简体   繁体   English

org.openqa.selenium.SessionNotCreatedException: session not created exception from tab crashed error when executing from Jenkins CI 服务器

[英]org.openqa.selenium.SessionNotCreatedException: session not created exception from tab crashed error when executing from Jenkins CI server

I am trying to run my automation tests from Jenkins CI server (built with Gradle), but the browser crashes instantly with the error below.我正在尝试从 Jenkins CI 服务器(使用 Gradle 构建)运行我的自动化测试,但浏览器立即崩溃并显示以下错误。 It also crashes when I run gradle test from the console.当我从控制台运行 gradle 测试时,它也会崩溃。 Now when I am running the same test from the IDE (Idea), everything works just fine.现在,当我从 IDE (Idea) 运行相同的测试时,一切正常。 I run the exact same test file, in the exact same directory.我在完全相同的目录中运行完全相同的测试文件。 Versions: Selenium: 3.11.0 Gradle: 4.6 TestNG: 6.14.2 Chrome: 65.0.3325.181 Chromedriver: 2.37版本:Selenium:3.11.0 Gradle:4.6 TestNG:6.14.2 Chrome:65.0.3325.181 Chromedriver:2.37

Anyone has any idea what could be causing this?任何人都知道是什么原因造成的?

org.openqa.selenium.SessionNotCreatedException: session not created exception
from tab crashed
  (Session info: chrome=65.0.3325.181)
  (Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.50 seconds
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'USNBDFV9K12', ip: '10.23.4.80', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: driver.version: ChromeDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:132)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
    at qa.appmanager.ApplicationManager.init(ApplicationManager.java:48)
    at qa.tests.misc_tests.TestBase.setUp(TestBase.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
    at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:455)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:401)
    at org.testng.SuiteRunner.run(SuiteRunner.java:364)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
    at org.testng.TestNG.runSuites(TestNG.java:1049)
    at org.testng.TestNG.run(TestNG.java:1017)
    at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.runTests(TestNGTestClassProcessor.java:134)
    at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.stop(TestNGTestClassProcessor.java:88)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy1.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:748)

This error message...这个错误信息...

