我有一個webobject
,當我點擊它,我得到:檢查Web對象是否位於Selenium中的其他Web對象的前面?
selenium.common.exceptions.WebDriverException: Message: u'unknown error: Element is not clickable at point (128, 605). Other element would receive the click: ...\n (Session info: chrome=37.0.2062.120)\n (Driver info: chromedriver=2.10.267518,platform=Linux 3.13.0-36-generic x86_64)'
的原因是,有在它的前面,即約餅乾消息的其他對象。那麼當我點擊它時,如何確保Web對象前面沒有任何東西?
例子:
from selenium import webdriver
browser = webdriver.Chrome()
browser.get("http://cookie-script.com/")
browser.set_window_size(800, 800)
# Click the Start button that is behind the 'Cookies' popup
el=browser.find_elements_by_xpath("id('sp-feature')/div[1]/p[2]/a[1]")[0]
el.click()
也許會添加一些JavaScript /邏輯,只爲您的硒測試激活,隱藏不必要的彈出窗口等? – michaelb 2014-10-01 14:17:31
@michaelb以及我正在測試一個網站,那麼這將是一件壞事。 – Pithikos 2014-10-01 14:18:48
那麼,如果有什麼東西在可點擊的對象前面,那麼真正的用戶也會有麻煩,所以這也是不正確的。也許在你的測試中,首先關閉cookie信息? – michaelb 2014-10-01 14:20:27