Chrome浏览器版本-72.0.3626.121未使用selenium打开

Chrome浏览器版本-72.0.3626.121未使用selenium打开,selenium,google-chrome,webdriver,Selenium,Google Chrome,Webdriver,导入org.openqa.selenium.WebDriver; 导入org.openqa.selenium.chrome.ChromeDriver 导入初始常数 公共类TestSelenium{ private static WebDriver driver; public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", System.getProperty("user.

导入org.openqa.selenium.WebDriver; 导入org.openqa.selenium.chrome.ChromeDriver

导入初始常数

公共类TestSelenium{

private static WebDriver driver;

public static void main(String[] args) {

    System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+Constants.getChromeDriver());
    driver = new ChromeDriver();
    driver.get("https://www.google.com");

}
}

我得到的错误如下

在端口45163上启动ChromeDriver 2.46.628402(536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) 只允许本地连接。 请保护ChromeDriver和相关测试框架使用的端口,以防止恶意代码访问

chrome浏览器正在打开,但url无法显示

我正在使用

铬合金驱动器-72.0.3626.69


WebDriver-3.0

它没有打开,因为您没有指定
chromedriver.exe
文件的路径

请查找下面的代码片段

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class TestChrome {

    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "path of the exe file\\chromedriver.exe");

        // Initialize browser
        WebDriver driver = new ChromeDriver();

        // Open facebook
        driver.get("http://www.facebook.com");

        // Maximize browser

        driver.manage().window().maximize();

    }

}

您提到使用了
Chrome驱动程序-72.0.3626.69
,但错误显示
启动ChromeDriver 2.46.628402
。检查是否有正确的chrome驱动程序

可能的原因:

  • Old selenium(从下载3.14.xx)
  • 较旧的chrome驱动程序(考虑更新到最新的chromedriver)
  • Chrome浏览器版本不匹配(在上检查浏览器版本和chromedriver兼容性)
  • 较旧的Java版本(最新的Java版本11.0.2)

在调用Chrome驱动程序之前,尝试先设置Chrome驱动程序路径

System.setProperty("webdriver.chrome.driver", "path of the exe file\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.google.com");

您可以使用
bonigarcia
依赖项实现自动化。然后,您不需要保留
chromedriver.exe
或设置系统变量。它将为所有平台和所有浏览器自动执行所有配置

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.3.0</version>
</dependency> 

我已经用Selenium 3.14.0和Chrome 73.0.3683.86版(官方版本)(64位)进行了测试。

尝试设置Chrome选项:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--whitelist-ip *");
chromeOptions.addArguments("--proxy-server='direct://'");
chromeOptions.addArguments("--proxy-bypass-list=*");
WebDriver driver = new ChromeDriver(chromeOptions);

步骤1:在此页面上检查浏览器版本和webdriver版本:

第2步:如果在执行上述步骤后,直到出现相同问题,则按照以下方法执行:

公共类TestSelenium{
私有静态WebDriver;
公共静态void main(字符串[]args){
System.setProperty(“webdriver.chrome.driver”、“user.dir”);
驱动程序=新的ChromeDriver();
驱动程序。获取(“https://www.google.com");
}
}

您缺少set chrome driver.exe path System.setProperty(“webdriver.chrome.driver”,“C:\\Users\\Desktop\\ChromeDriver\\ChromeDriver.exe”);在驱动程序上方使用=新的ChromeDriver();我已经提供了它-抱歉,上面的代码中没有它。感谢使用错误堆栈跟踪更新您的问题。[1554105685.243][INFO]:启动chrome:“C:\Program Files(x86)\Google\chrome\Application\chrome.exe”--禁用后台网络--禁用客户端网络钓鱼检测--禁用默认应用--禁用挂起监视器--禁用弹出窗口阻止--禁用重新发布提示--禁用同步--禁用web资源--启用自动化--启用日志--强制fieldtrials=SiteIsolationExtensions/Control--忽略证书错误--加载扩展=“D:\Users\unccej\AppData\Local\Temp\scoped\u dir14196\u 3309\internal”--日志级别=0--仅度量记录--无首次运行--密码存储=基本--远程为什么使用常量。getChromePath()?我尝试了所有版本-日志错误-但我使用的是3.14-谢谢java版本是什么?java版本1.7.0_75-谢谢我猜是java版本导致了问题。我使用的是11.0,它工作正常。运气不好。看起来办公网络正在阻塞。有什么线索吗
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--whitelist-ip *");
chromeOptions.addArguments("--proxy-server='direct://'");
chromeOptions.addArguments("--proxy-bypass-list=*");
WebDriver driver = new ChromeDriver(chromeOptions);