kazurayam / chromedriverfactory

A Java library that enables you to launch Selenium ChromeDriver using an existing user Profile. That let you to carry cookies over multiple HTTP sessions via user Profile.
0 stars 0 forks source link

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. #29

Closed kazurayam closed 2 years ago

kazurayam commented 2 years ago

v0.2.7, when i execute "> gradle test", i encounter a few failures (1, 2, 3 or 4) like

<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="examples.LaunchChromeWithUserProfile" tests="3" skipped="1" failures="1" errors="0" timestamp="2022-01-11T02:21:20" hostname="KAZUAKInoAir.AirPort" time="5.762">
  <properties/>
  <testcase name="test_launch_browser_with_profile" classname="examples.LaunchChromeWithUserProfile" time="1.709">
    <failure message="org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.&#10;  (chrome not reachable)&#10;  (The process started from chrome location /Applications/Google Chrome.app/Contents/MacOS/Google Chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)&#10;Build info: version: '4.1.1', revision: 'e8fcc2cecf'&#10;System info: host: 'KAZUAKInoAir.AirPort', ip: 'fe80:0:0:0:80:3542:d3d:bcc8%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '11.1', java.version: '11.0.11'&#10;Driver info: org.openqa.selenium.chrome.ChromeDriver&#10;Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [user-data-dir=/var/folders/..., profile-directory=Profile 6, window-size=1024,768, disableExtensions, disable-gpu, disable-infobars, disable-dev-shm-usage, --no-sandbox], extensions: [], prefs: {download.default_directory: /Users/kazuakiurayama/Downl..., download.prompt_for_download: false, plugins.plugins_disabled: [Adobe Flash Player, Chrome PDF Viewer], profile.default_content_settings.popups: 0}}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [user-data-dir=/var/folders/..., profile-directory=Profile 6, window-size=1024,768, disableExtensions, disable-gpu, disable-infobars, disable-dev-shm-usage, --no-sandbox], extensions: [], prefs: {download.default_directory: /Users/kazuakiurayama/Downl..., download.prompt_for_download: false, plugins.plugins_disabled: [Adobe Flash Player, Chrome PDF Viewer], profile.default_content_settings.popups: 0}}}}]" type="org.openqa.selenium.SessionNotCreatedException">org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.
  (chrome not reachable)
  (The process started from chrome location /Applications/Google Chrome.app/Contents/MacOS/Google Chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'KAZUAKInoAir.AirPort', ip: 'fe80:0:0:0:80:3542:d3d:bcc8%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '11.1', java.version: '11.0.11'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [user-data-dir=/var/folders/..., profile-directory=Profile 6, window-size=1024,768, disableExtensions, disable-gpu, disable-infobars, disable-dev-shm-usage, --no-sandbox], extensions: [], prefs: {download.default_directory: /Users/kazuakiurayama/Downl..., download.prompt_for_download: false, plugins.plugins_disabled: [Adobe Flash Player, Chrome PDF Viewer], profile.default_content_settings.popups: 0}}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [user-data-dir=/var/folders/..., profile-directory=Profile 6, window-size=1024,768, disableExtensions, disable-gpu, disable-infobars, disable-dev-shm-usage, --no-sandbox], extensions: [], prefs: {download.default_directory: /Users/kazuakiurayama/Downl..., download.prompt_for_download: false, plugins.plugins_disabled: [Adobe Flash Player, Chrome PDF Viewer], profile.default_content_settings.popups: 0}}}}]
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:230)
    at org.openqa.selenium.remote.RemoteWebDriver.&lt;init&gt;(RemoteWebDriver.java:151)
    at org.openqa.selenium.chromium.ChromiumDriver.&lt;init&gt;(ChromiumDriver.java:108)
    at org.openqa.selenium.chrome.ChromeDriver.&lt;init&gt;(ChromeDriver.java:104)
    at org.openqa.selenium.chrome.ChromeDriver.&lt;init&gt;(ChromeDriver.java:91)
    at org.openqa.selenium.chrome.ChromeDriver.&lt;init&gt;(ChromeDriver.java:80)
    at jdk.internal.reflect.GeneratedConstructorAccessor25.newInstance(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:250)
    at com.kazurayam.webdriverfactory.chrome.ChromeDriverFactoryImpl.launchChrome(ChromeDriverFactoryImpl.groovy:252)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
    at com.kazurayam.webdriverfactory.chrome.ChromeDriverFactoryImpl.newChromeDriver(ChromeDriverFactoryImpl.groovy:165)
    at com.kazurayam.webdriverfactory.chrome.ChromeDriverFactoryImpl$newChromeDriver$4.callCurrent(Unknown Source)
    at com.kazurayam.webdriverfactory.chrome.ChromeDriverFactoryImpl.newChromeDriver(ChromeDriverFactoryImpl.groovy:128)
    at com.kazurayam.webdriverfactory.chrome.ChromeDriverFactoryImpl$newChromeDriver$9.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
    at examples.LaunchChromeWithUserProfile.test_launch_browser_with_profile(LaunchChromeWithUserProfile.groovy:20)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
    at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at com.sun.proxy.$Proxy5.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:413)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    at java.base/java.lang.Thread.run(Thread.java:829)
