Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java org.openqa.selenium.SessionNotCreatedException:未创建会话断开连接:无法向渲染器发送消息ChromeDriver和Chrome出现错误_Java_Selenium_Google Chrome_Selenium Webdriver_Selenium Chromedriver - Fatal编程技术网

Java org.openqa.selenium.SessionNotCreatedException:未创建会话断开连接:无法向渲染器发送消息ChromeDriver和Chrome出现错误

Java org.openqa.selenium.SessionNotCreatedException:未创建会话断开连接:无法向渲染器发送消息ChromeDriver和Chrome出现错误,java,selenium,google-chrome,selenium-webdriver,selenium-chromedriver,Java,Selenium,Google Chrome,Selenium Webdriver,Selenium Chromedriver,我尝试使用Selenium在Java上运行这个简单的程序: import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class MySelenium { public static void main(String[] args) { System.out.println("First Selenium"); System

我尝试使用Selenium在Java上运行这个简单的程序:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;


public class MySelenium {

    public static void main(String[] args) {
        System.out.println("First Selenium");
        System.setProperty("webdriver.chrome.driver", "C:\\automation\\drivers\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.seleniumhq.org/");
        driver.quit();              
    }
}
但在运行时显示以下错误:

如何修复此错误?

此错误消息

org.openqa.selenium.SessionNotCreatedException: session not created 
disconnected: unable to send message to renderer
…意味着ChromeDriver无法启动/生成新的网络浏览器,即Chrome浏览器会话

我怀疑您的主要问题是所使用的二进制文件版本之间的不兼容

根据您提供的快照,您正在使用的以下二进制文件集在我看来很好:

  • JDK:1.8.0\u 191
  • 硒:3.14.0
  • 色度驱动器:2.43
  • 铬:69.0
分析与解决方案
  • 另一个主要原因可能是本地主机中存在防病毒,您需要禁用该病毒

  • 确保系统上的/etc/hosts包含以下条目:

    127.0.0.1 localhost.localdomain localhost
    #or
    127.0.0.1 localhost loopback
    
  • 将Chrome版本保持在Chrome v68-70级别之间。()

  • 通过IDE清理项目工作区,并仅使用所需的依赖项重建项目
  • (仅限Windows OS)在执行测试套件之前和之后,使用该工具清除所有操作系统杂务
  • (仅限LinuxOS)在执行测试套件之前和之后
  • 如果您的基本Web客户端版本太旧,请通过卸载它并安装最新的GA和Web客户端发布版本
  • 重新启动系统
  • 执行
    @测试

参考文献 您可以在中找到相关的讨论


tl;博士
根据这一点,ChromeDriver 2.38和Chrome67+/strong>组合也观察到了这个问题,并且与静态iFrame(最初加载的DOM的一部分)相关,即使在Chrome66之前,静态iFrame似乎也能正常工作。更新到JDK 1.8.0_191后,我遇到了同样的问题。

请阅读原因。粘贴代码并正确格式化。你搜索了错误消息了吗?你发现了什么?根据你的发现,你尝试了什么?做一点搜索,并用结果更新你的问题。可能重复