-2

Currently, I am using below code to take screenshot of particular action(calling in method where screenshot is important) performed. But I need to take screenshot of every page as we use to do while functional testing (before- as page loads and after- values are entered on that page) and it should name screenshot as @before- PageName and @after-PageName If anybody know how to take screenshot of whole Page, please let me know.

public void getscreenshot(WebDriver driver) throws Exception {

        File scr = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);

        File dest = new File(("user.dir")+"screenshot" + timestamp() + ".png");
        FileUtils.copyFile(scr, dest);
        Thread.sleep(3000);
    }
swati
  • 11
  • 1
  • 8
  • Possible duplicate of [Take a screenshot with Selenium WebDriver](http://stackoverflow.com/questions/3422262/take-a-screenshot-with-selenium-webdriver) – JDelorean Nov 15 '16 at 07:53
  • I have added below code: File scrFile =((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(scrFile, new File("C:\\Automation\\target\\zucchini-reports\\testScreenSh‌​ot.jpg")); if (testResult.getStatus() == ITestResult.FAILURE) { scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(scrFile, new File("C:\\Automation\\target\\zucchini-reports\\testScreenSh‌​ot.jpg")); getting error message takeScreenShotOnFailure(com.Runner.AbstractStepDefinitionTes‌​t) Time elapsed: 74.844 sec <<< FAILURE! – – swati Dec 02 '16 at 04:49

2 Answers2

0

Check with QAF. You can achieve it by adding log message with screenshot, for example:

Reporter.logWithScreenShot("before change")
//perform your stuff
Reporter.logWithScreenShot("after change")

You can take a quick tour by following Step-By-Step-Tutorial

user861594
  • 5,733
  • 3
  • 29
  • 45
0

You could use https://saucelabs.com/ for this (its a paid service, I'm not affiliated with them, nor am I recommending them). They offer videos of your scenarios as well as screenshots.

diabolist
  • 3,990
  • 1
  • 11
  • 15