为什么 SafariDriver 不能点击特定元素而 Chrome、FF、Edge 可以? [英] Why can't SafariDriver click on a specific element when Chrome, FF, Edge can?
本文介绍了为什么 SafariDriver 不能点击特定元素而 Chrome、FF、Edge 可以?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 MAC 上运行 Safari UI 测试时遇到问题.我有一个元素:
I have a trouble when running Safari UI tests on MAC. I have an element:
wd.find_element_by_xpath("//div[@id='ZoomBundle_people_search__searchTab-innerCt']//fieldset//span[text()='Company Information']")
它折叠/展开带有过滤器的隐藏块.当我在 Chrome、FF 或 Edge 中执行 click() 操作时,会执行此操作.但是当我为 Safari 运行相同的代码时,我得到了异常:
It collapses/uncollapses a hidden block with filters. When I perform a click() action in Chrome, FF or Edge, this action performed. But when I run the same code for Safari, I get the exception:
selenium.common.exceptions.ElementNotInteractableException: Message:
C:\python\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: ElementNotInteractableException
我尝试添加 WebDriverWait,但结果是一样的.它可以看到元素,但无法与之交互.
I tried to add WebDriverWait, but the result is the same. It sees the element, but can't interact with it.
推荐答案
这是一个 SafariDriver 问题.有一个建议尝试通过 JS 点击:
It's a SafariDriver issue. Got a suggestion to try clicking via JS:
wd.execute_script("arguments[0].click();", elem)
代替
elem.click()
它现在工作正常(=
这篇关于为什么 SafariDriver 不能点击特定元素而 Chrome、FF、Edge 可以?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文