QTP中与时间同步点:Sync、Wait、Waitproperty、Exist
来源:互联网 发布:湿热一瞬间新域名 编辑:程序博客网 时间:2024/05/16 01:19
同步点是QTP是很重要的一部分。常用的同步点方法有以下几种:
1)Sync方法;
2)WaitProperty方法;
3)Wait方法;
4)Exist方法;
1)Sync方法;
2)WaitProperty方法;
3)Wait方法;
4)Exist方法;
1)Sync
只有browse和page对象具有Sync方法,其它的对象都不具有该方法,那么browse.sync和page.sync有什么区别呢?
browse.sync表示等待浏览器加载完成后进行下一步操作,浏览器加载完成的标志是浏览器显示左下角显示完成字样。
page.sync表示页面中所有的元素都已加载完成后,进入下一步的操作。
语法:object.Sync
示例:
Sub Sync_Example()
'The following example uses the Sync method to wait for the
'Mercury Tours page to synchronize.
before performing the next operation.
Browser("Mercury Tours").page("Mercury Tours").Sync
End Sub
2)WaitProperty
等待指定对象属性获得指定值或超出指定超时后再继续下一步。如果属性获得该值则返回 TRUE,如果在属性获得该值之前发生超时则返回 FALSE(注意:FALSE 返回值不表示步骤失败)
语法:object.WaitProperty (PropertyName, PropertyValue, [lTimeOut])
示例1:
Sub WaitProperty_Example()
'The following example uses the WaitProperty method to wait for the
'All kind of link's readyState to be complete or for
'4 seconds (4000 milliseconds) to pass, whichever comes first.
'If the link achieves this value before 4000 milliseconds pass,
'QuickTest clicks the link.
只有browse和page对象具有Sync方法,其它的对象都不具有该方法,那么browse.sync和page.sync有什么区别呢?
browse.sync表示等待浏览器加载完成后进行下一步操作,浏览器加载完成的标志是浏览器显示左下角显示完成字样。
page.sync表示页面中所有的元素都已加载完成后,进入下一步的操作。
语法:object.Sync
示例:
Sub Sync_Example()
'The following example uses the Sync method to wait for the
'Mercury Tours page to synchronize.
before performing the next operation.
Browser("Mercury Tours").page("Mercury Tours").Sync
End Sub
2)WaitProperty
等待指定对象属性获得指定值或超出指定超时后再继续下一步。如果属性获得该值则返回 TRUE,如果在属性获得该值之前发生超时则返回 FALSE(注意:FALSE 返回值不表示步骤失败)
语法:object.WaitProperty (PropertyName, PropertyValue, [lTimeOut])
示例1:
Sub WaitProperty_Example()
'The following example uses the WaitProperty method to wait for the
'All kind of link's readyState to be complete or for
'4 seconds (4000 milliseconds) to pass, whichever comes first.
'If the link achieves this value before 4000 milliseconds pass,
'QuickTest clicks the link.
If Browser("index").Page("index").Link("All kind of").WaitProperty("attribute/readyState", "complete", 4000) Then
Browser("index").Page("index").Link("All kind of").Click
End If
End Sub
示例2:
Sub WaitProperty_Example()
'The following example uses the WaitProperty method to wait for the
'Account edit box to be enabled before setting its value to 123.
'If it is still disabled after the test's
'Object Synchronization Timeout time has been exceeded, it will not
'perform. the Set method.
Browser("index").Page("index").Link("All kind of").Click
End If
End Sub
示例2:
Sub WaitProperty_Example()
'The following example uses the WaitProperty method to wait for the
'Account edit box to be enabled before setting its value to 123.
'If it is still disabled after the test's
'Object Synchronization Timeout time has been exceeded, it will not
'perform. the Set method.
If Browser("index").Page("index").WebEdit("Account").WaitProperty("disabled", 0) Then
Browser("index").Page("index").WebEdit("Account").Set ("123")
End If
End Sub
Browser("index").Page("index").WebEdit("Account").Set ("123")
End If
End Sub
3)wait
wait函数,当脚本走到wait函数时,就开始执行这个函数.如:wait(10),就等待10秒种后再继续执行下面的语句.wait函数的这个等待的时间,那相对来说是固定的,可能造成时间的浪费,或者等待时间的不足.
4)Exist
检查对象当前是否存在于打开的应用程序中。返回一个Boolean 值。
语法:object.Exist([TimeOut])
示例:
Sub Exist_Example()
'The following example uses the Exist method to determine the
'existence of the "Mercury Tours" browser. If the object exists,
'a message box appears confirming its appearance.
If Browser("Mercury Tours").Exist Then
MsgBox "The browser exists."
End If
End Sub
在项目中根据不同的需要选择适合的函数或方法。
MsgBox "The browser exists."
End If
End Sub
在项目中根据不同的需要选择适合的函数或方法。
0 0
- QTP中与时间同步点:Sync、Wait、Waitproperty、Exist
- QTP中与时间同步点:Sync、Wait、Waitproperty、Exist
- QTP中与时间同步点:Sync、Wait、Waitproperty、Exist
- QTP中Wait与同步点的区别
- QTP 同步点设置
- QTP 同步点
- QTP 同步点设置
- QTP同步点方法
- java同步中wait 与 notify
- 多线程同步中sleep与wait区别
- QTP 中的同步点说明
- QTP有哪些同步点?
- QTP中时间的处理
- sleep与wait异同点
- linux 同步IO: sync、fsync与fdatasync
- 3.13 sync函数-文件缓存与同步
- linux 同步IO: sync、fsync与fdatasync
- linux 同步IO:sync、fsync与fdatasync
- iOS开发_iPhone 实现剪贴板操作_iPhone 复制粘贴功能
- 栈及实现(C语言)以及中缀式到后缀式的转换实例
- 代码静态分析工具 --- CppCheck
- c++引用的总结
- android动态注册广播,监听网络状态变化,判断网络模式
- QTP中与时间同步点:Sync、Wait、Waitproperty、Exist
- IOS中的单例模式
- 构造函数和析构函数
- 线段树区间更新
- 打开动态缓存图层时,即使将图层设置为透明,背景仍然为黑色。(服务器操作系统为windows server 2003)
- Codeforces 618C Constellation
- hdu 2807 The Shortest Path(最短路)
- 支付宝获取私钥和公钥
- TED-如何系列