代码改变世界

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

2016-02-24 11:35  xlmig  阅读(7169)  评论(0编辑  收藏  举报

关于 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的调用方法