RSpec Selenium Webdriver Html Report with Screenshots

Hello,

I’m using Rake + RSpec + Selenium-WebDriver for the web testing, Is
there a way to create html report with the screenshot generated on
failure? Would really appreciate your help!

You can generate HTML reports with surefire, just addd the folowing to
your
POM file:

org.apache.maven.plugins maven-site-plugin 3.1 org.apache.maven.plugins

maven-surefire-report-plugin
2.4.3



See more details on its use at
http://maven.apache.org/plugins/maven-surefire-plugin/
adn http://maven.apache.org/plugins/maven-surefire-report-plugin/ for
reporting.

As for screen shots, see takeScreenShot class in Selenium API:
http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html?overview-summary.html

Just a piecec pf code to create a screen shot:

private void takeScreenShot(RuntimeException e, String fileName) {

File screenShot = ((TakesScreenshot)

driver).getScreenshotAs(OutputType.FILE);

try {

    FileUtils.copyFile(screenShot, new File(fileName + ".png"));

} catch (IOException ioe) {

    throw new RuntimeException(ioe.getMessage(), ioe);

}

throw e;

}

Serguei C. wrote in post #1074435:

Just a piecec pf code to create a screen shot:

private void takeScreenShot(RuntimeException e, String fileName) {

File screenShot = ((TakesScreenshot)

driver).getScreenshotAs(OutputType.FILE);

try {

    FileUtils.copyFile(screenShot, new File(fileName + ".png"));

} catch (IOException ioe) {

    throw new RuntimeException(ioe.getMessage(), ioe);

}

throw e;

}

Thank you for the help, sorry I forgot to mention that I’m using ruby
and I need screenshots to be included into RSpec html reports.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service