![](/img/trans.png)
[英]selenium python not working with phantomjs but works with Firefox
[英]selenium phantomJS states 'element is not visible' but works fine in firefox
我正嘗試在商店網站中輸入郵政編碼,當我使用webdriver.firefox()但不能在PhantomJS上使用時,此方法可以正常工作。 相反,我得到一個錯誤:
NoSuchElementException: Message: {"errorMessage":"Unable to find element with id 'SL-map-search'"
這是我用來生成請求的相當簡單的代碼。 僅使用set_window_size的原因是,因為其他類似的問題表明這可以解決問題(沒有解決)。
driver = webdriver.PhantomJS()
# get address
driver.set_window_size(1920,1080)
driver.get("http://www.lowes.com/StoreLocatorDisplayView")
# select zipcode
element = driver.find_element(By.ID, 'SL-map-search')
element.send_keys(zipcode)
driver.find_element(By.ID, 'SL-map-search-submit').click()
任何幫助,將不勝感激!
等待元素出現:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "SL-map-search"))
)
element.send_keys(zipcode)
當我升級到El Capitan時,該錯誤已修復。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.