我试图通过WebDriverBackedSelenium在iexplore中使用Selenium Webdriver运行Selenium RC的代码。
在SeleniumConfig.class中我有:
File file = new File("C:/Selenium/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();
selenium = new WebDriverBackedSelenium(driver, "https:// my web ");
通常,SeleniumConfig for RC中的代码是
selenium = new DefaultSelenium("localhost", getPuerto(),
"*iexplore", "https:// my web");
selenium.start();
这是有效的。但是用新代码替换我得到了这个错误:
java.lang.NoClassDefFoundError: org/openqa/selenium/ExplodingSupplier
at org.openqa.selenium.WebDriverCommandProcessor.<init>(WebDriverCommandProcessor.java:165)
at org.openqa.selenium.WebDriverBackedSelenium.<init>(WebDriverBackedSelenium.java:30)
at config.SeleniumConfig.start(SeleniumConfig.java:40)
at idenLocaJava.LocaJavaSuite.setUp(LocaJavaSuite.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at .....
在控制台中:
Started InternetExplorerDriver server (32-bit)
2.45.0.0
Listening on port 12628
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
一些建议?可能我需要在POM.XML中有一些依赖? 我有:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>16.0.1</version>
</dependency>
我需要使用java 7,最新的兼容版本是selenium 2.46.0,我也试过。
感谢。
答案 0 :(得分:0)
我期待这个问题通常是因为不同版本的罐子之间的罐子或冲突。因为Maven使用good来提供所需的依赖关系,可能只有selenium-java和selenium-server,当然还有一个用于htmlunit。提供了更多信息here
谢谢你, 穆拉利
答案 1 :(得分:0)
谢谢,我添加了
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>2.45.0</version>
</dependency>
because without this I had
java.lang.NoClassDefFoundError: org/openqa/selenium/HasInputDevices
and
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>16.0.1</version>
</dependency>
becase whitout this i had
java.lang.NoClassDefFoundError: com/google/common/net/MediaType
I could delete
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<version>1.3</version>
</dependency>
But still the error
答案 2 :(得分:0)
看起来您的项目仍在引用旧的selenium jar。你可以在项目中运行“mvn dependency:tree”,看看你是否得到了正确的版本。尝试清洁和重建。
错误消息(WebDriverCommandProcessor和WebDriverBackedSelenium)中的selemium类来自旧的selenium包。在2.45.0中应该是:
com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium
com.thoughtworks.selenium.webdriven.WebDriverCommandProcessor