在maven中运行selenium测试时遇到异常

时间:2013-05-10 12:38:34

标签: java maven selenium-webdriver

我正在使用java,maven,selenium-webdriver。我添加了依赖项“ selenium-server 2.32.0”,“selenium-java 2.32.0 ”。但我得到的Exception如下: 这是代码: -

public class ABC{
   private static WebDriver webDriver ;
    public static void main(String [] args) throws IOException{
        ChromeDriverService service = new ChromeDriverService.Builder()
        .usingDriverExecutable(
                new File("/root/Downloads/chromedriver"))
                .usingAnyFreePort().build();
        service.start();
        webDriver = new RemoteWebDriver(service.getUrl(),
                DesiredCapabilities.chrome());
          //webDriver = new FirefoxDriver(); 
    }
} 

如您所见,我还创建了firefoxdriver实例但获得相同的异常。

 Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
    at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:59)
    at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:48)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:100)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:81)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129).

还添加了' httpclient 4.1.2 '。但是获得相同的异常,请指导我如何解决此问题

1 个答案:

答案 0 :(得分:0)

在服务使用示例下使用正确的结构(然后只需通过测试扩展您班级中的设置)

{
  "type": "Microsoft.Compute/virtualMachines/extensions",
  "name": "[concat(variables('vmName'),'/', variables('extensionName'))]",
  "apiVersion": "[variables('apiVersion')]",
  "location": "[resourceGroup().location]",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
  ],
  "properties": {
    "publisher": "Microsoft.Azure.Extensions",
    "type": "CustomScript",
    "typeHandlerVersion": "2.0",
    "autoUpgradeMinorVersion": true,
    "settings": {
      "fileUris": "[split(parameters('fileUris'), ' ')]",
      "commandToExecute": "[parameters('commandToExecute')]"
    },
    "protectedSettings": {
      "storageAccountName": "[parameters('customScriptStorageAccountName')]",
      "storageAccountKey": "[parameters('customScriptStorageAccountKey')]"
    }
  }
}