How to take Screenshots in BDD cucumber framework in selenium

0 votes

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);
    }

Apr 26, 2018 in Selenium by king_kenny
• 3,590 points
1,612 views

1 answer to this question.

0 votes

Check this out QAF.

This can be done by adding log message with screenshot, for example:

Reporter.logWithScreenShot("before change")
//execute what you want
Reporter.logWithScreenShot("after change")
answered Apr 26, 2018 by king_kenny
• 3,590 points

Related Questions In Selenium

0 votes
1 answer

How can we take screenshots of tests in Selenium 2 using C#

We can take screenshots using below function ...READ MORE

answered Mar 23, 2018 in Selenium by nsv999
• 5,050 points
131 views
0 votes
1 answer

How to take screenshot in Selenium WebDriver

In Java, it can be done like ...READ MORE

answered Apr 7, 2018 in Selenium by nsv999
• 5,050 points
394 views
0 votes
0 answers

How to hover element when action class is not working in my Selenium framework ?

When i am writing the code to ...READ MORE

Feb 15 in Selenium by Raishul
126 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
259 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
628 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
256 views
0 votes
1 answer

How to select an Object by its class in Selenium?

When it comes to Selenium, XPath will ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,590 points
30 views
+9 votes
13 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,280 points
47,653 views