In this video I have shown how to take complete web page screenshot in selenium webdriver using Ashot API. Once application is loaded it is taking screenshot of complete web page by scrolling down the page till end.
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
Code:
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.shooting.ShootingStrategies;
public class captureScreenShot {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "directory path of chrome driver exe\\chromedriver.exe");
ChromeOptions op = new ChromeOptions();
op.setBinary("directory path of chrome exe\\chrome.exe");
op.addArguments("--remote-allow-origins=*");
WebDriver driver = new ChromeDriver(op);
driver.get("https://programmerworld.co/");
Screenshot scrShot= new AShot().shootingStrategy(ShootingStrategies.viewportPasting(500)).takeScreenshot(driver);
ImageIO.write(scrShot.getImage(), "jpg", new File("directory path to save screenshot\\NameOfScreenshot.jpg"));
}
}
Screenshot:
Excerpt:
The video demonstrates how to capture a complete web page screenshot using Selenium WebDriver and the AShot API. After loading the application, the code scrolls down the page to capture the entire content. The provided code is in Java and includes setting up ChromeOptions, initializing WebDriver, and capturing the screenshot. Additionally, a link to the website and an email address for inquiries or feedback are provided. An excerpt and a screenshot of the full page are also included.
For the full content, the video link, and the code, visit: https://youtu.be/D17eYz8FVvg