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,690 points
2,853 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,690 points

Related Questions In Selenium

0 votes
2 answers

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

Hey, try using following code command to ...READ MORE

answered Aug 22, 2019 in Selenium by Abha
• 27,740 points
217 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,510 points
759 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, 2019 in Selenium by Raishul
786 views
0 votes
1 answer

How can I add Cucumber Jar files in Eclipse to use with Selenium Webdriver?

Hey Eshan, follow these steps to add ...READ MORE

answered May 22, 2019 in Selenium by Abha
• 27,740 points
569 views
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,510 points
1,543 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,850 points
1,487 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,850 points
1,265 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,690 points
83 views
+9 votes
15 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,370 points
84,587 views