QTP - 15 (Synchronization) 同步问题
Writer : Tarun Lalwani
怎样等待此页面加载完再执行测试步骤?这就是同步的问题:
主题1:
Synchronization Points: when application take time torespond your action. Being used to pause or wait time.
Three types of Synchronization Points:
1st Method – Using the Sync method: there are nodifference between Sync on browser and page.
Browser(“..”).Sync
But sometimes itself throw an error, use On Error resumenext constructs should be used as below
On Error Resume Next
Browser(“..”).Sync
On Error Goto 0
2nd Method – Using the wait statement
wait 2
3rd Method – waitProperty method
Browser(“..”).Page(“..”).WebButton(“Next”).waitProperty(“Enabled”,True, 5000) ‘wait 5s max to button enable.
In case the object not exist before the operation starts “
Browser(“..”).Page(“..”).WebButton(“Next”).Exist(20)
主题2:
Events: there maybe synchronization does not help, becauseof events not fired!
DP 时常用。
E.g only you input the webEdit, then OK button enabled.
方法一:代码firethe events:(可以查看event录制时是否支持ToolsàWeb Event RecordingConfiguration… and click the Custom Settings)
You need the code what event included, if you don’t know youcan fire all events:
Browser(“..”).Page(“..”).WebEdit(“..”).FireEvent “onkeydown”
Browser(“..”).Page(“..”).WebEdit(“..”).FireEvent “onkeyup”
Browser(“..”).Page(“..”).WebEdit(“..”).FireEvent“onkeypress”
方法二:设置Replaysetting, 不以eventfire, 用mousefire:
Tools-->Options…-->Web-->Advanced..and Replay Type radio value as Mouse.