解决selemium报错 Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure

关于 Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

代码中少了 webdriver.chrome.driver", "C:/selemiumlib/chromedriver.exe

应该为这样

        System.setProperty("webdriver.chrome.driver", "C:/selemiumlib/chromedriver.exe");
    //System.setProperty("webdriver.chrome.bin","C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
        System.setProperty("webdriver.chrome.bin","C:/Users/Admin/AppData/Local/Google/Chrome/Application/chrome.exe");
    WebDriver driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
    driver.get("http://www.baidu.com");
    driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
    driver.close();

 

 System.setProperty("webdriver.chrome.driver", "C:/selemiumlib/chromedriver.exe");

不添加这一行其实也可以,但要注意系统中chrome应该只有一个,否则报错

技术分享

 

正在研究一个系统里有不同版本的chrome的调用方法

 

 

文章来自:http://www.cnblogs.com/xlmig/p/5212376.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3