How can I tell Selenium to press cancel on a print popup in Chrome 75?(如何告诉 Selenium 在 Chrome 75 的打印弹出窗口上按取消?)
问题描述
我一直在使用以下建议的解决方案:https://stackoverflow.com/a/41670021/4633408
I have been using the the suggested solution from : https://stackoverflow.com/a/41670021/4633408
自 Chrome 71 以来它运行良好.
And it worked perfectly since Chrome 71.
executor.executeScript("document.querySelector("print-preview-app").shadowRoot.querySelector("print-preview-header").shadowRoot.querySelector("paper-button.cancel-button").click();");
但它不再有效.
有没有人想办法在 Chrome 75 的打印预览中点击取消"?
Has anyone figured out a way to click, "Cancel" in the print preview for Chrome 75?
我发现了异常,它只是说:
I caught the exception and it simply says:
e:org.openqa.selenium.WebDriverException: unknown error: Cannot read property 'shadowRoot' of null
推荐答案
在版本 75.0.3770.142 (Official Build) (64-bit) 上测试了这个.他们现在有额外的元素
Tested this on Version 75.0.3770.142 (Official Build) (64-bit) .They have additional element now
<print-preview-sidebar id="sidebar"></print-preview-sidebar>
用于控制台测试
document.querySelector("print-preview-app").shadowRoot.querySelector("print-preview-sidebar").shadowRoot.querySelector("print-preview-header").shadowRoot.querySelector("paper-button.cancel-button").click()
使用 executor.executeScript
with executor.executeScript
executor.executeScript("document.querySelector("print-preview-app").shadowRoot.querySelector("print-preview-sidebar").shadowRoot.querySelector("print-preview-header").shadowRoot.querySelector("paper-button.cancel-button").click();")
EDIT :: 适用于版本 79.0.3945.88(官方版本)(64 位)
EDIT :: For Version 79.0.3945.88 (Official Build) (64-bit)
document.querySelector("print-preview-app").shadowRoot.querySelector("print-preview-sidebar").shadowRoot.querySelector("print-preview-button-strip").shadowRoot.querySelector("cr-button.cancel-button").click()
这篇关于如何告诉 Selenium 在 Chrome 75 的打印弹出窗口上按取消?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何告诉 Selenium 在 Chrome 75 的打印弹出窗口上按取消?
基础教程推荐
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 如何对 Java Hashmap 中的值求和 2022-01-01
