[英]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.