Selenium not clicking 'Log In' button on Discover website login

Viewed 159

I am trying to build a Python script that will automatically log me into my Discover CC webpage. I got the username and password to enter themselves (CC info code not shown here for security reasons) but I can't get selenium to hit the 'Log In' button.

Here's the Discover webpage I'm using.

Here's the code I have so far:

import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

driver = webdriver.Firefox()

driver.get('https://www.discover.com/')

time.sleep(5)

driver.find_element_by_id('log-in-button').click()

Here's the error Sublime Text 3 gives me: "selenium.common.exceptions.ElementNotInteractableException: Message: Element could not be scrolled into view"

The button is clearly visible so I'm not sure why it can't see it. I also gave the webpage some time to load before I try hitting the Log In button. Side note: if I let the script enter the username and password and I manually hit 'Log In' it logs me in.

1 Answers

Replace the last line with:

driver.find_element_by_xpath("//input[@id='log-in-button' and @class='btn-primary log-in-button right']").click()

Related