硒 - Java:PhantomJS:引起:java.lang.ClassNotFoundException:org.openqa.selenium.remote.HttpVerb

Selenium - Java : PhantomJS : Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.HttpVerb

我正在尝试使用 Selenium Java 实例化 PhantomJS 驱动程序。下面是代码:

     File file = new File("C:\Softwares\drivers\phantomjs-2.1.1-windows\bin\phantomjs.exe");               
     System.setProperty("phantomjs.binary.path", file.getAbsolutePath());       
     WebDriver driver = new PhantomJSDriver();  
     driver.get("http://www.google.com");         

我尝试过不同版本的 Selenium,但我遇到了同样的异常:

Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.HttpVerb
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/HttpVerb
    at org.openqa.selenium.phantomjs.PhantomJSDriver.getCustomCommands(PhantomJSDriver.java:166)
    at org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.<init>(PhantomJSCommandExecutor.java:62)
    at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:110)

我在我的项目中使用了以下依赖项列表:

  1. phantomjsdriver
  2. 硒-common.jar
  3. 硒-java 2.53.1。罐子

我使用过时版本的 selenium 库的原因是我在互联网上发现的一些文章说 remote/HttpVerb 已被弃用,降级库将消除错误。但是,我仍然收到此错误

请在 POM 中检查此依赖项

<dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-remote-driver</artifactId>
      <version>2.53.1</version>
    </dependency>

检查这个class是否存在