Firefox 和 geckodriver 更新后定位器出现问题
Problem with Locators after Firefox and geckodriver update
我们有一个采用 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
更新后此代码无效。
NoSuchElementException: Message: Unable to locate element: //vaadin-context-menu-item[@id='FILE_MENU']
你有什么想法,我该怎么办?
非常感谢
HTML代码
enter image description here
Shadow DOM 支持已添加到 Firefox 63 中。在您之前使用 Firefox 56 进行的设置中,使用了 shadydom polyfill,因为没有影子根封装,这使得 vaadin-context-可在元素查询中找到菜单项。
更新Firefox版本后有影子根,需要在里面搜索。查看屏幕截图中的 dom 树,您需要 select vaadin-menu-bar 内的影子根,并在该上下文中搜索 vaadin-context-menu-item。 This answer 有一些如何操作的示例。
我们有一个采用 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
更新后此代码无效。
NoSuchElementException: Message: Unable to locate element: //vaadin-context-menu-item[@id='FILE_MENU']
你有什么想法,我该怎么办? 非常感谢
HTML代码 enter image description here
Shadow DOM 支持已添加到 Firefox 63 中。在您之前使用 Firefox 56 进行的设置中,使用了 shadydom polyfill,因为没有影子根封装,这使得 vaadin-context-可在元素查询中找到菜单项。
更新Firefox版本后有影子根,需要在里面搜索。查看屏幕截图中的 dom 树,您需要 select vaadin-menu-bar 内的影子根,并在该上下文中搜索 vaadin-context-menu-item。 This answer 有一些如何操作的示例。