serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
718 stars 515 forks source link

serenity-core 1.1.38 (and newer) + BrowserStack : receiving FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE error #560

Closed mngi-arogers closed 6 years ago

mngi-arogers commented 7 years ago

Hello,

Our serenity-core version 1.1.36 and BrowserStack integration has been working for several months now. However when I run a sample test after setting serenity-core version to 1.1.38, 1.1.40, or 1.1.42 in my pom.xml, I receive a FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE error.

I've looked at Serenity's BrowserStack documentation again (http://serenity-bdd.info/docs/serenity/#_running_tests_on_browserstack ), but I didn't see anything that points to the problem.

Any ideas? Thanks for the help ( and for building such a useful framework )!

-------------------------------------------------------------------------------------
     _______. _______ .______       _______ .__   __.  __  .___________.____    ____ 
    /       ||   ____||   _  \     |   ____||  \ |  | |  | |           |\   \  /   / 
   |   (----`|  |__   |  |_)  |    |  |__   |   \|  | |  | `---|  |----` \   \/   /  
    \   \    |   __|  |      /     |   __|  |  . `  | |  |     |  |       \_    _/   
.----)   |   |  |____ |  |\  \----.|  |____ |  |\   | |  |     |  |         |  |     
|_______/    |_______|| _| `._____||_______||__| \__| |__|     |__|         |__|    
-------------------------------------------------------------------------------------

[main] INFO net.serenitybdd.core.Serenity - Test Suite Started: Serenity issue test
[main] WARN net.thucydides.core.requirements.PackageRequirementsTagProvider - To generate correct requirements coverage reports you need to set the 'serenity.test.root' property to the package representing the top of your requirements hierarchy.
[main] INFO net.serenitybdd.core.Serenity - 
 _____ _____ ____ _____   ____ _____  _    ____ _____ _____ ____  
|_   _| ____/ ___|_   _| / ___|_   _|/ \  |  _ \_   _| ____|  _ \ 
  | | |  _| \___ \ | |   \___ \ | | / _ \ | |_) || | |  _| | | | |
  | | | |___ ___) || |    ___) || |/ ___ \|  _ < | | | |___| |_| |
  |_| |_____|____/ |_|   |____/ |_/_/   \_\_| \_\|_| |_____|____/ 

TEST STARTED: thisShouldRun
-------------------------------------------------------------------
[main] INFO net.serenitybdd.core.Serenity - TEST NUMBER: 1
[main] ERROR net.thucydides.core.webdriver.WebDriverFacade - FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE class org.openqa.selenium.firefox.FirefoxDriver: Could not instantiate class org.openqa.selenium.firefox.FirefoxDriver
net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate class org.openqa.selenium.firefox.FirefoxDriver
    at net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:128)
    at net.thucydides.core.webdriver.WebDriverFacade.newDriverInstance(WebDriverFacade.java:142)
    at net.thucydides.core.webdriver.WebDriverFacade.newProxyDriver(WebDriverFacade.java:133)
    at net.thucydides.core.webdriver.WebDriverFacade.getProxiedDriver(WebDriverFacade.java:103)
    at net.thucydides.core.webdriver.WebDriverFacade.openIgnoringHtmlUnitScriptErrors(WebDriverFacade.java:178)
    at net.thucydides.core.webdriver.WebDriverFacade.get(WebDriverFacade.java:173)
    at dfm.cms.test.SerenityIssueTest.thisShouldRun(SerenityIssueTest.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at net.serenitybdd.junit.runners.SerenityStatement.evaluate(SerenityStatement.java:24)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:427)
    at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:52)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at net.serenitybdd.junit.runners.SerenityRunner.run(SerenityRunner.java:241)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.NullPointerException
    at net.thucydides.core.webdriver.strategies.DriverCapabilities.realBrowserCapabilities(DriverCapabilities.java:97)
    at net.thucydides.core.webdriver.strategies.DriverCapabilities.forDriver(DriverCapabilities.java:41)
    at net.thucydides.core.webdriver.strategies.RemoteDriverBuilder.findbrowserStackCapabilities(RemoteDriverBuilder.java:113)
    at net.thucydides.core.webdriver.strategies.RemoteDriverBuilder.buildBrowserStackDriver(RemoteDriverBuilder.java:92)
    at net.thucydides.core.webdriver.strategies.RemoteDriverBuilder.newInstance(RemoteDriverBuilder.java:62)
    at net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:116)
    ... 32 more
[main] WARN net.thucydides.core.requirements.PackageRequirementsTagProvider - To generate correct requirements coverage reports you need to set the 'serenity.test.root' property to the package representing the top of your requirements hierarchy.
[main] ERROR net.serenitybdd.core.Serenity - 
           __  _____ _____ ____ _____   _____ _    ___ _     _____ ____  
  _       / / |_   _| ____/ ___|_   _| |  ___/ \  |_ _| |   | ____|  _ \ 
 (_)_____| |    | | |  _| \___ \ | |   | |_ / _ \  | || |   |  _| | | | |
  _|_____| |    | | | |___ ___) || |   |  _/ ___ \ | || |___| |___| |_| |
 (_)     | |    |_| |_____|____/ |_|   |_|/_/   \_\___|_____|_____|____/ 
          \_\                                                            

TEST FAILED WITH ERROR: This should run
---------------------------------------------------------------------
[main] ERROR net.serenitybdd.core.Serenity - Could not instantiate class org.openqa.selenium.firefox.FirefoxDriver
package dfm.cms.test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;

import net.serenitybdd.junit.runners.SerenityRunner;
import net.thucydides.core.annotations.Managed;

@RunWith( SerenityRunner.class )
public class SerenityIssueTest {

  @Managed
  WebDriver webDriver;

  @Test
  public void thisShouldRun() {
    webDriver.get( "http://serenity-bdd.info" );
  }
}
serenity.take.screenshots=FOR_FAILURES
webdriver.wait.for.timeout=20000
serenity.browser.width=1280
serenity.browser.height=1024

### Begin BrowserStack WebDriver properties ###
browserstack.url=https://MY_USERNAME:MY_API_KEY@hub.browserstack.com/wd/hub
browserstack.project=Selenium Tests
browserstack.name=My Eclipse Test

browserstack.resolution=1280x1024
browserstack.os=OS X
browserstack.os_version=El Capitan
browserstack.browser=chrome
browserstack.browser_version=53
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>my-selenium-tests</groupId>
    <artifactId>my-selenium-tests</artifactId>
    <version>1.0</version>
    <name>my-selenium-tests</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <serenity.version>1.1.42</serenity.version>
        <serenity.jira.version>1.1.1</serenity.jira.version>
        <chromeDrivers.directory>${project.projectDirectory}/chrome-drivers</chromeDrivers.directory>
    </properties>

    <profiles>
        <profile>
            <id>Mac</id>
            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>
            <properties>
                <chromedriver.location>${chromeDrivers.directory}/chromedriver_mac32</chromedriver.location>
            </properties>
        </profile>
        <profile>
            <id>Linux</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <chromedriver.location>${chromeDrivers.directory}/chromedriver_linux64</chromedriver.location>
            </properties>
        </profile>
        <profile>
            <id>Windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <chromedriver.location>${chromeDrivers.directory}/chromedriver_win32.exe</chromedriver.location>
            </properties>
        </profile>
        <profile>
            <id>Jira</id>
            <dependencies>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-jira-requirements-provider</artifactId>
                    <version>${serenity.jira.version}</version>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20160810</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.53.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.21</version>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>${serenity.version}</version>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-report-resources</artifactId>
            <version>${serenity.version}</version>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-junit</artifactId>
            <version>${serenity.version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <!-- To have Serenity generate reports even when tests fail, need to run 
                tests integration tests instead of unit tests. -->

            <!-- disable maven unit testing -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>

            <!-- enable maven integration testing -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.19.1</version>
                <executions>
                    <execution>
                        <id>integration-tests</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <skipTests>false</skipTests>
                            <systemPropertyVariables>
                                <webdriver.chrome.driver>${chromedriver.location}</webdriver.chrome.driver>
                            </systemPropertyVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.serenity-bdd.maven.plugins</groupId>
                <artifactId>serenity-maven-plugin</artifactId>
                <version>${serenity.version}</version>

                <executions>
                    <execution>
                        <id>serenity-reports</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
wakaleo commented 7 years ago

I'm unable to reproduce this with my BrowserStack account, could you provide a sample project that reproduces the issue?

mngi-arogers commented 7 years ago

I've attached a sample project: my-selenium-tests-issue-560.zip

Make sure to enter your BrowserStack credentials into the 'browserstack.url' field of the 'serenity.properties' file.

The project can be built and run with this command: mvn -Dit.test=mypackage.SerenityIssueTest clean verify

Not sure if it matters, but I'm running this on Ubuntu 16.04. Thanks for looking at this.

derkoe commented 7 years ago

We see the same issue.

Interestingly adding "webdriver.driver=chrome" seems to resolve this (regardless which browser you use on Browserstack).

derkoe commented 7 years ago

Adding "webdriver.driver=provided" also works - this seems to be the right setting.

wakaleo commented 7 years ago

Have you tried webdriver.driver=remote?

derkoe commented 7 years ago

Yes - the same NPE as above but with: net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate class org.openqa.selenium.remote.RemoteWebDriver

The problem seems to be in DriverCapabilities#driverCapabilitiesSelector - there is not "REMOTE" in the selectors

mngi-arogers commented 7 years ago

@derkoe Thanks for the tip! Adding webdriver.driver=provided to my serenity.properties file is working for me.