4

I am trying to use Python to automate something.

I can't seem to locate the email input element with driver.find_element_by_. I tried so many different ways. I just want to be able to log into the website with Chromedriver.

<div class="css-1ilyui9">
    <input type="email" required="" class="css-cgadzw" value="">
</div>

The email input box doesn't have any attributes. No name or id. Class is not unique. Password box has the same class.

This is what I have so far. I just want Python to log in for me and go to a certain page periodically but I am unable to send_key because I can't find the element. It keeps saying "element not found".

from selenium import webdriver

chrome_path = r"C:\Users\peter\Desktop\chromedriver.exe"
driver = webdriver.Chrome(executable_path=r"C:\Users\peter\Desktop\chromedriver.exe")
driver.get("https://")
driver.find_element_by_xpath("//input[@type='email']")

Error Code:

selenium.common.exceptions.NoSuchElementException: 
Message: no such element: 
Unable to locate element: {"method":"xpath","selector":"//input[@type='email']"}
  (Session info: chrome=78.0.3904.108)
halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

2

Try to use two identifiers in your selector:

driver.find_element_by_xpath("//input[@class='css-cgadzw'][@type='email']")

Also, you may need to put some wait in order to be able to see the element on page as refereed here

furkanayd
  • 811
  • 7
  • 19
  • 1
    Hey man, thanks for the input. I tried that... but same error codeselenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@class='css-cgadzw'][@type='email']"} (Session info: chrome=78.0.3904.108) – URBAN416 com Dec 06 '19 at 05:03
  • 1
    I will try adding the wait and see. Thanks :) – URBAN416 com Dec 06 '19 at 05:05