Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serenity.takeScreenshot + GEB not working #941

Closed
tde-desc opened this issue Sep 25, 2017 · 6 comments
Closed

Serenity.takeScreenshot + GEB not working #941

tde-desc opened this issue Sep 25, 2017 · 6 comments

Comments

@tde-desc
Copy link

tde-desc commented Sep 25, 2017

As it seems like Serenity is not being supported in conjunction with GEB natively. I can get it to work easiliy though and its integrating quite well, having the following setup:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>parent</artifactId>
        <groupId>service</groupId>
        <version>135-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>acceptancetests</artifactId>

    <properties>
        <gebVersion>1.1.1</gebVersion>
        <seleniumVersion>2.53.0</seleniumVersion>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <project.reporting.outputDirectory>${basedir}/target/site/serenity</project.reporting.outputDirectory>
        <serenityVersion>1.5.10</serenityVersion>
    </properties>

    <profiles>
        <profile>
            <id>grid</id>
            <properties>
                <geb.env>grid</geb.env>
            </properties>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                    <systemPropertyVariables>
                        <geb.env>${geb.env}</geb.env>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.serenity-bdd.maven.plugins</groupId>
                <artifactId>serenity-maven-plugin</artifactId>
                <version>1.5.9</version>
                <dependencies>
                    <dependency>
                        <groupId>net.serenity-bdd</groupId>
                        <artifactId>serenity-core</artifactId>
                        <version>${serenityVersion}</version>
                    </dependency>
                    <dependency>
                        <groupId>net.serenity-bdd</groupId>
                        <artifactId>serenity-jira-requirements-provider</artifactId>
                        <version>1.2.0</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>serenity-reports</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.9</version>
            </plugin>
        </plugins>
    </reporting>

    <dependencies>

        <!-- Cucumber -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-groovy</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>

        <!-- Spock & Groovy -->
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>${spock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-spring</artifactId>
            <version>${spock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.athaydes</groupId>
            <artifactId>spock-reports</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.6</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>3.2.4</version>
            <scope>test</scope>
        </dependency>

        <!-- Selenium -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>${seleniumVersion}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>${seleniumVersion}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-api</artifactId>
            <version>${seleniumVersion}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-support</artifactId>
            <version>${seleniumVersion}</version>
        </dependency>

        <!-- GEB -->
        <dependency>
            <groupId>org.gebish</groupId>
            <artifactId>geb-spock</artifactId>
            <version>${gebVersion}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.jdev.geb</groupId>
            <artifactId>geb-cucumber</artifactId>
            <version>0.3</version>
        </dependency>

        <!-- Serenity -->
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>${serenityVersion}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-spring</artifactId>
            <version>${serenityVersion}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-junit</artifactId>
            <version>${serenityVersion}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-cucumber</artifactId>
            <version>1.5.4</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>

Unfortunately Serentiy is not generating screenshots, neither by default nor when I'm calling Serenity#takeScreenshot. It seems like WebDriverFacade.proxiedWebDriver is never being instantiated as it's always null, just like in this issue, which leads to BaseStepListener#shouldTakeScreenshots always returning false. I'm somehow afraid GEB is creating its own driver which Serenity is not being aware of...

Any idea?

@wakaleo
Copy link
Member

wakaleo commented Sep 25, 2017

GEB is not officially integrated with Serenity (as in, there are no integration tests or specific code around it), so I couldn't really say.

@wakaleo
Copy link
Member

wakaleo commented Sep 25, 2017

But using Selenium 2.5.3 with Serenity 1.5.x (which is built against Selenium 3) might not help things...

@tde-desc
Copy link
Author

tde-desc commented Sep 26, 2017

Thank you so far for your fast reply. I could get it to work in the end. I just had to

  1. tell GEB to use the WebDriver provided by Serenity and
  2. call the creation of the proxiedWebDriver manually.

I combined those needs in the GebConfig.groovy as follows:

driver = { ThucydidesWebDriverSupport.getProxiedDriver() }

Now my GEB-Tests and Serenity-reports (including screenshots) are working properly, as far as i can say.

@alexfch
Copy link

alexfch commented Apr 7, 2019

Hi @tde-desc ,
I'm trying make my Serenity+Cucumber project use Geb for UI tests. There is no much information on this in the internet. Found this issue you reported. And it sounds you used exactly the same bundle (Serenity+Cucumber+Geb).
Could you give me a hint what libraries need to be used and what/where to initialized/declared to have this working?

@tde-desc
Copy link
Author

tde-desc commented Apr 8, 2019

Hi @alexfch ,

exactly, i was using the setup you are looking for successfully in multiple projects in a productive environment. Unfortunately I'm not having access on those projects anymore so I can just try to reproduce what i did so far to accomplish that setup:

  1. Regarding the libraries u need I recommend having a look at Serenity.takeScreenshot + GEB not working #941 (comment) . In a nutshell: gmavenplus, spock, cucumber, selenium, geb & serenity. The mentioned dependencies including its versions are probably outdated by now, but until february'19 i was able to keep those libraries working together even with up-to-date versions.
  2. Like @wakaleo was indicating, to integrate those libraries I had to do some research and experimenting. I remember this resource so far:
    2.1 http://www.gebish.org/manual/current/#cucumber-jvm
    2.2 https://serenity-bdd.github.io/theserenitybook/latest/cucumber.html
  3. I needed to tell Geb to use the Serenity-Webdriver: Serenity.takeScreenshot + GEB not working #941 (comment)

I hope this is going to help you. Feel free to ask if any further information is required.

@alexfch
Copy link

alexfch commented Apr 17, 2019

Hi @tde-desc ,

Thank you very much for your help! I was able to set the project up and it's successfully running!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants