[rspec-users] RSpec Selenium Webdriver Html Report with Screenshots

90 views
Skip to first unread message

David Tishkoff

unread,
Sep 2, 2012, 2:20:47 AM9/2/12
to rspec...@rubyforge.org
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...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Javix

unread,
Sep 3, 2012, 7:58:46 AM9/3/12
to rs...@googlegroups.com, rspec...@rubyforge.org, li...@ruby-forum.com
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

Javix

unread,
Sep 3, 2012, 8:00:08 AM9/3/12
to rs...@googlegroups.com, rspec...@rubyforge.org, li...@ruby-forum.com
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:

David Tishkoff

unread,
Sep 3, 2012, 1:59:21 PM9/3/12
to rspec...@rubyforge.org
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.
Reply all
Reply to author
Forward
0 new messages