| 
 | 1 | +from selenium import webdriver  | 
 | 2 | +import time  | 
 | 3 | +browser = webdriver.Chrome('chromedriver.exe')  | 
 | 4 | +browser.get('https://instagram.com/')  | 
 | 5 | +time.sleep(4)   | 
 | 6 | +#Automating the login  | 
 | 7 | +def login():#/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[1]/div/label/input  | 
 | 8 | + 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")  | 
 | 9 | + Username.send_keys("dummy7783")  | 
 | 10 | + time.sleep(4)  | 
 | 11 | + 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")  | 
 | 12 | + password.send_keys("17mtcs02")  | 
 | 13 | + password.submit()  | 
 | 14 | + time.sleep(5)  | 
 | 15 | +#Automate the notifications  | 
 | 16 | +def notification():  | 
 | 17 | + Notnow=browser.find_element_by_xpath("/html/body/div[1]/section/main/div/div/div/div/button")  | 
 | 18 | + Notnow.click()   | 
 | 19 | + time.sleep(3)  | 
 | 20 | + Noti=browser.find_element_by_xpath("/html/body/div[4]/div/div/div/div[3]/button[2]")  | 
 | 21 | + Noti.click()  | 
 | 22 | + time.sleep(7)  | 
 | 23 | +#click the message  | 
 | 24 | +def message():  | 
 | 25 | + msgclick=browser.find_element_by_class_name('xWeGp')  | 
 | 26 | + msgclick.click()  | 
 | 27 | + time.sleep(7)  | 
 | 28 | +#Final part of automation  | 
 | 29 | +def final():  | 
 | 30 | + chat=browser.find_element_by_class_name('QBdPU')  | 
 | 31 | + chat.click()  | 
 | 32 | + time.sleep(7)  | 
 | 33 | + typename=browser.find_element_by_xpath('/html/body/div[5]/div/div/div[2]/div[1]/div/div[2]/input')  | 
 | 34 | + typename.send_keys('arun.codes')  | 
 | 35 | + time.sleep(7)  | 
 | 36 | + name=browser.find_element_by_xpath('/html/body/div[5]/div/div/div[2]/div[2]/div[1]/div/div[2]/div[2]/div')  | 
 | 37 | + name.click()  | 
 | 38 | + time.sleep(7)  | 
 | 39 | + next=browser.find_element_by_class_name('rIacr').click()  | 
 | 40 | + time.sleep(7)  | 
 | 41 | + mbox = browser.find_element_by_tag_name('textarea')  | 
 | 42 | + mbox.send_keys('This is an automated message')  | 
 | 43 | + 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()  | 
 | 44 | +login()  | 
 | 45 | +notification()  | 
 | 46 | +message()  | 
 | 47 | +final()  | 
 | 48 | + | 
0 commit comments