</failure>
  </testcase>
  <testcase name="test_launch_browser_with_profile_FOR_HERE" classname="examples.LaunchChromeWithUserProfile" time="0.001">
    <skipped/>
  </testcase>
  <testcase name="test_launch_browser_with_profile_TO_GO" classname="examples.LaunchChromeWithUserProfile" time="4.051"/>
  <system-out><![CDATA[]]></system-out>
  <system-err><![CDATA[[Test worker] INFO io.github.bonigarcia.wdm.WebDriverManager - Using chromedriver 97.0.4692.71 (resolved driver for Chrome 97)
[Test worker] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.chrome.driver as /Users/kazuakiurayama/.cache/selenium/chromedriver/mac64/97.0.4692.71/chromedriver
[Test worker] INFO com.kazurayam.webdriverfactory.chrome.ChromeDriverFactoryImpl - copied 510 files from /Users/kazuakiurayama/Library/Application Support/Google/Chrome/Profile 6 into /var/folders/lh/jkh513dn7f3c0j09z131g1z00000gn/T/__user-data-dir__4713169740704953960/Profile 6 
Starting ChromeDriver 97.0.4692.71 (adefa7837d02a07a604c1e6eff0b3a09422ab88d-refs/branch-heads/4692@{#1247}) on port 59270
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[Test worker] INFO com.kazurayam.webdriverfactory.chrome.ChromeDriverFactoryImpl - copied 510 files from /Users/kazuakiurayama/Library/Application Support/Google/Chrome/Profile 6 into /var/folders/lh/jkh513dn7f3c0j09z131g1z00000gn/T/__user-data-dir__6710504117824968621/Profile 6 
Starting ChromeDriver 97.0.4692.71 (adefa7837d02a07a604c1e6eff0b3a09422ab88d-refs/branch-heads/4692@{#1247}) on port 56730
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
1月 11, 2022 11:21:23 午前 org.openqa.selenium.remote.ProtocolHandshake createSession
情報: Detected dialect: W3C
1月 11, 2022 11:21:23 午前 org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
警告: Unable to find an exact match for CDP version 97, so returning the closest version found: 96
1月 11, 2022 11:21:23 午前 org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
情報: Found CDP implementation for version 97 of 96
]]></system-err>
</testsuite>

The failure is occasional. Different tests fail each time.

kazurayam commented 2 years ago

v0.4.0, when I execute $ gradle test, 1 or 2 SessionNotCreatedException occurs. Almost every time, but different class/different methods.

kazurayam commented 2 years ago

I have 2 Mac Book Air.

  1. Retina, 13-inch, 2018 1.6GHz Dual Core Intel Core i5, memory 16GB, macOS Monterey 12.1
  2. M1, 2020, Apple M1, 8GB, macOS Monterey 12.1

I experieced the SessionNotCreatedException frequently on the M1 machine.

I moved to the Intel Core i5 machine and tried "gradle test" several times. I did not experienced the Exception at all.

I suppose that the chromedriver binary is compiled for the Intel chip; not 100% adaptive to the M1 chip.