way2vin
0
Q:

how to take a screenshot

Press the Windows key + Shift + S. The screen will dim and the mouse pointer will change. You can drag to select a portion of the screen to capture. The screenshot will be copied to the clipboard, which you can paste into another program. (This shortcut only works if you have the latest version of Windows 10 installed, called the Windows 10 Creators Update.)
0
I have a tearDown method in my Hooks Class. I keep my screenshot codes in it. 
It takes screenshot as soon as any scenario fails.

	@After
	public void tearDown(Scenario scenario) { 
        if(scenario.isFailed()) {
    	TakesScreenshot screen=(TakesScreenshot)Driver.getDriver();
        final byte[] screenshot = screen.getScreenshotAs(OutputType.BYTES); ==>
        taking screenshot
        scenario.embed(screenshot, "image/png");  ==> adding screenshot to
        the report 
    	}
	}
    
    
    HOW TO TAKE SCREENSHOT IN ANY TEST CASE WITHOUT FAILURE

        TakesScreenshot screen=(TakesScreenshot)Driver.getDriver();
        File screenshot=screen.getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(screenshot, new File("<your folder path here>"));

0

---------- Screenshot on WINDOW ----------------

>> Windows + Shift + S

---------- Screenshot on MAC ----------------

>> Shift + Command + 4 
 
0

New to Communities?

Join the community