Jul-07-2024, 04:11 PM
I'm trying to write a script (Python 2) to log in to a web site. However, in doing so there is a popup that occurs (allow cookies) preventing me from filling in the login. I have the following function to do the login but it does not catch the popup.
. . . from selenium import webdriver from selenium.webdriver.firefox.options import Options as FirefoxOptions from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By . . . options=FirefoxOptions() options.add_argument("--headless") driver=webdriver.Firefox(executable_path="/usr/local/bin/geckodriver",options=options) . . . def reSend(address): uri="https://app.mailjet.com/signin" driver.get(uri) wait=WebDriverWait(driver,3) el=wait.until(EC.presence_of_element_located((By.ID,'onetrust-accept-btn-handler'))) driver.find_element_by_id('onetrust-accept-btn-handler').click() print(driver.page_source) login=driver.find_element_by_id('login') login.send_keys(USER_NAME) passwd=driver.find_element_by_id('password') passwd.send_keys(PASSWORD) submit=driver.find_element_by_id('form-btn').click() . . . . . .The popup has no title or form name but I know the button ID. However, the code I am using either does not wait for the popup or cannot find that ID. It is also possible that the popup will not occur after the first login but I know I have not reached that point yet. If you use that link you can see what I am dealing with. Can someone spot what I am doing wrong? TIA.