Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Selenium » Solved Programs » Screenshot in Selenium Automation

Capture ScreenShot in Selenium Automation


package com.selenium.test;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
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.firefox.FirefoxDriver;

import Library.Utility;

public class CaptureScreenshot {

public static void main(String[] args) throws IOException {
	
WebDriver driver = new FirefoxDriver();	

Utility obj = new Utility();
		
driver.get("https://www.gmail.com");

//save screenshot
Utility.captureScreenshot(driver, "loginpage");

//maximize the window
driver.manage().window().maximize();

//code to login into gmail 

/*
driver.findElement(By.xpath(""))
		.sendKeys("emailid");
driver.findElement(By.xpath(""))
		.sendKeys("password");

driver.findElement(By.xpath("")).click();

//save screenshot
Utility.captureScreenshot(driver, "loginaccepted");
*/

}

}