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

DesiredCapabilities and requiredCapabilities are ignored #1384

Closed
alippai opened this issue Sep 21, 2018 · 15 comments
Closed

DesiredCapabilities and requiredCapabilities are ignored #1384

alippai opened this issue Sep 21, 2018 · 15 comments
Assignees

Comments

@alippai
Copy link

alippai commented Sep 21, 2018

System

  • Version: 0.22.0
  • Platform: Windows 10
  • Firefox: Firefox 62
  • Selenium: WebdriverIO 4.13.2

Testcase

Trying to use desiredCapabilities (like headless Firefox or acceptInsecureCerts)

Trace-level log

$ ./geckodriver.exe -v -p 9515
1537533157560   webdriver::httpapi      DEBUG   Creating routes
1537533157567   geckodriver     DEBUG   Listening on 127.0.0.1:9515
1537533163782   webdriver::server       DEBUG   -> POST /session {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"browser":"firefox","logLevel":"verbose","marionette":true,"acceptSslCerts":true,"acceptInsecureCerts":true,"moz:firefoxOptions":{"args":["-headless"]},"browserName":"firefox","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.13.2","name":"webdriverio"}}}
1537533163789   mozrunner::runner       INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\ADAM~1.LIP\\AppData\\Local\\Temp\\rust_mozprofile.0aeQxlkQUuVB"
1537533163790   geckodriver::marionette DEBUG   Waiting 60s to connect to browser on 127.0.0.1:63762
1537533164238   Marionette      DEBUG   Received observer notification profile-after-change
1537533164304   Marionette      DEBUG   Received observer notification command-line-startup
1537533164304   Marionette      DEBUG   Received observer notification nsPref:changed
1537533164304   Marionette      DEBUG   Init aborted (running=false, enabled=true, finalUIStartup=false)
1537533165082   Marionette      DEBUG   Received observer notification sessionstore-windows-restored
1537533165082   Marionette      DEBUG   Waiting for delayed startup...
1537533165229   Marionette      DEBUG   Setting recommended pref apz.content_response_timeout to 60000
1537533165230   Marionette      DEBUG   Setting recommended pref browser.download.panel.shown to true
1537533165230   Marionette      DEBUG   Setting recommended pref browser.pagethumbnails.capturing_disabled to true
1537533165230   Marionette      DEBUG   Setting recommended pref browser.search.update to false
1537533165230   Marionette      DEBUG   Setting recommended pref browser.showQuitWarning to false
1537533165231   Marionette      DEBUG   Setting recommended pref toolkit.cosmeticAnimations.enabled to false
1537533165231   Marionette      DEBUG   Setting recommended pref browser.tabs.disableBackgroundZombification to false
1537533165231   Marionette      DEBUG   Setting recommended pref browser.tabs.warnOnCloseOtherTabs to false
1537533165231   Marionette      DEBUG   Setting recommended pref browser.tabs.warnOnOpen to false
1537533165231   Marionette      DEBUG   Setting recommended pref browser.usedOnWindows10.introURL to
1537533165231   Marionette      DEBUG   Setting recommended pref browser.urlbar.suggest.searches to false
1537533165232   Marionette      DEBUG   Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
1537533165232   Marionette      DEBUG   Setting recommended pref dom.disable_beforeunload to true
1537533165232   Marionette      DEBUG   Setting recommended pref dom.disable_open_during_load to false
1537533165232   Marionette      DEBUG   Setting recommended pref dom.file.createInChild to true
1537533165232   Marionette      DEBUG   Setting recommended pref dom.max_chrome_script_run_time to 0
1537533165232   Marionette      DEBUG   Setting recommended pref dom.max_script_run_time to 0
1537533165233   Marionette      DEBUG   Setting recommended pref extensions.getAddons.cache.enabled to false
1537533165233   Marionette      DEBUG   Setting recommended pref extensions.webservice.discoverURL to http://%(server)s/dummy/discoveryURL
1537533165233   Marionette      DEBUG   Setting recommended pref network.http.prompt-temp-redirect to false
1537533165233   Marionette      DEBUG   Setting recommended pref network.http.speculative-parallel-limit to 0
1537533165233   Marionette      DEBUG   Setting recommended pref security.fileuri.strict_origin_policy to false
1537533165233   Marionette      DEBUG   Setting recommended pref security.notification_enable_delay to 0
1537533165234   Marionette      DEBUG   Setting recommended pref signon.autofillForms to false
1537533165234   Marionette      DEBUG   Setting recommended pref signon.rememberSignons to false
1537533165275   Marionette      INFO    Listening on port 63762
1537533165276   Marionette      DEBUG   Remote service is active
1537533165394   geckodriver::marionette DEBUG   Connection established on 127.0.0.1:63762. Waiting for Marionette handshake
1537533165396   Marionette      DEBUG   Accepted connection 0 from 127.0.0.1:63772
1537533165396   geckodriver::marionette DEBUG   Connected to Marionette
1537533165459   Marionette      DEBUG   [6442450945] Frame script loaded
1537533165461   Marionette      DEBUG   [6442450945] Frame script registered
1537533165468   webdriver::server       DEBUG   <- 200 OK {"value":{"sessionId":"39d05273-16c8-425e-9340-03f0e216297e","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"62.0","moz:accessibilityChecks":false,"moz:geckodriverVersion":"0.22.0","moz:headless":false,"moz:processID":8236,"moz:profile":"C:\\Users\\adam.lippai\\AppData\\Local\\Temp\\rust_mozprofile.0aeQxlkQUuVB","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"windows_nt","platformVersion":"10.0","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
1537533165481   webdriver::server       DEBUG   -> POST /session/39d05273-16c8-425e-9340-03f0e216297e/url {"url":"https://localhost:9005/"}
1537533165491   Marionette      DEBUG   [6442450945] Received DOM event beforeunload for about:blank
1537533165539   Marionette      DEBUG   [6442450945] Received DOM event beforeunload for about:blank
1537533165541   Marionette      DEBUG   [6442450945] Received DOM event pagehide for about:blank
1537533165573   Marionette      DEBUG   [6442450945] Received DOM event DOMContentLoaded for about:certerror?e=nssBadCert&u=https%3A//localhost%3A9005/&c=UTF-8&f=regular&d=%20
1537533165595   webdriver::server       DEBUG   <- 400 Bad Request {"value":{"error":"insecure certificate","message":"","stacktrace":"WebDriverError@chrome://marionette/content/error.js:178:5\nInsecureCertificateError@chrome://marionette/content/error.js:297:5\nhandleReadyState@chrome://marionette/content/listener.js:266:21\nhandleEvent@chrome://marionette/content/listener.js:239:9\n"}}
@andreastt
Copy link
Contributor

You can tell from the matched capabilities object that is returned that you have incorrectly configured the capability: acceptInsecureCerts":false

The capabilities object should look like this:

{
    "capabilities": {
        "alwaysMatch": {
            "acceptInsecureCerts": true
        }
    }
}

@andreastt
Copy link
Contributor

@alippai
Copy link
Author

alippai commented Sep 21, 2018

Well, this didn't help, I must miss something:

1537534307405   geckodriver     DEBUG   Listening on 127.0.0.1:9515
1537534313490   webdriver::server       DEBUG   -> POST /session {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"alwaysMatch":{"browser":"firefox","logLevel":"verbose","acceptInsecureCerts":true},"browserName":"firefox","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.13.2","name":"webdriverio"}}}
1537534313495   mozrunner::runner       INFO    Running command: "C:\\Program Files\\Firefox Nightly\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\ADAM~1.LIP\\AppData\\Local\\Temp\\rust_mozprofile.UvvLliopbhGK"
1537534313497   geckodriver::marionette DEBUG   Waiting 60s to connect to browser on 127.0.0.1:65109
1537534313931   Marionette      DEBUG   Received observer notification profile-after-change
1537534313990   Marionette      DEBUG   Received observer notification toplevel-window-ready
1537534314018   Marionette      DEBUG   Received observer notification command-line-startup
1537534314018   Marionette      DEBUG   Received observer notification nsPref:changed
1537534314018   Marionette      DEBUG   Init aborted (running=false, enabled=true, finalUIStartup=false)
1537534314157   Marionette      DEBUG   Received observer notification toplevel-window-ready
1537534314820   Marionette      DEBUG   Received observer notification sessionstore-windows-restored
1537534314820   Marionette      DEBUG   Waiting for delayed startup...
1537534314978   Marionette      DEBUG   Waiting for startup tests...
1537534314978   Marionette      DEBUG   Setting recommended pref security.turn_off_all_security_so_that_viruses_can_take_over_this_computer to true
1537534314978   Marionette      DEBUG   Setting recommended pref apz.content_response_timeout to 60000
1537534314979   Marionette      DEBUG   Setting recommended pref browser.download.panel.shown to true
1537534314979   Marionette      DEBUG   Setting recommended pref browser.pagethumbnails.capturing_disabled to true
1537534314980   Marionette      DEBUG   Setting recommended pref browser.search.update to false
1537534314980   Marionette      DEBUG   Setting recommended pref toolkit.cosmeticAnimations.enabled to false
1537534314980   Marionette      DEBUG   Setting recommended pref browser.tabs.disableBackgroundZombification to false
1537534314980   Marionette      DEBUG   Setting recommended pref browser.tabs.warnOnCloseOtherTabs to false
1537534314980   Marionette      DEBUG   Setting recommended pref browser.tabs.warnOnOpen to false
1537534314980   Marionette      DEBUG   Setting recommended pref browser.usedOnWindows10.introURL to
1537534314980   Marionette      DEBUG   Setting recommended pref browser.urlbar.suggest.searches to false
1537534314981   Marionette      DEBUG   Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
1537534314981   Marionette      DEBUG   Setting recommended pref dom.disable_beforeunload to true
1537534314981   Marionette      DEBUG   Setting recommended pref dom.disable_open_during_load to false
1537534314981   Marionette      DEBUG   Setting recommended pref dom.file.createInChild to true
1537534314981   Marionette      DEBUG   Setting recommended pref dom.max_chrome_script_run_time to 0
1537534314981   Marionette      DEBUG   Setting recommended pref dom.max_script_run_time to 0
1537534314981   Marionette      DEBUG   Setting recommended pref extensions.getAddons.cache.enabled to false
1537534314981   Marionette      DEBUG   Setting recommended pref extensions.webservice.discoverURL to http://%(server)s/dummy/discoveryURL
1537534314981   Marionette      DEBUG   Setting recommended pref network.http.prompt-temp-redirect to false
1537534314982   Marionette      DEBUG   Setting recommended pref network.http.speculative-parallel-limit to 0
1537534314982   Marionette      DEBUG   Setting recommended pref security.fileuri.strict_origin_policy to false
1537534314982   Marionette      DEBUG   Setting recommended pref security.notification_enable_delay to 0
1537534314982   Marionette      DEBUG   Setting recommended pref signon.autofillForms to false
1537534314982   Marionette      DEBUG   Setting recommended pref signon.rememberSignons to false
1537534315017   Marionette      INFO    Listening on port 65109
1537534315017   Marionette      DEBUG   Remote service is active
1537534315101   geckodriver::marionette DEBUG   Connection established on 127.0.0.1:65109. Waiting for Marionette handshake
1537534315104   Marionette      DEBUG   Accepted connection 0 from 127.0.0.1:65118
1537534315109   geckodriver::marionette DEBUG   Connected to Marionette
1537534315125   Marionette      TRACE   0 -> [0,1,"WebDriver:NewSession",{}]
1537534315165   Marionette      DEBUG   [6442450945] Frame script loaded
1537534315168   Marionette      DEBUG   [6442450945] Frame script registered
1537534315171   Marionette      TRACE   0 <- [1,1,null,{"sessionId":"7462450d-2645-40a9-a352-c59d95a36d15","capabilities":{"browserName":"firefox","browserVersion":"64.0a ... AppData\\Local\\Temp\\rust_mozprofile.UvvLliopbhGK","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true}}]
1537534315190   webdriver::server       DEBUG   <- 200 OK {"value":{"sessionId":"7462450d-2645-40a9-a352-c59d95a36d15","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"64.0a1","moz:accessibilityChecks":false,"moz:geckodriverVersion":"0.22.0","moz:headless":false,"moz:processID":17984,"moz:profile":"C:\\Users\\adam.lippai\\AppData\\Local\\Temp\\rust_mozprofile.UvvLliopbhGK","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","rotatable":false,"setWindowRect":true,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}
1537534315213   webdriver::server       DEBUG   -> POST /session/7462450d-2645-40a9-a352-c59d95a36d15/url {"url":"https://localhost:9005/"}
1537534315216   Marionette      TRACE   0 -> [0,2,"WebDriver:Navigate",{"url":"https://localhost:9005/"}]
1537534315233   Marionette      DEBUG   [6442450945] Received DOM event beforeunload for about:blank
1537534315283   Marionette      DEBUG   [6442450945] Received DOM event beforeunload for about:blank

@andreastt
Copy link
Contributor

Please look at your own log, you’re still passing the wrong input:

1537534313490   webdriver::server       DEBUG   -> POST /session {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"alwaysMatch":{"browser":"firefox","logLevel":"verbose","acceptInsecureCerts":true},"browserName":"firefox","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.13.2","name":"webdriverio"}}}

alwaysMatch does not go in the legacy desiredCapabilities object.

@alippai
Copy link
Author

alippai commented Sep 21, 2018

Oh, didn't know there is desiredCapabilities and capabilities as well, thanks!
Note for others: you have to upgrade to webdriverio 5.0

@andreastt
Copy link
Contributor

So maybe I should write some documentation about this, but geckodriver supports both the legacy Selenium style desiredCapabilities/requiredCapabilities objects as well as the standards-conforming capabilities object with alwaysMatch and firstMatch fields.

Selenium and WebDriverIO (which I don’t know) appear to be using the legacy object by default. In certain clients, such as the Selenium Java client, it may be impossible or very hard not to.

What geckodriver does when it receives the HTTP request body for a new session is that it first looks to see if there is a capabilities key. If there is, it assumes the request is standards-conforming and tries to deserialise what’s inside capabilities, such as parsing the alwaysMatch dicitonary (meaning “these things must be true for a session to be created”) and the firstMatch list (meaning “create a session for the first of these capabilities that matches”).

Then additionally geckodriver supports what is known as extension capabilities. This is moz:firefoxOptions, which specifies Firefox/geckodriver specific configuration, such as the binary location, log level, &c.

So in order to enable the acceptInsecureCerts capability you should be able to send:

{"desiredCapabilities": {"acceptInsecureCerts": true}}

As well as:

{"capabilities": {"alwaysMatch": {"acceptInsecureCerts": true}}}

Does that make sense?

@alippai
Copy link
Author

alippai commented Sep 21, 2018

Only the second one works in my config, the desiredCapabilities are ignored (as you see it in the logs)

@whimboo
Copy link
Collaborator

whimboo commented Sep 21, 2018

@alippai does that work with geckodriver 0.21.0?

@alippai
Copy link
Author

alippai commented Sep 21, 2018

I can try that next week. Using the new API is a nice workaround for me :) <3

@whimboo
Copy link
Collaborator

whimboo commented Sep 21, 2018

Yes please do so. I wonder if that might be a regression by my Serde patch for geckodriver. If you can also please provide a code snippet which exercises this code path. Thanks.

@alippai
Copy link
Author

alippai commented Sep 21, 2018

Sure, I'll do that.

@whimboo
Copy link
Collaborator

whimboo commented Sep 27, 2018

It is actually a regression in geckodriver. https://bugzilla.mozilla.org/show_bug.cgi?id=1494617 will take care of this, and we will release a new version soon.

@whimboo whimboo reopened this Sep 27, 2018
@whimboo whimboo changed the title DesiredCapabilities are ignored DesiredCapabilities and requiredCapabilities are ignored Sep 28, 2018
@whimboo
Copy link
Collaborator

whimboo commented Sep 28, 2018

I fixed it. Just wait for the next release of geckodriver, and use 0.21.0 for now. Thanks again for reporting.

@whimboo whimboo closed this as completed Sep 28, 2018
@whimboo
Copy link
Collaborator

whimboo commented Oct 4, 2018

FYI we just released geckodriver 0.23.0.

@lock
Copy link

lock bot commented Aug 16, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have run into an issue you think is related, please open a new issue.

@lock lock bot locked and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants