2

The code for username text area looks like this. It doesn’t have any id and the xpath didn’t work as well.

The element from Twitter looks like this

<input autocapitalize="none" autocomplete="on" autocorrect="off" name="session[username_or_email]" spellcheck="false" type="text" dir="auto" data-focusable="true" class="r-30o5oe r-1niwhzg r-17gur6a r-1yadl64 r-deolkf r-homxoj r-poiln3 r-7cikom r-1ny4l3l r-1inuy60 r-utggzx r-vmopo1 r-1w50u8q r-1swcuj1 r-1dz5y72 r-1ttztb7 r-13qz1uu" value="">
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
zeecode
  • 21
  • 1

2 Answers2

1

To send a character sequence to the Email field with in Twitter login page https://twitter.com/login you have 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[name='session[username_or_email]']"))).send_keys("zeecode")
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='session[username_or_email]']"))).send_keys("zeecode")
    
  • 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
//input[@name="session[username_or_email]" and @type="text"]
sentence
  • 8,213
  • 4
  • 31
  • 40