Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to an existing browser instance using noReset=true #20

Open
zuryx opened this issue Aug 25, 2021 · 2 comments
Open

Unable to connect to an existing browser instance using noReset=true #20

zuryx opened this issue Aug 25, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@zuryx
Copy link

zuryx commented Aug 25, 2021

Hi,

I'm unable to connect to an existing browser instance using noReset=true capability. Based on the logs looks like geckodriver cannot be launched because is expecting --marionette-port as part of the params (currently only --connect-existing and -p 5200 are specified)

Capabilites:
final DesiredCapabilities capabilities = DesiredCapabilities.android();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "mac");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "firefox");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Gecko");
capabilities.setCapability("noReset", "true");
final Map<String,Object> firefoxOptions = new HashMap<>();
firefoxOptions.put("androidPackage", "org.mozilla.firefox");
capabilities.setCapability("moz:firefoxOptions", firefoxOptions);
capabilities.setCapability("acceptInsecureCerts", true);

Log:
[debug] [HTTP] Request idempotency key: fe1749fe-1c68-49b0-a89d-8858e773dabb
[HTTP] --> POST /wd/hub/session
[HTTP] {"desiredCapabilities":{"noReset":"true","acceptInsecureCerts":true,"automationName":"Gecko","browserName":"firefox","moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox"},"platformName":"mac","version":"","platform":"ANDROID"},"capabilities":{"firstMatch":[{"acceptInsecureCerts":true,"appium:automationName":"Gecko","browserName":"firefox","moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox"},"appium:noReset":"true","platform":"ANDROID","platformName":"mac","version":""}]}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"noReset":"true","acceptInsecureCerts":true,"automationName":"Gecko","browserName":"firefox","moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox"},"platformName":"mac","version":"","platform":"ANDROID"},null,{"firstMatch":[{"acceptInsecureCerts":true,"appium:automationName":"Gecko","browserName":"firefox","moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox"},"appium:noReset":"true","platform":"ANDROID","platformName":"mac","version":""}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1629905801851 (10:36:41 GMT-0500 (Central Daylight Time))
[BaseDriver] The following capabilities are not standard capabilities and should have an extension prefix:
[BaseDriver] platform
[BaseDriver] version
[Appium] Appium v1.21.0 creating new GeckoDriver (v0.3.2) session
[Appium] Applying relaxed security to 'GeckoDriver' as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver] "alwaysMatch": {
[debug] [BaseDriver] "acceptInsecureCerts": true,
[debug] [BaseDriver] "browserName": "firefox",
[debug] [BaseDriver] "moz:firefoxOptions": {
[debug] [BaseDriver] "androidPackage": "org.mozilla.firefox"
[debug] [BaseDriver] },
[debug] [BaseDriver] "appium:platform": "ANDROID",
[debug] [BaseDriver] "platformName": "mac",
[debug] [BaseDriver] "appium:version": "",
[debug] [BaseDriver] "appium:automationName": "Gecko",
[debug] [BaseDriver] "appium:noReset": "true"
[debug] [BaseDriver] },
[debug] [BaseDriver] "firstMatch": [
[debug] [BaseDriver] {}
[debug] [BaseDriver] ]
[debug] [BaseDriver] }
[BaseDriver] Capability 'noReset' changed from string to boolean. This may cause unexpected behavior
[BaseDriver] The following capabilities were provided, but are not recognized by Appium:
[BaseDriver] platform
[BaseDriver] version
[BaseDriver] Session created with session id: b0c6fb8c-7706-4857-8bf0-de7410a1b0b4
[GeckoDriverServer] Starting '/usr/local/bin/geckodriver' with args ["--connect-existing","-p",5200]
[debug] [GeckoDriverServer] [geckodriver] /usr/local/bin/geckodriver: error: The following required arguments were not provided:
[debug] [GeckoDriverServer] --marionette-port
[debug] [GeckoDriverServer]
[debug] [GeckoDriverServer] USAGE:
[debug] [GeckoDriverServer] geckodriver --connect-existing --marionette-host --marionette-port --host --port

[debug] [GeckoDriverServer]
[debug] [GeckoDriverServer] For more information try --help
[GeckoDriverServer] geckodriver has exited with code 64, signal null
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[GeckoDriver] Ending Gecko Driver session
[GeckoDriverServer] Gecko Driver session cannot be stopped, because the server is not running
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1629905811928 (10:36:51 GMT-0500 (Central Daylight Time))
[debug] [W3C] Encountered internal error running command: Error: Gecko Driver server is not listening within 10000ms timeout. Make sure it could be started manually from a terminal
[debug] [W3C] at GeckoDriverServer.start (/usr/local/lib/node_modules/appium/node_modules/appium-geckodriver/lib/gecko.js:176:15)
[debug] [W3C] at processTicksAndRejections (node:internal/process/task_queues:94:5)
[debug] [W3C] at GeckoDriver.createSession (/usr/local/lib/node_modules/appium/node_modules/appium-geckodriver/lib/driver.js:59:7)
[debug] [W3C] at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:387:35)

@mykola-mokhnach
Copy link
Contributor

Thanks @zuryx
To be honest, such scenario has never been tested by us.
Please check if the patch #21 works for you

@zuryx
Copy link
Author

zuryx commented Aug 26, 2021

Hi @mykola-mokhnach, first of all thank you for your quick answer. As you suggested, I tried patch #21 and with it geckodriver is up and running (: but now I'm getting a different error. I'm wondering if this issue can be related to the fact that maybe my current Firefox session is not running with marionette mode enabled. I didn't find a clear answer about how to enable marionette on Firefox for Android, therefore I just enabled "Remote debugging via USB" setting directly in the app (as you can see below).

