Selenium無法點擊元素,報錯:ElementClickInterceptedException:element click intercepted


我們在進行selenium UI自動化測試時,可能會遇到元素可以定位到,但不可點擊的情況,如下錯誤:

這個問題有兩種解決方式:

方式一:

element = driver.find_element_by_xpath("表達式")
driver.execute_script("arguments[0].click();", element)

方式二:

element = driver.find_element_by_xpath('表達式')
webdriver.ActionChains(driver).move_to_element(element ).click(element ).perform()

這兩種方式都可以解決此問題(我采用的第一種,畢竟簡潔嘛)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM