Рет қаралды 367
In this video will see how to take/capture multiple screenshot or taking screenshots multiple times in a web application.
Video link for How to take a screenshot in selenium web driver:
• How to take a screensh...
I hope you like this video. For any questions, suggestions or appreciation please contact us at: programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Details:
programmerworld.co/selenium/h...
Code:
import java.io.File;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import com.google.common.io.Files;
public class captureScreenShot {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "directory path of chromedriver exe\\chromedriver.exe");
ChromeOptions op = new ChromeOptions();
op.setBinary("dierectory path of chrome exe\\chrome.exe");
op.addArguments("--remote-allow-origins=*");
WebDriver driver = new ChromeDriver(op);
driver.get("programmerworld.co/");
captureScreenShot.capSrShot(driver, "landingPage");
driver.findElement(By.xpath("//a[text()='Home']")).click();
captureScreenShot.capSrShot(driver, "HomePage");
}
public static void capSrShot(WebDriver driver, String name) throws IOException {
File f = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
Files.copy(f, new File("directory path to save screenshot\\"+name+".jpg"));
}
}
--