Reputation: 43
Chrome version: 61 to 63
Chrome webdriver: 2.33 to 2.35
I'm unable to get screenshot in my selenium program, which I run using Xvfb.
((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
Program runs well on a windows machine, and I get a screenshot using above code. But, when I run the program on a Linux server, using Xvfb I get a blank white screenshot, with nothing else.
Upvotes: 2
Views: 2901
Reputation: 990
That solved my problem:
ChromeOptions chromeOptions = new ChromeOptions();
HashMap<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("intl.accept_languages", "English");
chromeOptions.setExperimentalOption("prefs", chromePrefs);
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("enable-automation");
chromeOptions.addArguments("--headless"); //should be enabled for Jenkins
chromeOptions.addArguments("--disable-dev-shm-usage"); //should be enabled for Jenkins
chromeOptions.addArguments("--window-size=1920x1080"); //should be enabled for Jenkins
chromeOptions.addArguments("--disable-notifications");
chromeOptions.addArguments("--disable-extenstions");
chromeOptions.addArguments("--disable-gpu");
chromeOptions.addArguments("--dns-prefetch-disable");
chromeOptions.addArguments("disable-infobars");
chromeOptions.addArguments("force-device-scale-factor=0.65");
chromeOptions.addArguments("high-dpi-support=0.65");
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
driver = new ChromeDriver(chromeOptions);
Upvotes: 1
Reputation: 1
After drilling the web I found a solution and I am more than happy to share it so others don't spend so much time on it.
I added an argument:
chromeOptions.AddArgument("--disable-gpu");
I hope that will work for you
Upvotes: 0