David Tishkoff
2012-Sep-02 06:20 UTC
[rspec-users] 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! -- Posted via http://www.ruby-forum.com/.
Javix
2012-Sep-03 11:58 UTC
[rspec-users] RSpec Selenium Webdriver Html Report with Screenshots
You can generate HTML reports with surefire, just addd the folowing to your
POM file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.1</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.4.3</version>
</plugin>
</reportPlugins>
</configuration>
</plugin>
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
On Sunday, September 2, 2012 8:22:15 AM UTC+2, David Tishkoff
wrote:>
> 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!
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec... at rubyforge.org <javascript:>
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20120903/f72e69f9/attachment.html>
Javix
2012-Sep-03 12:00 UTC
[rspec-users] RSpec Selenium Webdriver Html Report with Screenshots
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;
}
On Sunday, September 2, 2012 8:22:15 AM UTC+2, David Tishkoff
wrote:>
> 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!
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec... at rubyforge.org <javascript:>
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20120903/394a9506/attachment-0001.html>
David Tishkoff
2012-Sep-03 17:59 UTC
[rspec-users] RSpec Selenium Webdriver Html Report with Screenshots
Serguei Cambour 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. -- Posted via http://www.ruby-forum.com/.