How to switch context on Device Farm with Appium?

0

Hello,

I am trying to switch the context to WebView and I am always receiving this message that the session was not created because Chrome was not reachable.

2025-03-18 19:37:05:425 - [Chromedriver@e51d] Spawning chromedriver with: /home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/linux/chromedriver_linux64_v134.0.6998.88 --port=44151 --adb-port=5037 --verbose
2025-03-18 19:37:05:432 - [Chromedriver@e51d] ChromeDriver version: '134.0.6998.88'
2025-03-18 19:37:05:433 - [Chromedriver@e51d] Matched '/status' to command name 'getStatus'
2025-03-18 19:37:05:434 - [Chromedriver@e51d] Proxying [GET /status] to [GET http://127.0.0.1:44151/status] with no body
2025-03-18 19:37:05:456 - [Chromedriver@e51d] connect ECONNREFUSED 127.0.0.1:44151
2025-03-18 19:37:05:657 - [Chromedriver@e51d] Matched '/status' to command name 'getStatus'
2025-03-18 19:37:05:657 - [Chromedriver@e51d] Proxying [GET /status] to [GET http://127.0.0.1:44151/status] with no body
2025-03-18 19:37:05:659 - [Chromedriver@e51d] Got response with status 200: {"value":{"build":{"version":"134.0.6998.88 (7e3d5c978c6d3a6eda25692cfac7f893a2b20dd0-refs/branch-heads/6998@{#1898})"},"message":"ChromeDriver ready for new sessions.","os":{"arch":"x86_64","name":"Linux","version":"5.10.233-224.894.amzn2.x86_64"},"ready":true}}
2025-03-18 19:37:05:659 - [Chromedriver@e51d] Starting W3C Chromedriver session with capabilities: {
2025-03-18 19:37:05:659 - [Chromedriver@e51d]   "capabilities": {
2025-03-18 19:37:05:659 - [Chromedriver@e51d]     "alwaysMatch": {
2025-03-18 19:37:05:659 - [Chromedriver@e51d]       "goog:chromeOptions": {
2025-03-18 19:37:05:659 - [Chromedriver@e51d]         "androidPackage": "com.age.portalfuncionarioapp",
2025-03-18 19:37:05:659 - [Chromedriver@e51d]         "androidUseRunningApp": true,
2025-03-18 19:37:05:659 - [Chromedriver@e51d]         "androidProcess": "com.age.portalfuncionarioapp",
2025-03-18 19:37:05:659 - [Chromedriver@e51d]         "androidDeviceSerial": "RFCW50M9N1T"
2025-03-18 19:37:05:659 - [Chromedriver@e51d]       },
2025-03-18 19:37:05:659 - [Chromedriver@e51d]       "goog:loggingPrefs": {
2025-03-18 19:37:05:659 - [Chromedriver@e51d]         "browser": "ALL"
2025-03-18 19:37:05:659 - [Chromedriver@e51d]       }
2025-03-18 19:37:05:659 - [Chromedriver@e51d]     }
2025-03-18 19:37:05:659 - [Chromedriver@e51d]   }
2025-03-18 19:37:05:659 - [Chromedriver@e51d] }
2025-03-18 19:37:05:660 - [Chromedriver@e51d] Matched '/session' to command name 'createSession'
2025-03-18 19:37:05:660 - [Chromedriver@e51d] Proxying [POST /session] to [POST http://127.0.0.1:44151/session] with body: {"capabilities":{"alwaysMatch":{"goog:chromeOptions":{"androidPackage":"com.age.portalfuncionarioapp","androidUseRunningApp":true,"androidProcess":"com.age.portalfuncionarioapp","androidDeviceSerial":"RFCW50M9N1T"},"goog:loggingPrefs":{"browser":"ALL"}}}}
2025-03-18 19:38:05:943 - [Chromedriver@e51d] Got response with status 500: {"value":{"error":"session not created","message":"session not created\nfrom chrome not reachable","stacktrace":"#0 0x56536d728a1a <unknown>\n#1 0x56536d1e01e3 <unknown>\n#2 0x56536d1cb1a3 <unknown>\n#3 0x56536d21f73c <unknown>\n#4 0x56536d216e2a <unknown>\n#5 0x56536d26653f <unknown>\n#6 0x56536d265a76 <unknown>\n#7 0x56536d2579a3 <unknown>\n#8 0x56536d22360e <unknown>\n#9 0x56536d224dd1 <unknown>\n#10 0x56536d6eeddb <unknown>\n#11 0x56536d6f2cbc <unknown>\n#12 0x56536d6d6392 <unknown>\n#13 0x56536d6f3834 <unknown>\n#14 0x56536d6ba1ef <unknown>\n#15 0x56536d717038 <unknown>\n#16 0x56536d717216 <unknown>\n#17 0x56536d727896 <unknown>\n#18 0x7f2f3a94444b start_thread\n"}}
2025-03-18 19:38:05:943 - [W3C] Matched W3C error code 'session not created' to SessionNotCreatedError
2025-03-18 19:38:05:958 - [Chromedriver@e51d] SessionNotCreatedError: A new session could not be created. Details: session not created
2025-03-18 19:38:05:958 - [Chromedriver@e51d] from chrome not reachable
2025-03-18 19:38:05:958 - [Chromedriver@e51d]     at errorFromW3CJsonCode (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/@appium/base-driver/lib/protocol/errors.js:1085:25)
2025-03-18 19:38:05:958 - [Chromedriver@e51d]     at ProxyRequestError.getActualError (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/@appium/base-driver/lib/protocol/errors.js:954:14)
2025-03-18 19:38:05:958 - [Chromedriver@e51d]     at JWProxy.command (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:353:19)
2025-03-18 19:38:05:958 - [Chromedriver@e51d]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
2025-03-18 19:38:05:958 - [Chromedriver@e51d]     at Chromedriver.startSession (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/lib/chromedriver.js:743:7)
2025-03-18 19:38:05:958 - [Chromedriver@e51d]     at Chromedriver.start (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/lib/chromedriver.js:667:14)
2025-03-18 19:38:05:958 - [Chromedriver@e51d]     at AndroidUiautomator2Driver.setupNewChromedriver (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context/helpers.js:745:3)
2025-03-18 19:38:05:959 - [Chromedriver@e51d]     at AndroidUiautomator2Driver.startChromedriverProxy (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context/exports.js:229:10)
2025-03-18 19:38:05:959 - [Chromedriver@e51d]     at AndroidUiautomator2Driver.switchContext (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context/exports.js:108:5)
2025-03-18 19:38:05:959 - [Chromedriver@e51d]     at AndroidUiautomator2Driver.setContext (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context/exports.js:64:3)
2025-03-18 19:38:05:959 - [Chromedriver@e51d]     at wrapped (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:93:13)
2025-03-18 19:38:05:959 - [Chromedriver@e51d]     at retry (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:66:13)
2025-03-18 19:38:05:959 - [Chromedriver@e51d]     at retryInterval (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/node_modules/asyncbox/lib/asyncbox.js:103:10)
2025-03-18 19:38:05:959 - [Chromedriver@e51d]     at AndroidUiautomator2Driver.performSessionPostExecSetup (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/lib/driver.ts:650:7)
2025-03-18 19:38:05:959 - [Chromedriver@e51d]     at AndroidUiautomator2Driver.startUiAutomator2Session (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/lib/driver.ts:683:5)
2025-03-18 19:38:05:959 - [Chromedriver@e51d]     at AndroidUiautomator2Driver.createSession (/home/device-farm/.appium/node_modules/appium-uiautomator2-driver/lib/driver.ts:405:22)
2025-03-18 19:38:05:959 - [Chromedriver@e51d]     at AppiumDriver.createSession (/var/devicefarm/runtime/appium_2_x/node_modules/appium/lib/appium.js:717:35)
2025-03-18 19:38:05:961 - [Chromedriver@e51d] Chromedriver exited unexpectedly with code null, signal SIGTERM
2025-03-18 19:38:05:961 - [Chromedriver@e51d] Changed state to 'stopped'
2025-03-18 19:38:05:961 - [Chromedriver@e51d] A new session could not be created. Details: session not created
2025-03-18 19:38:05:961 - [Chromedriver@e51d] from chrome not reachable

I have simulated the situation locally by forcing a ChromeDriver update before switching the context, but the error still does not occur.

Do I need to configure or inform something different so that I can use WebView in Device Farm?

asked 2 months ago35 views
1 Answer
1
Accepted Answer

Hi,

Thank you for sharing your query. This error can occur due to mismatch of chrom driver, can you please try the below approaches and check if this helps :

  1. The yaml test file needs to be updated in order to use the properly-matched chromedriver and chromedriver version. Set the value as : \"chromedriverExecutableDir\":\"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE_DIR\"
  2. Please change the device from the device pool to a different one and test if that allows the test. Please check here for more reference.
AWS
SUPPORT ENGINEER
answered 2 months ago
profile pictureAWS
EXPERT
reviewed 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions