Starting ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}) on port 9525
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
很多人都说不影响使用,但是运行的代码打不开浏览器,搞不懂这个为什么,浏览器的版本和Chromedriver的版本也对的上
这个是浏览器版本和chromedriver的版本
代码如下
public class LiuLanQi { public static WebDriver driver; public static WebDriver Open(String browser){ ChromeOptions options = new ChromeOptions(); options.setBinary("C:\\Users\\wuyilin510\\AppData\\Local\\Chromium\\Application\\"); WebDriver driver = new ChromeDriver(options); String path = System.getProperty("user.dir"); if (browser.equals("chrome")){ System.setProperty("webdriver.chrome.driver",path+"/drivers/chromedriver.exe"); driver = new ChromeDriver(); }else if (browser.equals("huohu")){ System.setProperty("webdriver.chrome.driver",path+"/drivers/getkodrivr"); driver = new FirefoxDriver(); }if (browser.equals("ie")){ System.setProperty("webdriver.chrome.driver",path+"/drivers/chromedriver.exe"); driver = new InternetExplorerDriver(); }else { System.err.println("你输入的浏览器名称有误"+browser); } driver.get("http//www.baidu.com"); return driver; } }
启动代码如下
public class LiuLanQiTest { @Test public void Oppen(){ LiuLanQi.Open("chrome"); } }
报错信息
Starting ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}) on port 40163
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.