image

I tried with Firefox Nightly (org.mozilla.fenix) instead of standard Firefox (org.mozilla.fenix) and also with capability marionettePort=0 (auto discovery port) and for both I got the same error.

Log:

[debug] [HTTP] Request idempotency key: e97484ec-d410-47e5-a464-2dc1ba3199e9
[HTTP] --> POST /wd/hub/session
[HTTP] {"desiredCapabilities":{"noReset":"true","acceptInsecureCerts":true,"automationName":"Gecko","browserName":"firefox","moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox","prefs":{"devtools.debugger.remote-enabled":true}},"platformName":"mac","version":"","platform":"ANDROID"},"capabilities":{"firstMatch":[{"acceptInsecureCerts":true,"appium:automationName":"Gecko","browserName":"firefox","moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox","prefs":{"devtools.debugger.remote-enabled":true}},"appium:noReset":"true","platform":"ANDROID","platformName":"mac","version":""}]}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"noReset":"true","acceptInsecureCerts":true,"automationName":"Gecko","browserName":"firefox","moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox","prefs":{"devtools.debugger.remote-enabled":true}},"platformName":"mac","version":"","platform":"ANDROID"},null,{"firstMatch":[{"acceptInsecureCerts":true,"appium:automationName":"Gecko","browserName":"firefox","moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox","prefs":{"devtools.debugger.remote-enabled":true}},"appium:noReset":"true","platform":"ANDROID","platformName":"mac","version":""}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1629952221357 (23:30:21 GMT-0500 (Central Daylight Time))
[BaseDriver] The following capabilities are not standard capabilities and should have an extension prefix:
[BaseDriver] platform
[BaseDriver] version
[Appium] Appium v1.21.0 creating new GeckoDriver (v0.3.3) session
[Appium] Applying relaxed security to 'GeckoDriver' as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver] "alwaysMatch": {
[debug] [BaseDriver] "acceptInsecureCerts": true,
[debug] [BaseDriver] "browserName": "firefox",
[debug] [BaseDriver] "moz:firefoxOptions": {
[debug] [BaseDriver] "androidPackage": "org.mozilla.firefox",
[debug] [BaseDriver] "prefs": {
[debug] [BaseDriver] "devtools.debugger.remote-enabled": true
[debug] [BaseDriver] }
[debug] [BaseDriver] },
[debug] [BaseDriver] "appium:platform": "ANDROID",
[debug] [BaseDriver] "platformName": "mac",
[debug] [BaseDriver] "appium:version": "",
[debug] [BaseDriver] "appium:automationName": "Gecko",
[debug] [BaseDriver] "appium:noReset": "true"
[debug] [BaseDriver] },
[debug] [BaseDriver] "firstMatch": [
[debug] [BaseDriver] {}
[debug] [BaseDriver] ]
[debug] [BaseDriver] }
[BaseDriver] Capability 'noReset' changed from string to boolean. This may cause unexpected behavior
[BaseDriver] The following capabilities were provided, but are not recognized by Appium:
[BaseDriver] platform
[BaseDriver] version
[BaseDriver] Session created with session id: a87f19ae-de1b-451e-940e-a1051b887a3b
[GeckoDriverServer] 'marionettePort' capability value is not provided while 'noReset' is enabled
[GeckoDriverServer] Assigning 'marionettePort' to the default value (2828)
[GeckoDriverServer] Starting '/usr/local/bin/geckodriver' with args ["--connect-existing","--marionette-port",2828,"-p",5200]
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:5200
[debug] [GeckoDriverServer] [geckodriver] 1629952221374 geckodriver INFO Listening on 127.0.0.1:5200
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:5200/status] with no body
[debug] [WD Proxy] Got response with status 200: {"value":{"message":"","ready":true}}
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:5200/session] with body: {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"browserName":"firefox","acceptInsecureCerts":true,"moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox","prefs":{"devtools.debugger.remote-enabled":true}},"platformName":"mac"}}}
[WD Proxy] Got response with status 500: {"value":{"error":"session not created","message":"Cannot connect to an existing Android App yet","stacktrace":""}}
[debug] [W3C] Matched W3C error code 'session not created' to SessionNotCreatedError
[GeckoDriver] Ending Gecko Driver session
[GeckoDriverServer] geckodriver has exited with code null, signal SIGTERM
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1629952222388 (23:30:22 GMT-0500 (Central Daylight Time))
[debug] [W3C] Encountered internal error running command: SessionNotCreatedError: A new session could not be created. Details: Cannot connect to an existing Android App yet

[debug] [W3C] at errorFromW3CJsonCode (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)
[debug] [W3C] at ProxyRequestError.getActualError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)
[debug] [W3C] at GeckoProxy.command (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:272:19)
[debug] [W3C] at processTicksAndRejections (node:internal/process/task_queues:94:5)
[debug] [W3C] at GeckoDriverServer.start (/usr/local/lib/node_modules/appium/node_modules/appium-geckodriver/lib/gecko.js:195:5)
[debug] [W3C] at GeckoDriver.createSession (/usr/local/lib/node_modules/appium/node_modules/appium-geckodriver/lib/driver.js:59:7)
[debug] [W3C] at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:387:35)
[HTTP] <-- POST /wd/hub/session 500 1055 ms - 1081
[HTTP]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants