-
Notifications
You must be signed in to change notification settings - Fork 34
/
whatsapp_group.py
49 lines (45 loc) · 1.73 KB
/
whatsapp_group.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
import csv
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def group_add(name):
l=[]
with open('Samples/people.csv','rt')as f:
data = csv.reader(f)
for row in data:
if row[1] != "Given Name":
l.append(row[1])
driver = webdriver.Firefox()
driver.maximize_window()
r=driver.get('https://web.whatsapp.com/')
time.sleep(20)
try:
driver.find_element_by_xpath('//*[@title="{}"]'.format(name)).click()# name of the group
except:
print("WhatsApp group doesn't exist")
print("Please Try again")
return
f = WebDriverWait(driver, 30).until(EC.visibility_of_element_located((By.XPATH,'//*[@class="_3V5x5"]')))
f.click()
f = WebDriverWait(driver, 30).until(EC.visibility_of_element_located((By.XPATH,'//*[@class="_3p0T6"]')))
f.click()
"""
driver.find_elements_by_class_name("_3V5x5")[0].click()
time.sleep(25)
driver.find_elements_by_class_name("_3p0T6")[0].click()
"""
for i in l :
driver.find_element_by_xpath('//*[@title="Search…"]').send_keys(i)
time.sleep(5)
driver.find_element_by_xpath('//*[@title="{}"]'.format(i)).click()
driver.find_element_by_xpath('//*[@data-icon="checkmark-light"]').click()
time.sleep(5)
f = WebDriverWait(driver, 30).until(EC.visibility_of_element_located((By.XPATH,'//*[@class="_2eK7W _3PQ7V"]')))
f.click()
return
name=input("Enter the name of the WhatsApp group you want to add people to")
group_add(name)