Hi,
Today we will be learning that how can we take screenshot using a selenium webdriver script.Screenshots are very useful in testing.It acts as a proof that a test case was run and executed.
import java.io.File;
import java.io.IOException;
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;
public class abcd {
public static void main(String ags[]) throws IOException
{
WebDriver driver=new FirefoxDriver();
driver.get("any website");
  
File file=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(file, new File("d:\\abc.jpg"));
}
}
Today we will be learning that how can we take screenshot using a selenium webdriver script.Screenshots are very useful in testing.It acts as a proof that a test case was run and executed.
SCRIPT FOR TAKING SCREENSHOT IN SELENIUM
import java.io.IOException;
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;
public class abcd {
public static void main(String ags[]) throws IOException
{
WebDriver driver=new FirefoxDriver();
driver.get("any website");
File file=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(file, new File("d:\\abc.jpg"));
}
}
 
 
![Latest Selenium Interview Questions [Updated 2019] Latest Selenium Interview Questions [Updated 2019]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiurKIZ53_uoMLjO-Ba0bWidMRDVVhnkqXT9h13xSMx4zldpFAs_CqQKTGBJPAUxc7rkVfxhflm6rT-rcf2kVRAiCkXv0gAmAVchHDgCIxY2r7nxnN7GrzvDnMK8AgYnAOhUibnJG2GLG4g/s72-c/SeleniumInterview.png) 
 
 
 
0 comments: