Selenium Waits
Selenium高级功能包含查找等待, Selenium的查找等待有两种方式, 隐式等待(Implicit Waits)和显示等待(Explicit Waits): 这里写下我对两者的理解,
1. 隐式等待, 作用域全局, 在Web Driver 的整个生命周期都起作用, web driver的每一个操作,例如查找元素, 如果找不到对应元素就设置一个等待时间,在这个等待时间之内,每隔500毫秒就轮询一次,直至找到元素或是超时。
OpenQA.Selenium.Chrome.ChromeDriver _chrDriver = new OpenQA.Selenium.Chrome.ChromeDriver();
_chrDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds());
_chrDriver.Navigate().GoToUrl("http://www.baidu.com");
注:使用隐式等待会导致整个测试过程变的很慢。
2. 显示等待, 作用域当前操作, 设置一个超时时间和期待条件, 在这个超时时间只能,每隔500毫秒轮询,如果期待条件满足就返回, 直至超时。这个超时会抛异常出来的。
OpenQA.Selenium.Chrome.ChromeDriver _chrDriver = new OpenQA.Selenium.Chrome.ChromeDriver();
_chrDriver.Navigate().GoToUrl("http://www.baidu.com"); OpenQA.Selenium.IWebElement we = (new OpenQA.Selenium.Support.UI.WebDriverWait(_chrDriver,TimeSpan.FromSeconds())
.Until<OpenQA.Selenium.IWebElement>((d)=>{return d.FindElement(OpenQA.Selenium.By.Id("kw"));}));
we.SendKeys("Hello");
_chrDriver.Quit();
Selenium Waits的更多相关文章
- <译>Selenium Python Bindings 5 - Waits
如今,大多数的Web应用程序使用AJAX技术.当页面加载到浏览器,页面中的元素也许在不同的时间间隔内加载.这使得元素很难定位,如果在DOM中的元素没有呈现,它将抛出ElementNotVisibleE ...
- [译]Selenium Python文档:五、Waits等待
大多数现代web应用都使用了AJAX技术.当浏览器加载一个页面的时候,该页面内的元素可能在不用的时间间隔内进行加载.这使得元素定位变得比较困难:如果一个元素还没有出现在DOM中,定位函数将会抛出一个E ...
- Selenium - WebDriver: Waits
These days most of the web apps are using AJAX techniques. When a page is loaded to browser, the ele ...
- 25+ Useful Selenium Web driver Code Snippets For GUI Testing Automation
本文总结了使用Selenium Web driver 做页面自动化测试的一些 tips, tricks, snippets. 1. Chrome Driver 如何安装 extensions 两种方式 ...
- 转载 基于Selenium WebDriver的Web应用自动化测试
转载原地址: https://www.ibm.com/developerworks/cn/web/1306_chenlei_webdriver/ 对于 Web 应用,软件测试人员在日常的测试工作中, ...
- 【译】Selenium 2.0 WebDriver
Selenium WebDriver 注意:我们正致力于完善帮助指南的每一个章节,虽然这个章节仍然存在需要完善的地方,不过我们坚信当前你看到的帮助信息是精确无误的,后续我们会提供更多的指导信息来完 ...
- selenium高级用法
http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp# WebDriver: Advanced Usage Explicit and Im ...
- [译]Selenium Python文档:目录
作者:Baiju Muthukadan 协议:本文档采用知识共享署名 - 共享4.0国际许可. 原英文网址:http://selenium-python.readthedocs.io/index.ht ...
- requests+selenium==requestium模块介绍
有时,你可能会在网上实现一些自动化操作.比如抓取网站,进行应用测试,或在网上填表,但又不想使用API,这时自动化就变得很必要.Python提供了非常优秀的Requests库可以辅助进行这些操作.可惜, ...
随机推荐
- Hadoop常见错误及处理方法
1.Hadoop-root-datanode-master.log 中有如下错误: ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: jav ...
- SQL Server数据库(作业)
create datebase zuoye2gouse zuoyegocreate table student --学生表( Sno varchar(20) not null primary key, ...
- GridControl的用法(1)
一.属性设置 ①去除gridControl上的筛选条 //去除上面的筛选条 gridView1.OptionsView.ShowGroupPanel = false; ②设置列名 ...
- apache rewrite设置 禁止某个文件夹执行php文件
RewriteRule (data|templates)/(.*).(php)$ – [F]
- Python中的*args和**kwargs
原文地址:http://www.linuxidc.com/Linux/2011-10/45083.htm 先来看个例子: ,2,3,4) foo(a=1,b=2,c=3) foo(1,2,3,4, a ...
- CNAPS Code 查询(招商银行)
招商银行的妹子实在太傻了,根本不知道什么是CNAPS Code.联行号,完全答非所问. 最后还是自己搞定了,如图: 最后再看看招行人员的英语水平,真是不知道什么是东西:
- hdu 4630 No Pain No Game
http://acm.hdu.edu.cn/showproblem.php?pid=4630 离散化+树状数组 将数组 *a 从后向前遍历 遍历到 a[x] 的时候 再枚举a[x]的约数 假如 约数 ...
- redis2.8--c/s架构流程
- hdu 1035 (usage of sentinel, proper utilization of switch and goto to make code neat) 分类: hdoj 2015-06-16 12:33 28人阅读 评论(0) 收藏
as Scott Meyers said in his book Effective STL, "My advice on choosing among the sorting algori ...
- android selector详解
--> 改变字体的颜色<selector xmlns:android="http://schemas.android.com/apk/res/android"> ...