Skip to content

Instantly share code, notes, and snippets.

@canimus
Forked from tarun3kumar/HeadlessFF.java
Last active August 29, 2015 14:22
Show Gist options
  • Save canimus/d818c257862f57302330 to your computer and use it in GitHub Desktop.
Save canimus/d818c257862f57302330 to your computer and use it in GitHub Desktop.
public static void main(String[] args) throws IOException {
// Setup firefox binary to start in Xvfb
String Xport = System.getProperty(
"lmportal.xvfb.id", ":1");
final File firefoxPath = new File(System.getProperty(
"lmportal.deploy.firefox.path", "/usr/bin/firefox"));
FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath);
firefoxBinary.setEnvironmentProperty("DISPLAY", Xport);
// Start Firefox driver
WebDriver driver = new FirefoxDriver(firefoxBinary, null);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://google.com/");
// Take snapshot of browser
File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File("ffsnapshot.png"));
driver.quit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment