0
votes

I am using Selenium and ChromeDriver 2.43.1 with the latest Chrome (Version 42.0.2311.135 at the time the quetion was asked). My web application generates a PDF. It is being sent with the correct MIME type and it also correctly opens in the Chrome PDF viewer. However when I try to open the PDF using Selenium in Chrome that is started by the WebDriver, it gets downloaded.

I believe it might be some settings that Selenium or WebDriver use to start Chrome.

I've tried settings a few switches, but nothing worked yet. My code:

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);

What I really need is to start the browser in "normal" mode. It doesn't need any profile settings, just the defaults that will open the PDF.

1
Have you checked this link ? stackoverflow.com/questions/29780399/…Rupesh Shinde

1 Answers

0
votes

The problem was caused by the recent change to the behaviour of the --test-type switch. It is described in the ChromeDriver issue tracker.

The workaround is to disable this switch. Here's my code changed:

// Add ChromeDriver-specific capabilities through ChromeOptions.
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches", Arrays.asList("test-type"));
webDriver = new ChromeDriver(options);
webDriver.get(url);