Operadriver无法运作

时间:2014-01-28 01:26:50

标签: selenium selenium-webdriver

我正在使用Seleniumwebdriver和Maven并尝试在Opera上运行一个简单的测试。 我在我的pom文件中添加了Opera驱动程序1.5版的依赖项。

此外,我的selenium-server依赖是2.39.0。我已经尝试降级两个依赖项,但我的Opera驱动程序仍然无法显示以下错误。

任何建议都会非常有用。 错误:

java.lang.NoClassDefFoundError: org/openqa/selenium/Keyboard at com.seleniumsimplified.webdriver.browsers.OperaDriverTestCase.testBasicOperaUsage(OperaDriverTestCase.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at  com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.Keyboard
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 27 more

我的代码如下:     package com.seleniumsimplified.webdriver.browsers;

import com.opera.core.systems.OperaDriver;
import com.opera.core.systems.OperaProfile;
import org.junit.AfterClass;
import org.junit.Test;

import org.openqa.selenium.WebDriver;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public class OperaDriverTestCase {


@Test
public void testBasicOperaUsage(){

    WebDriver operaDriver = new OperaDriver();
    operaDriver.get("http://sadfasd.com");

    assertThat(operaDriver.getTitle(),is(""));
    operaDriver.quit();
}

}

1 个答案:

答案 0 :(得分:0)

Jagori,

请查看此link,其中Simon Stewart解释HasInputDevice导入已移至其他包中。 HasImportDevice导入是键盘的类定义所在的位置。

希望这有帮助。