获取HTMLUnit驱动程序异常(java.lang.ClassNotFoundException)-w Selenium和java

获取HTMLUnit驱动程序异常(java.lang.ClassNotFoundException)-w Selenium和java,selenium,htmlunit,Selenium,Htmlunit,我不熟悉无头浏览器的概念。我正在尝试验证一个页面 使用Selenium根据大量记录验证两个webElement值 我想使用HTMLUnit驱动程序(或任何无头浏览器驱动程序)获取此信息,但在启动HTMLUnit驱动程序时,我得到了类not found exception。下面是我的pom和我正在使用的代码。谢谢你的帮助。谢谢 pom.xml: <dependencies> <dependency> <groupId>junit</groupId>

我不熟悉无头浏览器的概念。我正在尝试验证一个页面 使用Selenium根据大量记录验证两个webElement值

我想使用HTMLUnit驱动程序(或任何无头浏览器驱动程序)获取此信息,但在启动HTMLUnit驱动程序时,我得到了类not found exception。下面是我的pom和我正在使用的代码。谢谢你的帮助。谢谢

pom.xml:

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>2.15</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.9.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>3.141.59</version>
</dependency>   
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>   
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
</dependencies>

您正在尝试混合使用不同的Selenium版本:

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>

<version>3.9.1</version>

</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>

<version>3.141.59</version>

</dependency>   

org.seleniumhq.selenium
硒爪哇
3.9.1
org.seleniumhq.selenium
硒原料药
3.141.59
您应该保持一致,使用3.141.59并将HTML单元驱动程序的依赖项更改为当前版本。他们更改了工件以匹配HTML单元版本

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>htmlunit-driver</artifactId>
  <version>2.34.0</version>
</dependency>

org.seleniumhq.selenium
htmlunit驱动程序
2.34.0
这将解决您的依赖性问题

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>htmlunit-driver</artifactId>
  <version>2.34.0</version>
</dependency>