Created
April 26, 2012 10:55
-
-
Save tarun3kumar/2498760 to your computer and use it in GitHub Desktop.
Executing Headless test in Firefox driver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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