7 Replies Latest reply on Nov 10, 2014 6:22 AM by Karel Piwko

    null pointer exception when calling Drone driver

    John Fistikis Newbie

      i'm trying to make this example work and open a URL by injecting Drone in my test class, however i keep getting a null pointer when calling the driver (  browser.get("http://google.com");    ). I'm not using deployment annotations or containers. The example is very straight forward, i just want to use arquillian from cucumber to open a browser page and redirect it to a URL of my choice.

       

      Cukes in Space in Standalone mode

       

      any ideas ?

        • 1. Re: null pointer exception when calling Drone driver
          John Fistikis Newbie

          ok i've tried running it with maven and it runs ok, but when running the cucumber feature file it gives me the null pointer exception.

          • 2. Re: null pointer exception when calling Drone driver
            Karel Piwko Master

            Hi John, I'm not very familiar with Cucumber. How do you run cucumber feature file? Can you pass -Darquillian.debug there and post the output here?

             

            I suspect that Arquillian is not being initialized at all when running cucumber directly, as it's lifecycle is managed via JUnit runner (for JUnit based integrations).

             

            Karel

            • 3. Re: null pointer exception when calling Drone driver
              Daniel Maldonado Newbie

              I am running into the same issue.  Here are the specifics:

               

              Running com.my-company.arquillian.graphene.LoginScreenGrapheneTest

              Nov 06, 2014 12:06:31 PM org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ReusedSessionPermanentFileStorage readStore

              INFO: Reused session store is not available at /Users/daniel/.drone-webdriver-session-store, a new one will be created.

              Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.083 sec <<< FAILURE! - in com.my-company.arquillian.graphene.LoginScreenGrapheneTest

              com.my-company.arquillian.graphene.LoginScreenGrapheneTest  Time elapsed: 2.082 sec  <<< ERROR!

              java.lang.NullPointerException: null

                  at org.jboss.arquillian.drone.configuration.ConfigurationMapper.keyTransformReverse(ConfigurationMapper.java:278)

                  at org.jboss.arquillian.drone.configuration.ConfigurationMapper.mapFromNameValuePairs(ConfigurationMapper.java:156)

                  at org.jboss.arquillian.drone.configuration.ConfigurationMapper.fromArquillianDescriptor(ConfigurationMapper.java:96)

                  at org.jboss.arquillian.drone.webdriver.configuration.WebDriverConfiguration.configure(WebDriverConfiguration.java:179)

                  at org.jboss.arquillian.drone.webdriver.factory.AbstractWebDriverFactory.createConfiguration(AbstractWebDriverFactory.java:33)

                  at org.jboss.arquillian.drone.webdriver.factory.WebDriverFactory.createConfiguration(WebDriverFactory.java:41)

                  at org.jboss.arquillian.drone.webdriver.factory.AbstractWebDriverFactory.createConfiguration(AbstractWebDriverFactory.java:17)

                  at org.jboss.arquillian.drone.impl.DroneConfigurator.configureDrone(DroneConfigurator.java:172)

                  at org.jboss.arquillian.drone.impl.DroneConfigurator.prepareDroneConfiguration(DroneConfigurator.java:122)

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at java.lang.reflect.Method.invoke(Method.java:606)

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                  at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

                  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

                  at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:84)

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at java.lang.reflect.Method.invoke(Method.java:606)

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                  at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:65)

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at java.lang.reflect.Method.invoke(Method.java:606)

                  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)

                  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)

                  at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)

                  at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:190)

                  at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:345)

                  at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:49)

                  at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:207)

                  at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

                  at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:155)

                  at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)

                  at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)

                  at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)

                  at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)

                  at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)

                  at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

               

               

              Results :

               

              Tests in error:

                LoginScreenGrapheneTest.com.my-company.arquillian.graphene.LoginScreenGrapheneTest » NullPointer

               

              Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

               

              ------------------------------------------------------------------------

              BUILD FAILURE

              ------------------------------------------------------------------------

              Total time: 4.250s

              Finished at: Thu Nov 06 12:06:32 EST 2014

              Final Memory: 10M/158M

              ------------------------------------------------------------------------

               

              <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>com.my-company</groupId>

                  <artifactId>Arquillian-Graphene</artifactId>

                  <version>1.0-SNAPSHOT</version>

                  <packaging>war</packaging>

               

                  <name>Arquillian-Graphene</name>

               

                 <properties>

                    <browser>firefox</browser>

                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

                    <arquillian.version>1.1.5.Final</arquillian.version> 

                    <arquillian_drone.version>1.3.1.Final</arquillian_drone.version> 

                    <arquillian_warp.version>1.0.0.Alpha4</arquillian_warp.version>

                    <arquillian_selenium.version>2.43.1</arquillian_selenium.version>     

                 </properties>

               

                 <dependencyManagement>

                     <dependencies>

                         <dependency>

                             <groupId>org.jboss.arquillian</groupId>

                             <artifactId>arquillian-bom</artifactId>

                             <version>${arquillian.version}</version>

                             <scope>import</scope>

                             <type>pom</type>

                         </dependency>

                      <dependency>

                          <groupId>org.jboss.arquillian.extension</groupId>

                          <artifactId>arquillian-drone-bom</artifactId>

                          <version>${arquillian_drone.version}</version>

                          <type>pom</type>

                          <scope>import</scope>

                      </dependency>

                      <dependency>

                          <groupId>org.jboss.arquillian.selenium</groupId>

                          <artifactId>selenium-bom</artifactId>

                          <version>${arquillian_selenium.version}</version>

                          <type>pom</type>

                          <scope>import</scope>

                      </dependency>          

                     </dependencies>

                 </dependencyManagement>

                

              <dependencies>

                  <dependency>

                      <groupId>junit</groupId>

                      <artifactId>junit</artifactId>

                      <version>4.8.1</version>

                      <scope>test</scope>

                  </dependency>

                  <dependency>

                      <groupId>org.jboss.arquillian.junit</groupId>

                      <artifactId>arquillian-junit-container</artifactId>

                      <scope>test</scope>

                  </dependency>

                 <dependency>

                     <groupId>org.jboss.arquillian.graphene</groupId>

                     <artifactId>graphene-webdriver</artifactId>

                     <version>2.1.0.Alpha1</version>

                     <type>pom</type>

                     <scope>test</scope>

                 </dependency>   

              </dependencies>

               

                <build>

                       <testResources>

                           <testResource>

                               <directory>src/test/resources</directory>

                           </testResource>

                           <testResource>

                               <directory>src/test/resources-glassfish-remote</directory>

                           </testResource>

                       </testResources>    

                  <plugins>

                    <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-compiler-plugin</artifactId>

                      <version>2.3.2</version>

                      <configuration>

                        <source>1.6</source>

                        <target>1.6</target>

                      </configuration>

                    </plugin>

                    <plugin>

                        <artifactId>maven-surefire-plugin</artifactId>

                        <version>2.17</version>

                    </plugin>     

                  </plugins>

                </build>

               

                 <profiles>

                     <profile>

                        <id>firefox</id>

                        <properties>

                           <browser>firefox</browser>

                        </properties>

                     </profile>

                     <profile>

                        <id>chrome</id>

                        <properties>

                            <browser>chrome</browser>

                        </properties>

                     </profile>  

                    <profile>

                       <id>arquillian-glassfish-embedded</id>

                       <activation>

                           <activeByDefault>true</activeByDefault>

                       </activation>      

                       <dependencies>

                               <dependency>

                                   <groupId>org.jboss.arquillian.container</groupId>

                                   <artifactId>arquillian-glassfish-embedded-3.1</artifactId>

                                   <version>1.0.0.CR3</version>

                                   <scope>test</scope>

                               </dependency>

                               <dependency>

                                   <groupId>org.glassfish.main.extras</groupId>

                                   <artifactId>glassfish-embedded-all</artifactId>

                                   <version>3.1.2</version>

                                   <scope>provided</scope>

                               </dependency>

                       </dependencies>

                    </profile>  

                    <profile>

                       <id>arquillian-glassfish-remote</id>     

                       <dependencies>

                            <dependency>

                                <groupId>org.jboss.spec</groupId>

                                <artifactId>jboss-javaee-6.0</artifactId>

                                <version>1.0.0.Final</version>

                                <type>pom</type>

                                <scope>provided</scope>

                            </dependency>

                            <dependency>

                                <groupId>org.jboss.weld</groupId>

                                <artifactId>weld-api</artifactId>

                                <version>1.1.Final</version>

                                <scope>test</scope>

                            </dependency>

                            <dependency>

                                <groupId>org.jboss.arquillian.container</groupId>

                                <artifactId>arquillian-glassfish-remote-3.1</artifactId>

                                <version>1.0.0.CR3</version>

                                <scope>test</scope>

                            </dependency>

                       </dependencies>

                    </profile>  

                     <profile>

                         <id>arquillian-weld-ee-embedded</id>

                         <dependencies>

                             <dependency>

                                 <groupId>org.jboss.spec</groupId>

                                 <artifactId>jboss-javaee-6.0</artifactId>

                                 <version>1.0.0.Final</version>

                                 <type>pom</type>

                                 <scope>provided</scope>

                             </dependency>

                             <dependency>

                                 <groupId>org.jboss.arquillian.container</groupId>

                                 <artifactId>arquillian-weld-ee-embedded-1.1</artifactId>

                                 <version>1.0.0.CR3</version>

                                 <scope>test</scope>

                             </dependency>

                             <dependency>

                                 <groupId>org.jboss.weld</groupId>

                                 <artifactId>weld-core</artifactId>

                                 <version>1.1.5.Final</version>

                                 <scope>test</scope>

                             </dependency>

                             <dependency>

                                 <groupId>org.slf4j</groupId>

                                 <artifactId>slf4j-simple</artifactId>

                                 <version>1.6.4</version>

                                 <scope>test</scope>

                             </dependency>

                         </dependencies>

                     </profile>

                 </profiles>

              </project>

               

               

              //-------------------------------------------- arquillian.xml ------------------------------

              <?xml version="1.0"?>

              <arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                  xmlns="http://jboss.org/schema/arquillian"

                  xsi:schemaLocation="http://jboss.org/schema/arquillian

                  http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

                

                 <extension qualifier="webdriver">

                    <!--property name="browser">${browser}</property-->

                    <property>firefox</property>

                 </extension>    

                

                 <engine>

                    <property name="deploymentExportPath">target/arquillian</property>

                 </engine>

                 

                 <container qualifier="arquillian-glassfish-remote" default="true" >

                    <configuration>

                       <property name="adminUser">admin</property>

                       <property name="adminPassword">123456789</property>

                       <property name="target">server</property>

                       <!--property name="sunResourcesXml">src/main/setup/glassfish-resources.xml</property-->

                    </configuration>

                 </container>

                 

              </arquillian>

               

               

              //-------------------------------------------- LoginScreenGrapheneTest.java ------------------------------

              package com.my-company.arquillian.graphene;

               

              import java.io.File;

              import java.net.URL;

              import org.jboss.arquillian.container.test.api.Deployment;

              import org.jboss.arquillian.drone.api.annotation.Drone;

              import static org.jboss.arquillian.graphene.Graphene.guardHttp;

              import static org.jboss.arquillian.graphene.Graphene.waitAjax;

              import org.jboss.arquillian.graphene.findby.FindByJQuery;

              import org.jboss.arquillian.junit.Arquillian;

              import org.jboss.shrinkwrap.api.ShrinkWrap;

              import org.jboss.shrinkwrap.api.asset.EmptyAsset;

              import org.jboss.shrinkwrap.api.asset.StringAsset;

              import org.jboss.shrinkwrap.api.spec.WebArchive;

              import org.junit.runner.RunWith;

              import org.jboss.arquillian.test.api.ArquillianResource;

              import static org.junit.Assert.assertEquals;

              import static org.junit.Assert.assertTrue;

              import org.junit.Test;

              import org.openqa.selenium.WebDriver;

              import org.openqa.selenium.WebElement;

              import org.openqa.selenium.support.FindBy;

               

               

              @RunWith(Arquillian.class)

              public class LoginScreenGrapheneTest {

                 private static final String WEBAPP_SRC = "src/main/webapp";

                 

                 @Deployment(testable = false)

                 public static WebArchive createDeployment() {

                    return ShrinkWrap.create(WebArchive.class, "login.war")

                       .addClasses(Credentials.class, User.class, LoginController.class)

                       .addAsWebResource(new File(WEBAPP_SRC, "login.xhtml"))

                       .addAsWebResource(new File(WEBAPP_SRC, "home.xhtml"))

                       .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")

                       .addAsWebInfResource(new StringAsset("<faces-config version=\"2.0\"/>"), "faces-config.xml");

                 }

                

                 @Drone

                 private WebDriver browser; 

                

                 @ArquillianResource

                 private URL deploymentUrl;  

                 

                 @FindBy                                     // 1. injects an element by default location strategy ("idOrName")

                 private WebElement userName;

               

                 @FindBy

                 private WebElement password;

               

                 @FindBy(id = "login")

                 private WebElement loginButton;

               

                 @FindBy(tagName = "li")                     // 2. injects a first element with given tag name

                 private WebElement facesMessage;

                

                 @FindByJQuery("p:visible")                  // 3. injects an element using jQuery selector

                 private WebElement signedAs;

               

                 @FindBy(css = "input[type=submit]")

                 private WebElement whoAmI;

               

                 @Test

                 public void should_login_successfully() {

                     browser.get(deploymentUrl.toExternalForm() + "login.jsf");      // 1. open the tested page

               

                     userName.sendKeys("demo");                                      // 3. control the page

                     password.sendKeys("demo");

               

                     guardHttp(loginButton).click();

               

                     assertEquals("Welcome", facesMessage.getText().trim());

                    

                     whoAmI.click();

                     waitAjax().until().element(signedAs).is().present();

                     assertTrue(signedAs.getText().contains("demo"));

                    

                 }   

               

              }

              • 4. Re: null pointer exception when calling Drone driver
                Karel Piwko Master

                Thank you Daniel for detailed output! I've fixed that problem in both 1.3 and 2.0 branches.

                 

                [ARQ-1882] NPE in ConfigurationMapper - JBoss Issue Tracker

                 

                If you could verify that it fixed all problems with Cucumber, I'd be happy to release 1.3.2.Final early next week and 2.0.0.Alpha3 later on.

                 

                Thanks,

                 

                Karel

                • 5. Re: null pointer exception when calling Drone driver
                  Karel Piwko Master

                  Ahh, that's a different thing. Daniel, your problem is caused by <property>firefox</property> <-- notice missing name="browser" there.

                   

                  Karel

                  • 6. Re: null pointer exception when calling Drone driver
                    Daniel Maldonado Newbie

                    Hi Karel,

                       thank you so much for the tip.  I feel so dumb asking these questions sometimes but I can't believe I missed that.

                    That was my issue, just wish I caught it before I wasted your time.  You won't believe how many hours I spent on that.

                     

                    Anyway, thank you again.  You are a life saver :-)

                    • 7. Re: null pointer exception when calling Drone driver
                      Karel Piwko Master

                      No worries Daniel, I'm glad it fixed your issue now and you've helped to made Drone a little bit more robust for the future, which is something I'm very happy about.

                       

                      Cheers,

                       

                      Karel