我们有一个Vaadin技术的网站。
Test environment:
firefox-56.0.1
geckodriver: 0.20.0
Robotframework 4.1.1
selenium 3.141.0
Python 3.7.3
这个Python脚本正在工作,机器人可以点击这个定位器。
GetElement.py
def Get_Element_hmenu():
Lib = BuiltIn().get_library_instance('SeleniumLibrary')
Driver = Lib.driver
host1 = Driver.find_element_by_xpath("//vaadin-context-menu-item[@id='FILE_MENU']")
return host1
test.robot<br>
<br>
${Element}= Get_Element_hmenu
Log ${Element}
Click Element ${Element}
如果我更新这个组件
Firefox 92.0.1
Geckodriver 0.30.0
After update不能运行此代码。
NoSuchElementException: Message: Unable to locate element: //vaadin-context-menu-item[@id='FILE_MENU']
你知道我该怎么做吗?非常感谢
发布于 2021-11-02 10:34:43
Firefox63增加了对Shadow DOM的支持。在之前的Firefox56设置中,使用了shadydom polyfill,因为没有阴影根封装,所以可以在元素查询中找到vaadin-context-菜单项。
更新Firefox版本后,会出现卷影根,您需要在其中进行搜索。查看屏幕截图中的dom树,您需要选择vaadin-menu-bar中的影子根,并在该上下文中搜索vaadin- context -菜单项。This answer有一些如何做到这一点的例子。
https://stackoverflow.com/questions/69542990
复制相似问题