How to Take Full Page Screenshot in Selenium Using Ashot API (Java)
By Bhau Automation Lab • Selenium Full Page Screenshot Tutorial
🎯 What You Will Learn
- How to take full page screenshot in Selenium
- What is Ashot API?
- How to configure Ashot in Maven project
- Difference between normal screenshot and full page screenshot
- Practical Java example using Ashot
💡 Default Selenium screenshot captures only visible area. Ashot API captures entire scrollable webpage.
📌 Why We Need Ashot API?
Selenium WebDriver default TakesScreenshot interface captures only the visible portion of the screen. To capture the complete scrollable webpage, we use Ashot API.
📌 Add Ashot Dependency (Maven)
ru.yandex.qatools.ashot ashot 1.5.4
💻 Full Page Screenshot Using Ashot (Java Code)
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.shooting.ShootingStrategies;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
public class FullPageScreenshot {
public static void main(String[] args) throws IOException {
WebDriver driver = new ChromeDriver();
driver.get("https://example.com");
Screenshot screenshot = new AShot()
.shootingStrategy(ShootingStrategies.viewportPasting(1000))
.takeScreenshot(driver);
ImageIO.write(screenshot.getImage(), "PNG",
new File("./Screenshots/FullPage.png"));
System.out.println("Full Page Screenshot Captured Successfully!");
driver.quit();
}
}
📍 How Ashot Works
- Scrolls page automatically
- Captures multiple screenshots
- Merges them into single full-page image
⚡ Real-Time Framework Use Case
- UI validation testing
- Visual regression testing
- Failure screenshot reporting
- Extent Report integration
❓ Interview Questions
Q: Can Selenium take full page screenshot by default?
A: No, Selenium captures only visible area. For full page, use Ashot API.
Q: Which method is used for full page capture in Ashot?
A: ShootingStrategies.viewportPasting()
🎥 Watch Complete Video Tutorial
👉 Watch on YouTube: Full Page Screenshot Using Ashot API
🎓 Key Takeaways
- Selenium default screenshot captures only visible area
- Ashot API captures entire scrollable page
- viewportPasting() method enables full page screenshot
- Useful in automation frameworks and reporting
- Important Selenium 4 interview topic
🚀 Created with ❤️ by Bhau Automation Lab