当我为此应用程序执行自动化代码时,将显示上面的弹出窗口.现在我需要知道如何使用Java在Selenium WebDriver中禁用PDF Viewer插件.
这就是我现在正在使用的不起作用的地方.
DesiredCapabilities capabilities = DesiredCapabilities
.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments(new String[] { "test-type" });
options.addArguments(new String[] { "disable-extensions" });
String pluginTodisable = "Chrome PDF Viewer";
options.addArguments("plugins.plugins_disabled", pluginTodisable);
capabilities.setCapability("chrome.binary",
chromeDriver.getAbsolutePath());
capabilities.setCapability(ChromeOptions.CAPABILITY,
options);
options.addArguments("--lang=en-gb");
GlobalVars.driver = new ChromeDriver(capabilities);
解决方法:
以下是使用Selenium / Chrome禁用Flash和PDF查看器的示例:
ChromeOptions options = new ChromeOptions();
Map<String, Object> preferences = new Hashtable<String, Object>();
options.setExperimentalOption("prefs", preferences);
// disable flash and the PDF viewer
preferences.put("plugins.plugins_disabled", new String[] {
"Adobe Flash Player",
"Chrome PDF Viewer"
});
// launch the browser and navigate to the page
ChromeDriver driver = new ChromeDriver(options);
driver.get("https://www.google.co.uk");
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。