Wednesday, 12 November 2014

Screenshots using selenium.

package Flowell.Flowell1;

import java.io.File;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

@Test
public class iTextPDFTutorial {
    public void iTextPDF() throws Exception{
   
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com/");
        File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
        // Now you can do whatever you need to do with it, for example copy somewhere
        FileUtils.copyFile(scrFile, new File("C:\\Users\\Youtility\\Desktop\\screenshot.png"));
       
    }
}

No comments:

Post a Comment