运行selenium remotedriver时出现带有NativeConstructorAccessorImpl.newInstance0的SessionNotCreatedException错误 [英] Error SessionNotCreatedException with NativeConstructorAccessorImpl.newInstance0 while running selenium remotedriver

查看:3607
本文介绍了运行selenium remotedriver时出现带有NativeConstructorAccessorImpl.newInstance0的SessionNotCreatedException错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行以下内容但收到错误

I am running the following but getting the error

public class base
{
    public static WebDriver driver;

    public static void main(String[]  args) throws MalformedURLException, InterruptedException
    {
        System.setProperty("webdriver.chrome.driver", "C:\\code\\lib\\browser drivers\\chromedriver.exe");

        String URL = "http://www.google.com";
        String Node = "http://localhost:4444/wd/hub";
        DesiredCapabilities cap = DesiredCapabilities.chrome();
        cap = DesiredCapabilities.chrome();
        cap.setPlatform(org.openqa.selenium.Platform.WINDOWS);


        driver = new RemoteWebDriver(new URL(Node), cap);

        driver.navigate().to(URL);
        Thread.sleep(5000);
        driver.quit();
    }       
}

显示错误如下:

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'RAJESHW10', ip: '169.254.3.253', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
Driver info: driver.version: unknown
Command duration or timeout: 316 milliseconds
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

有人可以请帮助

推荐答案

请执行以下操作并重试。

Please do the following and retry.

确保路径 C:\\code\\lib\\ browser drivers \\chromedriver.exe 已添加到您的%PAT运行节点的计算机上的H%变量。这将确保selenium uber jar可以找到chromedriver二进制文件的位置。

Ensure that the path C:\\code\\lib\\browser drivers\\chromedriver.exe is added to your %PATH% variable on the machine in which you are running the node. This would ensure that the selenium uber jar can find the location of the chromedriver binary.


System.setProperty(webdriver.chrome .driver,C:\ code \lib \browser drivers \chromedriver.exe);

此机制仅在您执行时使用

This mechanism should be only used when you are doing

ChromeDriver driver = ChromeDriver()

由于您正在使用selenium网格,因此您在此处理多个JVM。

Since you are working with a selenium grid, you are dealing with multiple JVMs here.

System.setProperty()只会影响当前的JVM(在本例中是您的测试),但是实际的浏览器在另一个JVM(运行selenium节点的JVM)中分离出来。

System.setProperty() will affect only the current JVM (which in this case is your tests), but the actual browser gets spun off in a different JVM (the one that is running the selenium node).

这篇关于运行selenium remotedriver时出现带有NativeConstructorAccessorImpl.newInstance0的SessionNotCreatedException错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