Skip to content

Instantly share code, notes, and snippets.

@hristo-vrigazov
Created December 7, 2016 15:17
Show Gist options
  • Save hristo-vrigazov/943ec837153259e97b954295548e303d to your computer and use it in GitHub Desktop.
Save hristo-vrigazov/943ec837153259e97b954295548e303d to your computer and use it in GitHub Desktop.
Starting Chrome in headless mode
package config;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import com.google.common.collect.ImmutableMap;
/**
* Created by hvrigazov on 06.12.16.
*/
public class ExperimentsTest {
@Test
public void experiment() throws InterruptedException, IOException {
ChromeDriverService chromeDriverService = new ChromeDriverService.Builder()
.usingDriverExecutable(new File("/home/hvrigazov/chrome_driver/chromedriver"))
.usingAnyFreePort().withEnvironment(ImmutableMap.of("DISPLAY", ":1")).build();
chromeDriverService.start();
WebDriver driver = new ChromeDriver(chromeDriverService);
driver.quit();
chromeDriverService.stop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment