0
我想在我的实习生/ selenium/leadfoot测试正在运行的客户端浏览器中执行javascript。具体来说,我试图绕过IE8 & 9证书警告。Leadfoot绕过IE证书警告
以前,使用硒-python绑定,我可以使用此代码在所有浏览器上运行,通过警告,如果它发生了:
if "Certificate" in driver.title:
driver.get("javascript:document.getElementById('overridelink').click();")
现在使用leadfoot,我已经试过以下的多种组合:
.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();")
你什么错误? – Louis 2014-08-30 10:32:12
它为下面的'''.find()''语句提供了超时错误,似乎是在错误的上下文中执行的。 – lacy 2014-08-31 19:28:37
在您的问题中显示find语句以及您所得到的确切错误消息将是一件好事。另外,你是否检查浏览器上的控制台,看看是否有错误? – Louis 2014-08-31 20:46:19