Element is not clickable at point,Other element would receive the click: xxx 遇到某个对象Click()不能正常使用?
生活随笔
收集整理的這篇文章主要介紹了
Element is not clickable at point,Other element would receive the click: xxx 遇到某个对象Click()不能正常使用?
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
環境:python3.6 + selenium 3.11 +? chromedriver.exe
在處理一個button對象的時候,需要激發一個click事件,但是這個button或者link外面包含了特別多的div和復雜的樣式,如下圖:
原代碼如下:
view_detail_tag = trTag.find_element_by_css_selector("[class='next-table-cell']") btn_div = view_detail_tag.find_element_by_css_selector("[class='next-btn next-btn-text next-btn-primary next-btn-medium']") btn_div.click()btn_div 的對象可以被正常獲取到,但是在執行 btn_div.click()函數的時候遇到如下錯誤。
Error 信息如下:
WebDriverException: Message: Element is not clickable at point (918, 13). Other element would receive the click: <div class="xxx"></div>?意思是說,點擊這個button的時候,這個單擊事件被上層的div給接收了……說明div覆蓋在這個button上面。
這時候我們就不能直接發送click事件了。需要做如下處理:
view_detail_tag = trTag.find_element_by_css_selector("[class='next-table-cell last']") btn_div = view_detail_tag.find_element_by_css_selector("[class='next-btn next-btn-text next-btn-primary next-btn-medium']")#方法1 btn_div.send_keys("\n")#方法2 btn_div.send_keys(Keys.SPACE) #方法3 driver.execute_script("arguments[0].click();", btn_div)通過這種方式,可以正常點擊選擇的button了.
?
總結
以上是生活随笔為你收集整理的Element is not clickable at point,Other element would receive the click: xxx 遇到某个对象Click()不能正常使用?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 百度笔试题——开发测试工程师(深圳)
- 下一篇: Mybatis通配符