硒webdrive和检查警报消息 [英] selenium webdrive and checking alert messages

查看:201
本文介绍了硒webdrive和检查警报消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我解析我的网页与,我与处理的来。但是,这是非常缓慢的,检查每一页,如果有JS警报弹出消息becouse所有的人都没有。如何使这个速度更快becouse现在只需超过1s每cheking时间更多。



检查JS警报弹出硒webdrive


$ B码$ b

 
{
webDriver.SwitchTo()警报()接受()。 //准备硒处理警报
}
赶上(NoAlertPresentException E)
{
//没有警报消息
}


解决方案

一个未来增强的webdriver会抛出异常的任何命令,如果警报存在。



的当前实现SWITCHTO的()。警报()导致一个小的睡眠延迟,因为它必须等待浏览器传播的事件的警报窗口出现( IIRC它是300毫秒)。



有关,现在你有什么是当你不知道做了肯定,如果警报会出现在页面上你最好的选择。在未来,你应该能够赶上了没有建在延迟常规命令一个不同的异常。


I am parsing my page with selenium and i am handling javascript alert messages with selenium to. But this is very slow to check every page if it has JS alert popup message becouse all of them doesn't. How to make this faster becouse now takes more than 1s for every cheking time.

code for checking JS alert popup with selenium webdrive

try
{
webDriver.SwitchTo().Alert().Accept(); // prepares Selenium to handle alert 
}
catch (NoAlertPresentException e)
{
// no alert message
}

解决方案

A future enhancement to webdriver will be to throw an exception on any command if an alert is present.

The current implementation of SwitchTo().Alert() causes a small sleep delay because it has to wait for the browser to propagate the events for the alert window to appear (IIRC it's 300ms).

For now what you have is your best bet for when you don't know for sure if an alert will appear on the page. In the future you should be able to catch a different exception for regular commands that don't have the delay built in.

这篇关于硒webdrive和检查警报消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