Selenium.ElementNotVisibleException: An element command could not be completed because the element i

selenium+python 写web自动化脚本,在Safari浏览器上遇到这个问题:

selenium.common.exceptions.ElementNotVisibleException: Message: An element command could not be completed because the element is not visible on the page.

https://github.com/SeleniumHQ/selenium/issues/5355

也就是链接显示的这个问题,有一个回答如下:

You can find details at https://bugs.webkit.org/show_bug.cgi?id=174710. This bug has been fixed, but Apple have yet to fix this in SafariDriver. This has been reported to Apple under bug report number 33459305.

是苹果浏览器的问题,目前在开发版已经解决,但是还没发布

那么怎么解决Safari浏览器的点击问题呢?

解决方法如下:

通过调用js的方法进行操作

  • execute_script(script, *args)

Example:

ele = browser.find_element_by_xpath('//*[@id="1$Menu"]/li')
browser.execute_script('arguments[0].click();', ele)

可正常执行

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值