Home > Back-end >  Selenium with Python cannot find button element
Selenium with Python cannot find button element

Time:08-04

So i'm trying to use Selenium to click the following search bar button:

<input name="someName" type="button" id="buttonid" value="Search"  style="margin-bottom:9px">

I'm getting the error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="buttonid"]"}

when I try to run:

search_button = driver.find_element(By.ID, "buttonid")

I also tried this:

search_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "buttonid")))

but it gives me a timeout exception. Implicitly waiting doesn't help either.

Has someone an idea what I am missing?

CodePudding user response:

As it seem, it is a search box or other something like this. Try driver.find_element(By.CLASS_NAME, "btn-primary")

CodePudding user response:

So I think i found the problem. The search bar and search button is apparently in an iframe and thats why I can't find the elements.

  • Related