Leadfoot绕过IE证书警告

Leadfoot bypass IE certificate warning

本文关键字:警告 证书 IE 绕过 Leadfoot      更新时间:2023-09-26

我正试图在运行internet/selement/leadfoot测试的客户端的浏览器中执行javascript。具体来说,我试图绕过IE8&9证书警告。

以前,使用selenium-python绑定,我可以使用此代码在所有浏览器上运行,如果发生这种情况,会传递警告:

if "Certificate" in driver.title:
    driver.get("javascript:document.getElementById('overridelink').click();")

现在使用铅脚,我已经尝试了以下的许多组合:

.get(require.toUrl('https://secure-url.com')
.execute("document.getElementById('overridelink').click();")
// OR
.get("javascript:document.getElementById('overridelink').click();")

但无法在客户端上执行此javascript。有人在这方面取得了成功吗?

.execute('alert("hello");')

适用于其他页面,但不适用于此页面。就好像leadfoot无法在这个安全页面中运行JS,但selenium-api是吗?

最终它失败了,并出现错误:

JavaScriptError: [POST http://localhost:4444/wd/hub/session/1fa8a4a3-8774-46af-ad87-0e8fbc5a1388/execute / {"script":"document.getElementById('overridelink').click();","args":[]}] JavaScript error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 30 milliseconds
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'IE9Win7', ip: '169.254.0.207', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_67'
Session ID: 8b20796a-1d40-48ad-82e1-25ce16a40f17
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=0, ignoreZoomSetting=false, enablePersistentHover=true, ie.ensureCleanSession=false, browserName=internet explorer, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss, version=9, ie.usePerProcessProxy=false, cssSelectorsEnabled=true, ignoreProtectedModeSettings=false, requireWindowFocus=false, handlesAlerts=true, initialBrowserUrl=http://localhost:29797/, ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0, ie.browserCommandLineSwitches=, takesScreenshot=true}]
  at Server._post  <node_modules'intern'node_modules'leadfoot'Server.js:68:9>
...

此外,我可以在WebDriverIO中确认,我可以用绕过警告

client.url("javascript:document.getElementById('overridelink').click();")

我能够成功地浏览证书错误页面,方法是将键发送到选项卡,通过页面到覆盖链接,然后输入如下:

.pressKeys([Keys.TAB, Keys.TAB, Keys.TAB, Keys.ENTER])

显然,可能有更好的方法,但这是有效的。

示例:

        var command = this.remote;
        return command
            .get(require.toUrl('https://portal-stg.vpc.locusdev.net'))
            .getPageTitle()
            // IE Certificate Error Workaround
            .then(function(title) {
                if (title.indexOf('Certificate Error') !== -1) {
                    command.pressKeys([Keys.TAB, Keys.TAB, Keys.TAB, Keys.ENTER])
                }
                return true;
            })