无法设置Drone:NoClassDefFoundError:com / opera / core / systems / OperaDriver

时间:2014-02-20 14:31:08

标签: java selenium selenium-webdriver jboss-arquillian arquillian-drone

我正在关注本教程:http://arquillian.org/guides/functional_testing_using_graphene/

但我收到了这个错误:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.047 sec <<< FAILURE!
cn.ftc.test.BeanTest  Time elapsed: 1.045 sec  <<< ERROR!
java.lang.NoClassDefFoundError: com/opera/core/systems/OperaDriver
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2436)
at java.lang.Class.getDeclaredMethods(Class.java:1793)
at org.jboss.arquillian.core.impl.Reflections.getObserverMethods(Reflections.java:52)
at org.jboss.arquillian.core.impl.ExtensionImpl.of(ExtensionImpl.java:51)
at org.jboss.arquillian.core.impl.ManagerImpl.inject(ManagerImpl.java:198)
at org.jboss.arquillian.core.impl.InjectorImpl.inject(InjectorImpl.java:58)
at org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader.createServiceInstance(ServiceRegistryLoader.java:108)
at org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader.all(ServiceRegistryLoader.java:55)
at org.jboss.arquillian.drone.impl.DroneRegistrar.registerConfigurators(DroneRegistrar.java:74)
at org.jboss.arquillian.drone.impl.DroneRegistrar.register(DroneRegistrar.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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.createSuiteContext(TestContextHandler.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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:135)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeSuite(EventTestRunnerAdaptor.java:68)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:97)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.ClassNotFoundException: com.opera.core.systems.OperaDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 41 more
Caused by: java.lang.ClassNotFoundException: com.opera.core.systems.OperaDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 41 more


Results :

Tests in error: 
  cn.ftc.test.BeanTest: com/opera/core/systems/OperaDriver

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

这是我的arquillian.xml

<extension qualifier="webdriver">
    <property name="browser">firefox</property>
</extension>

<container qualifier="JBOSS_AS_MANAGED_7.X" default="true">
    <configuration>
        <!-- <property name="javaVmArguments">-Xmx1024m -XX:MaxPermSize=512m ${jacoco.agent}</property> -->
        <property name="allowConnectingToRunningServer">true</property>
        <property name="jbossHome">/home/neo/app/jboss-as-7.1.1.Final</property>
    </configuration>
</container>

这是我的dependency

<dependencyManagement>
    <dependencies>
        <!-- Arquillian Core dependencies -->
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>${version.org.jboss.arquillian}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <!-- Arquillian Drone dependencies and WebDriver/Selenium dependencies -->
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-drone-bom</artifactId>
            <version>${version.org.jboss.arquillian.drone}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.selenium</groupId>
            <artifactId>selenium-bom</artifactId>
            <version>2.35.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
</dependencyManagement>

<dependencies>

    <!-- webdriver -->
    <dependency>
        <groupId>org.jboss.arquillian.extension</groupId>
        <artifactId>arquillian-drone-webdriver-depchain</artifactId>
        <type>pom</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian.graphene</groupId>
        <artifactId>graphene-webdriver</artifactId>
        <version>${version.org.jboss.arquillian.graphene2}</version>
        <type>pom</type>
        <scope>test</scope>
    </dependency>
...

我在远程JBoss-as-7.1.1服务器上运行此测试。我不明白为什么需要operadriver ......

3 个答案:

答案 0 :(得分:1)

不需要依赖项org.jboss.arquillian.extension:arquillian-drone-webdriver-depchain:pom

使用本教程中列出的依赖项应该足够了。

您可以将版本升级到:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>1.1.3.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-drone-bom</artifactId>
            <version>1.2.3.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.selenium</groupId>
            <artifactId>selenium-bom</artifactId>
            <version>2.39.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependency>
    <groupId>org.jboss.arquillian.graphene</groupId>
    <artifactId>graphene-webdriver</artifactId>
    <version>2.0.1.Final</version>
    <type>pom</type>
    <scope>test</scope>
</dependency>

答案 1 :(得分:0)

依赖关系在POM中指定

<dependency>
    <groupId>org.jboss.arquillian.extension</groupId>
    <artifactId>arquillian-drone-webdriver-depchain</artifactId>
    <version>1.2.0.Final</version>
</dependency>

依赖于groupId com.opera 和工件 operadriver

Plz查看maven链接http://mvnrepository.com/artifact/org.jboss.arquillian.extension/arquillian-drone-webdriver-depchain/1.2.0.Final

答案 2 :(得分:0)

问题与类路径中缺少Opera Driver的事实有关。包括整个Drone web驱动程序depchain将解决问题。请注意,arquillian-drone-webdriver-depchain工件的打包类型为pom,因此请确保在将依赖项包含到项目中时,将type定义为pom。这样,它的所有依赖项都将作为传递依赖项添加到项目中。

<dependency>
    <groupId>org.jboss.arquillian.extension</groupId>
    <artifactId>arquillian-drone-webdriver-depchain</artifactId>
    <version>${version.org.jboss.arquillian.drone}</version>
    <type>pom</type>
    <scope>test</scope>
</dependency>

我希望这会有所帮助。