Selenium screen shots

71 views
Skip to first unread message

Dimuth Lasantha

unread,
Nov 7, 2014, 2:02:07 AM11/7/14
to seleniu...@googlegroups.com
I am writing a code for generate screenshots for failures. i can do it. but i want to refactor the code. i create a method in common class and extended it. then i try to call that method from each @AfterMethod. but it gives a configuration failure for @AfterMethod.

here is my code 

in common calss
public class CommonClass{

public void takeScreenShotOnFailure(ITestResult testResult, String destination) throws IOException{

if (testResult.getStatus() == ITestResult.FAILURE) {

System.out.println(testResult.getStatus());

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

FileUtils.copyFile(scrFile, new File(destination));

}

}

}

i am extend above class

public class invoice extends Common Class{

@AfterMethod

public void takeScreenShotOnFailure2() throws IOException{

String y = "//Users/dimuth/Documents/Hiveage_bugs_screenshots(Selenium)//testScreenShot.jpg";

ITestResult test = null;

login l = new login();

l.takeScreenShotOnFailure(test, y);

}

}

Krishnan Mahadevan

unread,
Nov 11, 2014, 8:38:35 PM11/11/14
to Selenium Users

You would need to show the complete stacktrace of the error you encountered.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/63425d0b-8ae9-4f75-923a-b52f1e21b0d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Collin

unread,
Nov 16, 2014, 10:21:29 AM11/16/14
to seleniu...@googlegroups.com
Try creating a listener rather than adding something into your @AfterMethod, there is one you can copy from here:


Don’t forget to annotate your tests with

@Listeners(ScreenshotListener.class)

CH!NN@ K

unread,
Nov 17, 2014, 12:29:38 AM11/17/14
to seleniu...@googlegroups.com
hi Lasantha, Refer this below link, it is worked for me.You will get  idea about Screenshot using selenium Webdriver.
http://techlearn.in/content/fullpage-screenshot-firefox-and-chrome-using-selenium

---
Thanks & Regards,
Purushotham Karimbedu,
Web Developer and QA Engineer,
Personal Website : http://techlearn.in
Phone no :9000109120.

Reply all
Reply to author
Forward
0 new messages