python - Firefox 和 geckodriver 更新后定位器出现问题
问题描述
我们有一个采用 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 代码 在此处输入图像描述
解决方案
在 Firefox 63 中添加了Shadow DOM支持。在您之前使用 Firefox 56 的设置中,使用了 shadydom polyfill,因为没有影子根封装,这使得 vaadin-context-menu-item 可以在元素查询中找到。
更新 Firefox 版本后有影子根,您需要在其中搜索。查看屏幕截图中的 dom 树,您需要选择 vaadin-menu-bar 内的影子根,并在该上下文中搜索 vaadin-context-menu-item。这个答案有一些如何做到这一点的例子。
推荐阅读
- java - 带有优先级队列的 Spring Boot 中的 RabbitMQ
- python - sqlalchemy.exc.IntegrityError:(psycopg2.errors.UniqueViolation)重复键值违反唯一约束“product_pkey”
- python - 在 ubuntu / debian io.h 上使用 pip 时出现扭曲 iocpsupport 错误
- python - Python/Pandas:根据列名对数据框列进行排序
- python - 字典/数组的 Python 类属性
- node.js - NPM 失败并显示代码:npm ERR!代码生命周期
- c++ - 我们可以创建 Ghostscript 的静态库吗?
- wpf - 为什么列表视图之间的拖放失败?
- django - 使用 json-schemas 验证 JSONField 中的多态数据
- javascript - 尝试导入错误:“getMoviesList”未从“./actions”导出;反应还原错误