Tuesday, 8 August 2017

Code Example - Take Screen Shot

package com.practiceCode;

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

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.testng.annotations.Test;

/**
 * @Blog Name : Selenium Code Example
 * @author Deepak Gupta
 * @Created Date 8-08-2017
 *
 */
public class TakeScreenShot extends SuperTestNG {

@Test
public void test() throws InterruptedException, IOException {
driver.get("http://only-testing-blog.blogspot.in/2013/09/testing.html");
// Capture entire page screenshot and then store it to destination drive
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new File(System.getProperty("user.dir") +      "/ScreenShot/TakeScreenshot.jpg"));
System.out.print("Screenshot is captured and stored in your D: Drive");
}

}

No comments:

Post a Comment

Code Example - File Download By Robot Class In Firefox Browser

Exported from Notepad++ package com . practiceCode ; import java . awt . AWTException ; import java . awt . Robot ; import j...