Software Test Engineer
pavankumar.nagaraj@gmail.com
Pavankumar Nagaraj Linkedin Profile
Mobile:+91 8971673487
Bangalore.

Senior Software Test Engineer
mr.vikasdumka@gmail.com
Vikas Kumar Linkedin Profile
Mobile:+91 8123492801
Bangalore.

This class helps the WebDriver 2.0 users to take multiple screenshots and element screenshots and mininimize the browser.
This construtor accepts two argument one is the path where to save the screenshots public MultiScreenShot(String path,String className)
path=C:\Users\xxxxxx\Desktop\New folder\TestMultiScreenShot_Screenshots\
and another argument is className,we are using this class name to create the folder and save the screenshot inside that.
className=MultiScreenShot
Takes the full screenshot of page whenever you call the method and this method accepts WebDriver object as argument
mShot.multiScreenShot(driver);Takes the element screenshot in a page whenever you call the method and this method accepts 2 arguments one is WebDriver object as argument and another one is WebElement object,(i.e ) which element we want to take as screenshot
mShot.elementScreenShot(driver, driver.findElement(By.id("search-submit")));This method minimizes the browser window if the browser is maximized on windows os,it does not accept any arguments
mShot.minimize();Associate the MultiScreenshot.jar file in your project by navigating Right click on project>Properties>Java Build path>Add Externar jars.
package testPackage;
import java.awt.AWTException;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import multiScreenShot.MultiScreenShot;
public class TestMultiScreenShot
{
public static void main(String[] args) throws IOException, AWTException
{
MultiScreenShot mShot=new MultiScreenShot("C:\\xxxx\\Desktop\\New\\","TestMultiScreenShot");
WebDriver driver =new FirefoxDriver();
driver.get("https://google.com");
//maximze the window
driver.manage().window().maximize();
//take full screenshot using MultiScreenShot class
mShot.multiScreenShot(driver);
//take element screenshot using MultiScreenShot class
mShot.elementScreenShot(driver, driver.findElement(By.id("gbqfq")));
//navigate to yahoo
driver.navigate().to("https://yahoo.in");
//take element screenshot using MultiScreenShot class
mShot.elementScreenShot(driver, driver.findElement(By.id("search-submit")));
//take full screenshot using MultiScreenShot class
mShot.multiScreenShot(driver);
//minimize the window using MultiScreenShot class
mShot.minimize();
driver.quit();
}
}
