1

I am new to selenium and have tried searching for this element using xpath, ID, and class, however I cannot seem to find it. Upon using inspect element, the element is certainly there.

<input type="email" class="chakra-input rr-auth-web-user-email-input css-1wpvo2" placeholder="Email" name="emailAddress" id="emailAddress" required="" aria-required="true">

I have tried

login = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='emailAddress']"))).click()

Adjusting for ID, class name, etc, but the code can't seem to find it.

I am expecting the code to find the element and clicking on it, I have done this before on other sites however I cannot seem to figure out why it is not working here.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
rayyyu
  • 11
  • 1

2 Answers2

0

Given the HTML:

<input type="email" class="chakra-input rr-auth-web-user-email-input css-1wpvo2" placeholder="Email" name="emailAddress" id="emailAddress" required="" aria-required="true">

To click on the clickable element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#emailAddress[name='emailAddress']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='emailAddress' and @name='emailAddress']"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Your mistake is that you're defining an event as a variable (the click() event, assigned to the login variable). You need to assign the actual element to the variable, as:

login = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='emailAddress']")))

And now you should be able to click on it:

login.click()

Also, this click should happen without assigning the element to a variable, by simply doing:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='emailAddress']"))).click()

Selenium documentation can be found here.

Barry the Platipus
  • 9,594
  • 2
  • 6
  • 30