-
Notifications
You must be signed in to change notification settings - Fork 1
/
automate.py
56 lines (47 loc) · 1.85 KB
/
automate.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
from time import sleep
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
browser = webdriver.Firefox()
browser.implicitly_wait(5)
browser.get('https://instagram.com/')
sleep(2)
username_input = browser.find_element_by_css_selector("input[name='username']") #target input userid
password_input = browser.find_element_by_css_selector("input[name='password']") #target iput type password
username_input.send_keys("atul.tiwariii") #yaha par apni insta id dalo
password_input.send_keys("########") #yaha par apna password of insta dalo
btn = browser.find_element_by_xpath("//button[@type='submit']") #for clicking loggin button
btn.click()
sleep(10)
users = ["subham_yadav834", "ashish.kesharwanii", "pradeep"]
for i in range(0, 3):
prf = browser.find_element_by_xpath("//div[2]/input")
sleep(1)
prf.send_keys(users[i])
sleep(3)
cl_t_prf = browser.find_element_by_xpath("//div[2]/div/div/a/div")
cl_t_prf.click()
sleep(3)
cl_t_msg = browser.find_element_by_xpath("//button[contains(.,'Message')]")
cl_t_msg.click()
sleep(3)
try:
not_now = browser.find_element_by_xpath("//button[contains(.,'Not Now')]")
not_now.click()
cl_t_s_msg = browser.find_element_by_xpath("//textarea")
cl_t_s_msg.click()
cl_t_s_msg.send_keys("Bye Bye! "+users[i])
sleep(1)
send_msg = browser.find_element_by_xpath("//button[contains(.,'Send')]")
send_msg.click()
except NoSuchElementException as exception:
cl_t_s_msg = browser.find_element_by_xpath("//textarea")
cl_t_s_msg.click()
cl_t_s_msg.send_keys("Hello! "+users[i])
sleep(1)
send_msg = browser.find_element_by_xpath("//button[contains(.,'Send')]")
send_msg.click()
print("no such yyyyyyyyyyyyyyyyyyyy")
else:
print("No Exception Found")
finally:
print("All Set!!")