【发布时间】:2015-07-09 17:12:59
【问题描述】:
我正在使用 Selenium 和 ChromeDriver 2.43.1 和最新的 Chrome(在提出问题时版本为 42.0.2311.135)。我的 Web 应用程序生成 PDF。它使用正确的 MIME 类型发送,并且在 Chrome PDF 查看器中也正确打开。但是,当我尝试在由 WebDriver 启动的 Chrome 中使用 Selenium 打开 PDF 时,它会被下载。
我相信这可能是 Selenium 或 WebDriver 用来启动 Chrome 的一些设置。
我尝试了settings a few switches,但还没有任何效果。我的代码:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
// Add ChromeDriver-specific capabilities through ChromeOptions.
ChromeOptions options = new ChromeOptions();
options.addArguments("--please-make-it-work"); // not a real switch
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
webDriver = new ChromeDriver(capabilities);
webDriver.get(url);
我真正需要的是以“正常”模式启动浏览器。它不需要任何配置文件设置,只需要打开 PDF 的默认设置。
【问题讨论】:
-
你检查过这个链接吗? stackoverflow.com/questions/29780399/…
标签: java google-chrome pdf selenium selenium-chromedriver