如何告诉Selenium在Chrome 75的打印弹出窗口中按“取消"? [英] How can I tell Selenium to press cancel on a print popup in 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(正式版本)(64位)上进行了测试.它们现在具有其他元素
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>
用于在控制台中进行测试
For testing in console
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();")
编辑 ::对于版本 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的打印弹出窗口中按“取消"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!