Selenium 2.18.0 - 驱动程序初始化时出现 UnhandledAlertException,如何处理它?
我犯了错误,并将我的 pom.xml 更新为 selenium 2.18.0 现在,操作期间的 UnhandledAlertException 是新功能:
Firefox 和 IE 中的警报处理:如果操作期间出现警报,则抛出 UnhandledAlertException。未处理的警报也会被忽略,以减少重复异常。
但如果我调用
driver = new InternetExplorerDriver();
它会导致模态对话框出现异常,因为我当前的系统需要代理凭据,这些凭据由循环自动脚本填充(以防万一有人需要它):
Dim $arrTitle[2] = ["Authentification required", "Windows Security"]
While 1
For $sTitle In $arrTitle
If WinExists($sTitle) Then
WinActivate($sTitle);
Send("{HOME}");
Send("+{END}");
Send("{DEL}");
Send("user");
Send("{TAB}");
Send("{HOME}");
Send("+{END}");
Send("{DEL}");
Send("password");
Send("{ENTER}");
Sleep(1000)
EndIf
Next
Sleep(500)
WEnd
那么我该如何防止这个异常?如果我只是简单地
try { driver = new InternetExplorerDriver(); }
catch(UnhandledAlertException e) {}
收到一个 driver=null
感谢您的宝贵时间
I did the mistaked and updated my pom.xml to selenium 2.18.0
now the UnhandledAlertException during an operation is the new feature:
Alert handling in Firefox and IE: Throwing UnhandledAlertException if an alert is present during an operation. The unhandled alert is also dismissed to mitigate repeat exceptions.
but if i call
driver = new InternetExplorerDriver();
it results in Modal dialog present Exception, because my current system needs proxy credentials, which are filled by a looping auto-it script (just in case somebody needs it):
Dim $arrTitle[2] = ["Authentification required", "Windows Security"]
While 1
For $sTitle In $arrTitle
If WinExists($sTitle) Then
WinActivate($sTitle);
Send("{HOME}");
Send("+{END}");
Send("{DEL}");
Send("user");
Send("{TAB}");
Send("{HOME}");
Send("+{END}");
Send("{DEL}");
Send("password");
Send("{ENTER}");
Sleep(1000)
EndIf
Next
Sleep(500)
WEnd
So how can I prevent this exception? If I simply
try { driver = new InternetExplorerDriver(); }
catch(UnhandledAlertException e) {}
i will receive a driver=null
Thanks for your time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的系统需要代理凭据,您应该能够将其与您所需的功能一起传递到驱动程序中。
请参阅 http://code.google.com/p/selenium/wiki/DesiredCapability# Proxy_JSON_Object 关于使用什么。
If your system needs proxy credentials you should be able to pass this through with your desired capabilities into the driver.
see http://code.google.com/p/selenium/wiki/DesiredCapabilities#Proxy_JSON_Object on what to use.