-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwhatsapp1.py
330 lines (287 loc) · 11.2 KB
/
whatsapp1.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
import os
from selenium import webdriver
import logging
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
def dp_click_back():
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/div/header/div/div[1]/button/span")
python_button.click()
return
def dp_click():
time.sleep(15)
python_button = driver.find_element_by_xpath("//*[@id='side']/header/div[1]/div/img")
python_button.click()
return
def view_dp():
time.sleep(5)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/div/div/div[1]/div/div/div/div/div/img")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[4]/div/ul/li[1]/div")
python_button.click()
time.sleep(5)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[3]/div/div/div[1]/div[2]")
python_button.click()
return
def remove_dp():
time.sleep(3)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/div/div/div[1]/div/div/div/div/div/img")
python_button.click()
time.sleep(3)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[4]/div/ul/li[4]/div")
python_button.click()
time.sleep(3)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[2]/div/div/div/div/div/div/div[2]/div[2]")
python_button.click()
return
def upload_dp():
time.sleep(3)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/div/div/div[1]/div/div/span/div")
python_button.click()
time.sleep(3)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[4]/div/ul/li[2]/div")
python_button.click()
time.sleep(3)
#python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[4]/div/ul/li[4]/div")
#python_button.click()
def change_name():
time.sleep(3)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/div/div/div[2]/div[2]/div[1]/span[2]/div/span")
python_button.click()
time.sleep(2)
actions = ActionChains(driver)
for i in range(20):
actions.send_keys(Keys.BACKSPACE).perform()
name = input("give name")
actions.send_keys(name)
actions.send_keys(Keys.ENTER).perform()
return
def change_about():
time.sleep(3)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/div/div/div[4]/div[2]/div[1]/span[2]/div/span")
python_button.click()
time.sleep(2)
actions = ActionChains(driver)
for i in range(40):
actions.send_keys(Keys.BACKSPACE).perform()
name = input("give about")
actions.send_keys(name)
actions.send_keys(Keys.ENTER).perform()
return
def view_archived():
time.sleep(3)
python_button = driver.find_element_by_xpath("//*[@id='side']/header/div[2]/div/span/div[3]")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='side']/header/div[2]/div/span/div[3]/span/div/ul/li[3]/div")
python_button.click()
time.sleep(5)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/div/header/div/div[1]/button/span")
python_button.click()
return
def view_starred():
time.sleep(3)
python_button = driver.find_element_by_xpath("//*[@id='side']/header/div[2]/div/span/div[3]/div/span")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='side']/header/div[2]/div/span/div[3]/span/div/ul/li[4]/div")
python_button.click()
time.sleep(5)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/div/div/header/div/div[1]/button/span")
python_button.click()
return
def setting():
time.sleep(3)
python_button = driver.find_element_by_xpath("//*[@id='side']/header/div[2]/div/span/div[3]/div/span")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='side']/header/div[2]/div/span/div[3]/span/div/ul/li[5]/div")
python_button.click()
return
def setting_back():
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/span/div/header/div/div[1]/button/span")
python_button.click()
return
def notification():
setting()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/span/div/div/div[2]/div[2]")
python_button.click()
setting_back()
return
def notificaton_back():
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/span/div/header/div/div[1]/button/span")
python_button.click()
return
def notification_sound():
notification()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/span/div/div/div/div[1]/div[1]/div")
python_button.click()
notificaton_back()
return
def notification_Desktop_alerts():
notification()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/span/div/div/div/div[2]/div[2]")
python_button.click()
notificaton_back()
return
def notification_show_previews():
notification()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[1]/span/div/span/div/div/div/div[3]/div[2]")
python_button.click()
notificaton_back()
return
def group_chat_dots():
time.sleep(5)
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/div/span")
python_button.click()
return
def group_info():
group_chat_dots()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/span/div/ul/li[1]/div")
python_button.click()
return
def group_info_back():
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[3]/span/div/span/div/header/div/div[1]/button/span")
python_button.click()
return
def change_group_name():
group_info()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[3]/span/div/span/div/div/div[1]/div[1]/div[2]/div[1]/span[2]/div/span")
python_button.click()
time.sleep(2)
actions = ActionChains(driver)
for i in range(40):
actions.send_keys(Keys.BACKSPACE).perform()
name = input("give about")
actions.send_keys(name)
actions.send_keys(Keys.ENTER).perform()
group_info_back()
return
def change_group_desc():
group_info()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/div/div[2]/div[3]/span/div/span/div/div/div[1]/div[2]/div[2]/div/div/span[2]/div/span")
python_button.click()
time.sleep(2)
actions = ActionChains(driver)
for i in range(40):
actions.send_keys(Keys.BACKSPACE).perform()
name = input("give about")
actions.send_keys(name)
actions.send_keys(Keys.ENTER).perform()
group_info_back()
return
def mute_group():
time.sleep(2)
group_chat_dots()
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/span/div/ul/li[3]/div")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[2]/div/div/div/div/div/div/div[2]/form/ol/li[3]/label/input")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[2]/div/div/div/div/div/div/div[3]/div[2]")
python_button.click()
return
def unmute_group():
time.sleep(2)
group_chat_dots()
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/span/div/ul/li[3]/div")
python_button.click()
return
def clear_group_chat():
time.sleep(2)
group_chat_dots()
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/span/div/ul/li[4]/div")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[2]/div/div/div/div/div/div/div[2]/div[2]")
python_button.click()
return
def exit_group_chat():
time.sleep(2)
group_chat_dots()
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/span/div/ul/li[5]/div")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[2]/div/div/div/div/div/div/div[2]/div[2]]")
python_button.click()
return
def individual_chat_dots():
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/div/span")
python_button.click()
return
def individual_info():
individual_chat_dots()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/span/div/ul/li[1]/div")
python_button.click()
def individual_chat_mute():
individual_chat_dots()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/span/div/ul/li[3]/div")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[2]/div/div/div/div/div/div/div[2]/form/ol/li[3]/label/input")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[2]/div/div/div/div/div/div/div[3]/div[2]")
python_button.click()
return
def individual_clear_chat():
individual_chat_dots()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/span/div/ul/li[4]/div")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[2]/div/div/div/div/div/div/div[2]/div[2]")
python_button.click()
return
def individual_delete_chat():
individual_chat_dots()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[3]/span/div/ul/li[5]/div")
python_button.click()
time.sleep(2)
python_button = driver.find_element_by_xpath("//*[@id='app']/div/span[2]/div/div/div/div/div/div/div[2]/div[2]")
python_button.click()
return
if __name__ == '__main__':
LOG_FILENAME = 'logger.log'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
logging.info('This message should go to log file')
chromedriver = "C:\webdrivers\chromedriver.exe"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.get("https://web.whatsapp.com")
dp_click()
view_dp()
dp_click_back()
#remove_dp()
#upload_dp()
#change_name()
#change_about()
#view_archived()
#view_starred()
#setting()
#notification()
#notification_sound()
#notification_show_previews()
#notification_Desktop_alerts()
#group_info()
#group_info_back()
#group_chat_dots()
#change_group_name()
#change_group_desc()