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:
https://youtu.be/j7ShHn8Ea7E
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Details:
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("https://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"));
}
}
Excerpt:
The provided content includes details about capturing multiple screenshots in a web application using Selenium WebDriver. It features a Java code snippet for capturing screenshots, and a video link demonstrating how to take a screenshot using Selenium WebDriver. Additionally, contact information for further inquiries or feedback is provided, along with an image excerpt.