Skip to content

Commit

Permalink
suppress output in both headless and headed modes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pabender committed Mar 4, 2019
1 parent 046eb72 commit 5b28fb1
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions java/test/jmri/util/web/BrowserFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ public static EventFiringWebDriver getBrowser(String browserName) {
driver = drivers.get("Firefox");
if (driver == null) {
WebDriverManager.getInstance(FirefoxDriver.class).setup();
FirefoxBinary firefoxBinary = new FirefoxBinary();
FirefoxOptions firefoxOptions = new FirefoxOptions();
if(GraphicsEnvironment.isHeadless()) {
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setBinary(firefoxBinary);
firefoxOptions.setLogLevel(org.openqa.selenium.firefox.FirefoxDriverLogLevel.ERROR);
driver = new EventFiringWebDriver(new FirefoxDriver(firefoxOptions));
firefoxBinary.addCommandLineOptions("--headless");
firefoxOptions.setBinary(firefoxBinary);
firefoxOptions.setLogLevel(org.openqa.selenium.firefox.FirefoxDriverLogLevel.ERROR);
} else {
driver = new EventFiringWebDriver(new FirefoxDriver());
firefoxOptions.setBinary(firefoxBinary);
firefoxOptions.setLogLevel(org.openqa.selenium.firefox.FirefoxDriverLogLevel.ERROR);
}
driver = new EventFiringWebDriver(new FirefoxDriver(firefoxOptions));
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
drivers.put("Firefox", driver);
}
Expand All @@ -56,13 +57,13 @@ public static EventFiringWebDriver getBrowser(String browserName) {
driver = drivers.get("Chrome");
if (driver == null) {
WebDriverManager.getInstance(ChromeDriver.class).setup();
ChromeOptions chromeOptions = new ChromeOptions();
if(GraphicsEnvironment.isHeadless()) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless --log-level=3");
driver = new EventFiringWebDriver(new ChromeDriver(chromeOptions));
} else {
driver = new EventFiringWebDriver(new ChromeDriver());
chromeOptions.addArguments("--log-level=3");
}
driver = new EventFiringWebDriver(new ChromeDriver(chromeOptions));
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
drivers.put("Chrome", driver);
}
Expand Down

0 comments on commit 5b28fb1

Please sign in to comment.