The below is a selenium python code where I am trying to click Sign In by sending the login details via selenium. However, when I am using find_element_by_id
method to locate the username and password input area the scripts throws an error
Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="usernameOrEmail"]"}
. But, when I am inspect the webpage on the input text type it shows me the same id which I have mentioned in my script.
P.S: When the selenium opens up the browser please maximize the windows else the code will not work
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
driver = webdriver.Chrome(executable_path='C://Arighna/chromedriver.exe')
driver.get("https://www.fool.com/")
print(driver.title)
mybutton = driver.find_element_by_id('login-menu-item')
mybutton.click()
delay = 5
WebDriverWait(driver,delay)
email_area = driver.find_element_by_id('usernameOrEmail')
email.send_keys(Keys.ENTER)
email_area.send_keys('ar')
WebDriverWait(driver,delay)
pwd_area = driver.find_element_by_id('password')
pwd_area.send_keys(Keys.ENTER)
pwd_area.send_keys('1234')
WebDriverWait(driver,delay)
login_btn = driver.find_element_by_id('btn-login')
login_btn.click()
Any help is really appreciated.