I am losing my mind here and cannot find what error could or if something is missing.
I am trying to automate the login process using Python and Selenium. When I step into each line of my code, it works without any issue. But if I just press run and the code is completed without any issue but it doesn't log in.
It logs in when I keep the chrome screen on the side like the image below but not when I just don't do anything after running the code.
This is my code to click the button
try:
cookies_Button = driver.find_element_by_xpath("//button[@title='Accept Cookies']")
cookies_Button.click()
time.sleep(5)
except:
print("Cookies Button click failed")
try:
Login_Button = driver.find_element_by_xpath("//input[@name='Login'][@type='button']")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME,'Login')))
print("Button is ready")
#time.sleep(10)
actions = ActionChains(driver)
actions.move_to_element(Login_Button).click().perform()
time.sleep(30)
except:
print("Login Button click failed")
Any help will be appreciated on how I can log in automatically.
The cookies were creating an issue. Adding the cokkies click helped resolving the issue
try:
cookies_Button = driver.find_element_by_xpath("//button[@title='Accept Cookies']")
cookies_Button.click()
time.sleep(5)
except:
print("Cookies Button click failed")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.