-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathwhats_app_ubuntu.py
63 lines (47 loc) · 1.73 KB
/
whats_app_ubuntu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#import packages
from selenium import webdriver
from time import sleep
#get the driver for individual browser
driver = webdriver.Chrome('/usr/bin/chromedriver')
#scan the QR code
print("Scan the QR code")
driver.get("https://web.whatsapp.com/")
#send message function
def Sendmsg():
#enter name of receiver
name = input("Enter the name of user or group : ")
#enter the message
msg = input("Enter the message : ")
#enter the count
count = int(input("Enter Number of count : "))
user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))
user.click()
msg_box = driver.find_element_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')
for i in range(count):
msg_box.send_keys(msg)
button = driver.find_element_by_xpath('//*[@id="main"]/footer/div[1]/div[3]')
button.click()
#send image or video file function
def sendimgvid():
#enter name of receiver
name = input("Enter the name of user or group : ")
#enter file path
filepath = input("Enter the file path (Image,Video) : ")
user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))
user.click()
attachment_box = driver.find_element_by_xpath('//div[@title = "Attach"]')
attachment_box.click()
imgvid_box = driver.find_element_by_xpath('//input[@accept="image/*,video/mp4,video/3gpp,video/quicktime"]')
imgvid_box.send_keys(filepath)
sleep(3)
send_button = driver.find_element_by_xpath('//span[@data-icon="send-light"]')
send_button.click()
#user input
print("Press 1 for sending multiple messages \nPress 2 to send an image or video \nPress to exit")
n = int(input())
if (n == 1):
Sendmsg()
elif(n == 2):
sendimgvid()
elif(n==3):
quit()