Skip to content

Instantly share code, notes, and snippets.

@tarun3kumar
Created April 26, 2012 10:55
Show Gist options
  • Save tarun3kumar/2498760 to your computer and use it in GitHub Desktop.
Save tarun3kumar/2498760 to your computer and use it in GitHub Desktop.
Executing Headless test in Firefox driver
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