firefox - 如何为 geckodriver 设置空手道浏览器功能 acceptInsecureCerts:true
问题描述
我尝试通过这种方式为我的空手道测试设置我的 geckodriver 的功能。我正在使用 karate.version 0.9.6 这是 geckodriver 驱动程序:64 位 Windows:https ://github.com/mozilla/geckodriver/releases/tag/v0.29.1 firefox 版本 89.0.2(64 位)
def session = {能力:{acceptInsecureCerts:true,browserName:'firefox',代理:{proxyType:'manual',httpProxy:'127.0.0.1:8080'}}}
配置驱动程序= {类型:'geckodriver',showDriverLog:true,可执行文件:'driver/geckodriver.exe',webDriverSession:'#(session)'}
但是,它显然没有选择我的设置。
这是我的日志:
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"}}}
我的目的是围绕这个安全检查页面。 在此处输入图像描述
此外,即使我尝试单击该安全检查页面中的该按钮,当我执行以下操作时,我的脚本也无法从 dom 树中获取按钮。
And click('button[id=advancedButton]')
And click('button[id=exceptionDialogButton]')
解决方案
它可能与此有关:KarateUI: How to Handle SSL Certificate during geckodriver configuration? 我添加了 alwaysMatch,它能够获得这些功能。
* def session = { capabilities: {alwaysMatch:{ acceptInsecureCerts:true, browserName: 'firefox' }}}
* configure driver = { type: 'geckodriver', showDriverLog: true , executable: 'driver/geckodriver.exe', webDriverSession: '#(session)' }
推荐阅读
- c# - 在 ListBox WPF 中默认选择 2 个或更多项目
- java - 重新打开android应用程序时SQLlite表为空
- r - 如何根据字符串绑定列
- javascript - 在 React 中渲染选择
- python - 按年份和 total_vehicles 熊猫数据框求和
- netbeans-8 - 我想在我的代码中添加 GPA 但不幸的是没有工作
- javascript - 使用 URL 参数强制语言切换
- android - Android - 如何将文本视图附加到另一个文本视图的末尾?
- vim - 如何在 vim 中更改特定的“主题”颜色
- python - python scrapy从多个解析函数构建相同的项目:在循环中调用第二个解析函数