解决:selenium在chrome上运行报 Element is not clickable at point

解决:selenium在chrome上运行报 Element is not clickable at point

问题

Firefox上正常运行的脚本在chrome上提示Element is not clickable at point。
分析原因,首先肯定不是因为页面元素不存在而无法点击。也不是要点击的button不在预览范围内。
后来发现,是被前一步的操作的一个弹出层挡住了。因为前一步是弹出了一个list层,在关闭list的时候webdriver就立刻执行下一步点击这个元素(element)时,而这时list可能还没完全关闭掉。
解决办法是等待那个弹出层完全关闭掉,元素(element)可以点击的时候再执行

# 添加客户账户        
Wait Until Element Is Visible   %{U_WEB_STOCK_ADD_CUSTOMER_BTN} 
Click Element   %{U_WEB_STOCK_ADD_CUSTOMER_BTN} 
Wait Until Element Is Visible   %{U_WEB_STOCK_ADD_CUSTOMER} 
Input Text  %{U_WEB_STOCK_ADD_CUSTOMER} ${customer}
# 点击弹出层
Click Element   %{U_WEB_STOCK_CHOOSE_MANAGER}
${mng_element}	Self_Defined_Variable	${manager}
Click Element   ${mng_element} 
Capture Page Screenshot     
# 等待弹出层完全关闭掉
sleep   %{U_WEB_WAITING_TIME}   
${submit_element}  Self_Defined_Variable   提交
Click Element   ${submit_element}  
Wait Until Element Is Not Visible   %{U_WEB_STOCK_ADD_CUSTOMER_SUBMIT}  
Capture Page Screenshot     

等待直到定位的元素可以点击

至于FF上可以正常运行,是selenium支持的更好些。
具体原因:
“The reason for the element is not clickable at point(x,y) exception.
Some of my observation was

  • It mostly happens in Chrome so if you are mostly working with Firefox or IE then you will not be getting this exception.
  • Chrome does not calculate the exact location of element
  • Chrome always click in the middle of Element.
  • Sometimes you will get this exception due to Sync issue also.”

猜你喜欢

转载自blog.csdn.net/Allan_shore_ma/article/details/81182343