-
Notifications
You must be signed in to change notification settings - Fork 51
/
Instamsg.py
48 lines (47 loc) · 1.91 KB
/
Instamsg.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
from selenium import webdriver
import time
browser = webdriver.Chrome('chromedriver.exe')
browser.get('https://instagram.com/')
time.sleep(4)
#Automating the login
def login():#/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[1]/div/label/input
Username=browser.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[1]/div/label/input")
Username.send_keys("username")
time.sleep(4)
password=browser.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[2]/div/label/input")
password.send_keys("password")
password.submit()
time.sleep(5)
#Automate the notifications
def notification():
Notnow=browser.find_element_by_xpath("/html/body/div[1]/section/main/div/div/div/div/button")
Notnow.click()
time.sleep(3)
Noti=browser.find_element_by_xpath("/html/body/div[4]/div/div/div/div[3]/button[2]")
Noti.click()
time.sleep(7)
#click the message
def message():
msgclick=browser.find_element_by_class_name('xWeGp')
msgclick.click()
time.sleep(7)
#Final part of automation
def final():
chat=browser.find_element_by_class_name('QBdPU')
chat.click()
time.sleep(7)
typename=browser.find_element_by_xpath('/html/body/div[5]/div/div/div[2]/div[1]/div/div[2]/input')
typename.send_keys('arun.codes')
time.sleep(7)
name=browser.find_element_by_xpath('/html/body/div[5]/div/div/div[2]/div[2]/div[1]/div/div[2]/div[2]/div')
name.click()
time.sleep(7)
next=browser.find_element_by_class_name('rIacr').click()
time.sleep(7)
mbox = browser.find_element_by_tag_name('textarea')
mbox.send_keys('This is an automated message')
send=browser.find_element_by_xpath('/html/body/div[1]/section/div/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/div[3]/button').click()
login()
notification()
message()
final()