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

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

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,030 points
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,030 points
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
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 5 hours ago in Selenium by Abha
• 5,840 points
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,030 points
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
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
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
+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

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.