Forum: RSpec RSpec Selenium Webdriver Html Report with Screenshots

3f8de000d6adb5d2ed90116150b6944b?d=identicon&s=25 David Tishkoff (dtishkoff)
on 2012-09-02 08:20
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!
F7141e066d691d7f18765c1ea6389b18?d=identicon&s=25 Serguei Cambour (javix)
on 2012-09-03 13:59
(Received via mailing list)
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-rep... for
reporting.

As for screen shots, see takeScreenShot class in Selenium API:
http://selenium.googlecode.com/svn/trunk/docs/api/...
F7141e066d691d7f18765c1ea6389b18?d=identicon&s=25 Serguei Cambour (javix)
on 2012-09-03 14:00
(Received via mailing list)
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;

}
3f8de000d6adb5d2ed90116150b6944b?d=identicon&s=25 David Tishkoff (dtishkoff)
on 2012-09-03 19:59
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.
This topic is locked and can not be replied to.