1

I'm a beginner in Selenium. I want to type the address in the search box. But I have a problem with finding that field. Field HTML code:

<input type="text" class="SearchField_SearchField__hDobT" placeholder="Address..." value="">

I'm trying to do something like this:

element = driver.find_element_by_xpath("//input[@class='SearchField_SearchField__hDobT']")

or

element=driver.find_element_by_class_name("SearchField_SearchField__hDobT")

I get that errors:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@class='SearchField_SearchField__hDobT']"}
  (Session info: chrome=80.0.3987.132) 

or

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".SearchField_SearchField__hDobT"}
  (Session info: chrome=80.0.3987.132).

I cannot access other fields either. I render the HTML content with JavaScript.

I don't know what the problem is. Please help!

viam0Zah
  • 25,949
  • 8
  • 77
  • 100
TigerJ
  • 87
  • 1
  • 6
  • Can you access other elements on the page with Selenium? Do you render the HTML content with JavaScript? – viam0Zah Jul 13 '20 at 08:33
  • **Can you access other elements on the page with Selenium?** - No. I have for example this field :`` and I have the same problem. **Do you render the HTML content with JavaScript?**- Yes. – TigerJ Jul 13 '20 at 08:40
  • 1
    Very likely the HTML element is not yet rendered by the time your Selenium script tries to access it then. You need to incorporate some waiting. See if this helps: https://stackoverflow.com/questions/39190910/nosuchelementexception-unable-to-locate-element?noredirect=1&lq=1 – viam0Zah Jul 13 '20 at 08:52
  • Thanks, it works, I need to wait until element visible. – TigerJ Jul 13 '20 at 09:26

0 Answers0