How to set up Karate browser capabilities acceptInsecureCerts:true for geckodriver

Viewed 221

I tried this way to set up the capabilities of my geckodriver for my karate tests. I am using karate.version 0.9.6 Here is the geckodriver driver: 64bit windows: https://github.com/mozilla/geckodriver/releases/tag/v0.29.1 firefox Version 89.0.2 (64-bit)

  • def session = { capabilities: { acceptInsecureCerts:true, browserName: 'firefox', proxy: { proxyType: 'manual', httpProxy: '127.0.0.1:8080' } } }

  • configure driver = { type: 'geckodriver', showDriverLog: true , executable: 'driver/geckodriver.exe', webDriverSession: '#(session)' }

However, it obviously not picking up my settings.

Here is my log:

1 > User-Agent: Apache-HttpClient/4.5.12 (Java/1.8.0_41)
{"capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","proxy":{"proxyType":"manual","httpProxy":"127.0.0.1:8080"}}}

13:25:13.121 [geckodriver_1626121511819-out] DEBUG c.i.k.d.geckodriver_1626121511819 - 1626121513121    mozrunner::runner   INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\xxxxx\\AppData\\Local\\Temp\\rust_mozprofiledFOSxn"
13:25:16.428 [geckodriver_1626121511819-out] DEBUG c.i.k.d.geckodriver_1626121511819 - 1626121516428    Marionette  INFO    Marionette enabled
13:25:20.065 [geckodriver_1626121511819-out] DEBUG c.i.k.d.geckodriver_1626121511819 - console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at C:\\Users\\xxxxx\\AppData\\Local\\Temp\\rust_mozprofiledFOSxn\\search.json.mozlz4", (void 0)))
13:25:20.368 [geckodriver_1626121511819-out] DEBUG c.i.k.d.geckodriver_1626121511819 - console.error: Region.jsm: "Error fetching region" (new TypeError("NetworkError when attempting to fetch resource.", ""))
13:25:20.369 [geckodriver_1626121511819-out] DEBUG c.i.k.d.geckodriver_1626121511819 - console.error: Region.jsm: "Failed to fetch region" (new Error("NO_RESULT", "resource://gre/modules/Region.jsm", 419))
13:25:20.960 [geckodriver_1626121511819-out] DEBUG c.i.k.d.geckodriver_1626121511819 - 1626121520961    Marionette  INFO    Listening on port 58400
13:25:21.071 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - response time in milliseconds: 7997.52
1 < 200
1 < cache-control: no-cache
1 < content-length: 712
1 < content-type: application/json; charset=utf-8
1 < date: Mon, 12 Jul 2021 20:25:13 GMT
{"value":{"sessionId":"b17123ef-1426-45d2-827b-adbc35b02e46","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"89.0.2","moz:accessibilityChecks":false,"moz:buildID":"20210622155641","moz:geckodriverVersion":"0.29.1","moz:headless":false,"moz:processID":36360,"moz:profile":"C:\\Users\\wli2\\AppData\\Local\\Temp\\rust_mozprofiledFOSxn","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}

My purpose is to circle around this security check page. enter image description here

Also, even if I tried to click that button in that security check page, my script is not able to get the buttons from the dom tree when I do the following.

And click('button[id=advancedButton]')
And click('button[id=exceptionDialogButton]')
2 Answers

it might be related with this : KarateUI: How to Handle SSL Certificate during geckodriver configuration? I added the alwaysMatch in and it is able to pick up the capabilities.

 * def session = { capabilities: {alwaysMatch:{ acceptInsecureCerts:true, browserName: 'firefox' }}}
    * configure driver = { type: 'geckodriver', showDriverLog: true , executable: 'driver/geckodriver.exe',   webDriverSession: '#(session)'  }

This is an area that may require you to do some research and contribute findings back to the community. Finally Karate passes the capabilities you define "as-is" to the driver. One thing that you should look at is if any command-line sessions should be passed to geckodriver - for example for Chrome, I remember there is some flag for ignoring these security errors. Note that you can use the addOptions flag in the Karate driver options.

Related