r - RSelenium,根据文本字符串按下按钮
问题描述
我正在从网站收集一些数据,我需要按一个按钮来打印(并保存)每个对象。为此,我使用 RSelenium。我要导航并单击的是:
<a href="javascript:void(0)" data-bind="clickAndTouch: onClick, blockTouches: true"><span data-bind="attr: { 'class': css() || name() }" aria-hidden="true" class="pri pri-print"></span><em data-bind="text: title()">Print</em></a>
我尝试了几种导航到此的方法,我使用了 XPath,但 XPath 会因不同的搜索而变化。由于我想自动执行此操作并收集更多数据,因此这是行不通的。我相信通过文本“打印”进行导航和单击将是最充分的方式。但是,我还没有找到合适的方法来做到这一点。我试过了:
remote_driver$findElement(using = 'xpath', ("//*[text() = 'Print']"))$clickElement()
但这会导致此错误:
Selenium message: element not interactable
(Session info: chrome=81.0.4044.92)
(Driver info: chromedriver=81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776}),platform=Windows NT 10.0.18363 x86_64)
Error: Summary: ElementNotVisible
Detail: An element command could not be completed because the element is not visible on the page.
Further Details: run errorDetails method
我也尝试过上课但没有成功。我对使用 Selenium 比较陌生,所以希望有人可以给我一个解决方案,并在遇到这些问题时指出一种更好的方法来思考这些问题。
提前致谢!
解决方案
推荐阅读
- node.js - 使用私有解密(publicEncrypt、privateDecrypt)解密时出现错误解密错误
- nsis - NSIS 安装程序屏幕中的新自定义打印按钮未显示
- javascript - Thymeleaf JS 无法传递参数
- javascript - 重构javascript中的硬代码
- azure - IoT Workbench 中仅显示一个 Azure 订阅:Cloud Azure 配置命令
- angular - 如何对角度@Output 进行单元测试
- ios - Ionic Cordova Typescript iOS App - 自动从 BLE 检索数据
- css - 如何选择最后一个元素?
- javascript - 在 componentDidMount 或单击按钮时调用 API
- javascript - 在跨域 iframe 中获取 iframe id