Hello I am using a automated web scraper but at random times the screen is covered with an accept cookies popup that blocks the form click button. It affects the whole script and I don't know how I could write and if cookie_pop_up.close() or something of that nature. Get the xpath of the close for cookies?
I am trying to log into snapchat here is my code:
hrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(f"--proxy-server=http://{random.choice(live_proxies)}")
driver = webdriver.Chrome("chromedriver.exe", options=chrome_options)
driver.set_window_position(-10000,0)
driver.get("https://accounts.snapchat.com/accounts/login")
if "Log in to Snapchat" in driver.page_source:
proxy_is_valid = True
user_input = driver.find_element_by_id("username")
user_input.send_keys(user)
passsword_input = driver.find_element_by_id("password")
passsword_input.send_keys(password)
login_button = driver.find_element_by_xpath("/html/body/div[1]/div/div/div[3]/article/div[1]/div/form/div[4]/button")
login_button.click()
if check_for_captcha_connectivity(driver):
solve(driver)
Here is the error:
File "C:\Users\Administrator\Desktop\python\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\Users\Administrator\Desktop\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\Administrator\Desktop\python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <button type="submit" class="btn btn-lg btn-primary">...</button> is not clickable at point (507, 384). Other element would receive the click: <div class="cookie-popup">...</div>
(Session info: chrome=77.0.3865.75)
HERE IS WHAT IT LOOKS LIKE THAT BLOCKS IT FROM LOGIN: https://imgur.com/gallery/sZroFq9
thanks in advance!
update I tried this
login_button = driver.find_element_by_xpath("/html/body/div[1]/div/div/div[3]/article/div[1]/div/form/div[4]/button")
login_button.click()
if ElementClickInterceptedException:
time.sleep(1)
driver.find_element_by_xpath("/html/body/div[1]/div/div/div[3]/div/div/div[3]/div[4]").click()
continue
still failed the indents pasted weirdly ^