org.openqa.selenium.SessionNotCreatedException: session not created exception from tab crashed (Session info: chrome=65.0.3325.181) (Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 2.50 seconds Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z' System info: host: 'USNBDFV9K12', ip: '10.23.4.80', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131' Driver info: driver.version: ChromeDriver

The error stack trace clearly shows your ChromeDriver binary details are not getting detected back as in :错误堆栈跟踪清楚地显示您的ChromeDriver二进制详细信息没有被检测到:

Driver info: driver.version: ChromeDriver

Though your chromedriver=2.37.544315 and Chrome: 65.0.3325.181 are compatible your main issue is java.version: '1.8.0_131' which is ancient .尽管您的chromedriver=2.37.544315Chrome: 65.0.3325.181兼容,但您的主要问题是java.version: '1.8.0_131'这是古老的


Solution解决方案

  • Upgrade JDK to recent levels JDK 8u162JDK升级到最新级别JDK 8u162
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.通过IDE清理项目工作区并仅使用所需的依赖项重建项目。
  • Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite .在执行测试套件之前和之后,使用CCleaner工具清除所有操作系统杂务。
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client .如果您的基本Web Client版本太旧,请通过Revo Uninstaller卸载它并安装最新的 GA 和发布版本的Web Client
  • Take a system Reboot .采取系统重新启动
  • Execute your @Test .执行你的@Test

from tab crashed从选项卡崩溃

from tab crashed was WIP( Work In Progress ) with the Chromium Team for quite some time now which relates to Linux attempting to always use /dev/shm for non-executable memory .来自选项卡崩溃的WIP(正在进行的工作)与Chromium 团队现在已经有一段时间了,这与Linux 试图始终将 /dev/shm 用于非可执行内存有关 Here are the references :以下是参考资料:

Hence you may need to bump up to Chrome v65.0.3299.6 or later.因此,您可能需要升级到Chrome v65.0.3299.6或更高版本。

请尝试使用 Chromedriver 版本 83.0.4103.39 ( https://chromedriver.chromium.org/downloads )

Chrome Crash issue fix : Chrome 崩溃问题修复:

This code with launch the browser without any crash.此代码启动浏览器而不会发生任何崩溃。 Make sure, chrome exe is compatible with the current browser.确保 chrome exe 与当前浏览器兼容。

    ChromeOptions options = new ChromeOptions()
    options.addArguments("--no-sandbox");
    driver = new ChromeDriver(options);
    driver.manage().window().maximize();
    driver.get("https://www.google.com");

In my case, it was getting crashed in my chromium due to DDoS protection ,就我而言,由于DDoS 保护,它在我的铬中崩溃了, 在此处输入图片说明

I am able to solve it with the answer provided here Selenium webdriver: Modifying navigator.webdriver flag to prevent selenium detection我可以用这里提供的答案来解决它Selenium webdriver: Modifying navigator.webdriver flag to prevent selenium detection

Some take aways are,一些要点是,

  1. Please check the source html data.请检查源html数据。 With python: driver.page_source使用 python: driver.page_source
  2. As mentioned in the linked answer,如链接的答案中所述,
from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.53 Safari/537.36'})
print(driver.execute_script("return navigator.userAgent;"))
driver.get('https://www.httpbin.org/headers')

I had the same problem.我有同样的问题。 The following actions helped:以下行动有所帮助:

  1. Put the version of Java 11, in the maven (The same version was indicated for Jenkins when installing it. Java version for Jenkins 11 original from the oracle site, not OpenJDK, and environment variable JAVA_HOME must indicates this version. Jenkins had problems with OpenJDK.). Put the version of Java 11, in the maven (The same version was indicated for Jenkins when installing it. Java version for Jenkins 11 original from the oracle site, not OpenJDK, and environment variable JAVA_HOME must indicates this version. Jenkins had problems with OpenJDK .).
  2. Adding a git ignore file (I forgot to add it at the beginning of the project).添加一个git忽略文件(我忘记在项目开始添加了)。 Deleting folders in the project folder: target and idea.删除项目文件夹中的文件夹:target和idea。 (I also don't think this is important either.. But I also reopened the project folder in the idea, ran the tests, and chose to save the IML config.) (我也觉得这个也不重要。。但是我也重新打开了idea中的工程文件夹,跑了测试,选择了保存IML配置。)
  3. Pushing the changes to the github.将更改推送到 github。
  4. In Jenkis, deleting the current assembly of the project.在 Jenkis 中,删除项目的当前程序集。 Well, start on a new one.好吧,开始一个新的。

If the thread-count or data-provider-thread-count is more, decrease the thread-count value in testng file to make room for the session to get created如果线程计数或数据提供者线程计数更多,请减少 testng 文件中的线程计数值,以便为创建 session 腾出空间

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium error: “org.openqa.selenium.SessionNotCreatedException: session not created from tab crashed” after update electron engine to 9.0.3 - Selenium error: “org.openqa.selenium.SessionNotCreatedException: session not created from tab crashed” after update electron engine to 9.0.3 org.openqa.selenium.SessionNotCreatedException:会话未为Chrome创建异常 - org.openqa.selenium.SessionNotCreatedException: session not created exception for Chrome Selenium(OSX 和 Linux)抛出错误 org.openqa.selenium.SessionNotCreatedException:会话未创建:找不到匹配的功能 - Selenium(OSX and Linux) thowing error org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found org.openqa.selenium.SessionNotCreatedException:会话未创建断开连接:无法使用 ChromeDriver 和 Chrome 将消息发送到渲染器错误 - org.openqa.selenium.SessionNotCreatedException: session not created disconnected:unable to send message to renderer error with ChromeDriver and Chrome Appium 错误:线程“main”org.openqa.selenium.SessionNotCreatedException 中的异常:无法创建新的远程会话 - Appium Error :Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session org.openqa.selenium.SessionNotCreatedException - org.openqa.selenium.SessionNotCreatedException org.openqa.selenium.SessionNotCreatedException - org.openqa.selenium.SessionNotCreatedException org.openqa.selenium.SessionNotCreatedException:无法创建新会话。 (原始错误:请求了一个新会话,但正在进行中) - org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Requested a new session but one was in progress) org.openqa.selenium.SessionNotCreatedException:无法创建新的会话。 (原始错误:&#39;java -version&#39;失败。错误:产生ENOENT) - org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: 'java -version' failed. Error: spawn ENOENT) org.openqa.selenium.SessionNotCreatedException: session not created: 此版本的 ChromeDriver 仅支持使用 Selenium 的 Chrome 75 版 - org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 75 using Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM