Accepting Cookies Error With Python/selenium On Www.instagram.com
I'm trying to, using Firefox, log into Instagram by using Python Selenium using the following code: from time import sleep from selenium import webdriver browser = webdriver.Firef
Solution 1:
I was working on this too and had a bit of struggle. This command finds the "Accept" button on the cookies pop up:
find_element_by_xpath("//button[text()='Accept']")
After the log in it prompts 2 more pop ups: 1 to save the log in informations, 1 to allow notifications on the browser. The lines after "#not now" take care of them in the same manner
from time import sleep
from selenium import webdriver
browser = webdriver.Firefox()
browser.implicitly_wait(5)
browser.get('https://www.instagram.com/')
sleep(2)
# cookie
cookie_button = browser.find_element_by_xpath("//button[text()='Accept']")
cookie_button.click()
username_input = browser.find_element_by_css_selector("input[name='username']")
password_input = browser.find_element_by_css_selector("input[name='password']")
username_input.send_keys("<your username>")
password_input.send_keys("<your password>")
login_button = browser.find_element_by_xpath("//button[@type='submit']")
login_button.click()
sleep(3)
# not now
save_login_info_button= browser.find_element_by_xpath("//button[text()='Not Now']")
save_login_info_button.click()
sleep(3)
notification_button= browser.find_element_by_xpath("//button[text()='Not Now']")
notification_button.click()
browser.close()
Post a Comment for "Accepting Cookies Error With Python/selenium On Www.instagram.com"