[英]Selenium with Python cannot find button element
所以我正在尝试使用 Selenium 单击以下搜索栏按钮:
<input name="someName" type="button" id="buttonid" value="Search" class="btn-primary" style="margin-bottom:9px">
我收到错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="buttonid"]"}
当我尝试运行时:
search_button = driver.find_element(By.ID, "buttonid")
我也试过这个:
search_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "buttonid")))
但它给了我一个超时异常。 隐式等待也无济于事。
有人知道我错过了什么吗?
看起来,它是一个搜索框或其他类似的东西。 试试 driver.find_element(By.CLASS_NAME, "btn-primary")
所以我想我找到了问题所在。 搜索栏和搜索按钮显然在 iframe 中,这就是我找不到元素的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.