The following example will demonstrate, why synchronization is necessary in many situations.
Option Explicit
Dim orderNo, mypath
mypath = Environment( "ProductDir" ) & "\samples\flight\app\" ' ProductDir is In-built environment variable
SystemUtil.Run "flight4a.exe", "", mypath,"open"
If Dialog("Login").Exist( 2000 ) Then ' A way of synchronization
Dialog("Login").WinEdit("Agent Name:").Set "Abhikansh"
Dialog("Login").WinEdit("Password:").Set "Mercury"
Dialog("Login").WinButton("OK").Click
wait 1
Else
Reporter.ReportEvent micFail, "Synchronization time-out", "Login dialog is not dispalyed"
ExitTest( "your test name" ) ' it is the name of your QTP Test
End If
If Not Window("Flight Reservation").Exist( 2000 ) Then
Reporter.ReportEvent micFail, "Synchronization time-out", "Flight Reservation window is not dispalyed"
ExitTest( "your test name" ) ' it is the name of your QTP Test
End If
With Window("Flight Reservation")
.WinButton("Button").Click
.ActiveX("MaskEdBox").Type "010112"
.WinComboBox("Fly From:").Select "London"
.WinComboBox("Fly To:").Select "Los Angeles"
.WinButton("FLIGHT").Click
.Dialog("Flights Table").WinButton("OK").Click
.WinEdit("Name:").Set "Abhikansh"
.WinEdit("Tickets:").SetSelection 0,1
.WinEdit("Tickets:").Set "2"
.WinRadioButton("First").Set
.WinButton("Insert Order").Click
'.ActiveX("Threed Panel Control").WaitProperty "text", "Insert Done...", 2000 -
orderNo = Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")
MsgBox orderNo, vbInformation, "Order Number"
End With
As there is no sychronization after WinButton("Insert Order").Click , it will display blank message box, which is incorrect!
Think if you are paasing this number to other tests as argument, you might end-up with peculier results.
Now just uncomment this line in above code, and see the difference..
.ActiveX("Threed Panel Control").WaitProperty "text", "Insert Done...", 2000
As we can see in this example, synchronization is required here.
Synchronization points must be used whenever its necessary.
Following are different ways of synchronization :-
1. Exist property 'used above
2. WaitProperty 'used above
3. Wait 'used above
For further information, please post your comments. I'll try to cover all your queries in further posts.
Option Explicit
Dim orderNo, mypath
mypath = Environment( "ProductDir" ) & "\samples\flight\app\" ' ProductDir is In-built environment variable
SystemUtil.Run "flight4a.exe", "", mypath,"open"
If Dialog("Login").Exist( 2000 ) Then ' A way of synchronization
Dialog("Login").WinEdit("Agent Name:").Set "Abhikansh"
Dialog("Login").WinEdit("Password:").Set "Mercury"
Dialog("Login").WinButton("OK").Click
wait 1
Else
Reporter.ReportEvent micFail, "Synchronization time-out", "Login dialog is not dispalyed"
ExitTest( "your test name" ) ' it is the name of your QTP Test
End If
If Not Window("Flight Reservation").Exist( 2000 ) Then
Reporter.ReportEvent micFail, "Synchronization time-out", "Flight Reservation window is not dispalyed"
ExitTest( "your test name" ) ' it is the name of your QTP Test
End If
With Window("Flight Reservation")
.WinButton("Button").Click
.ActiveX("MaskEdBox").Type "010112"
.WinComboBox("Fly From:").Select "London"
.WinComboBox("Fly To:").Select "Los Angeles"
.WinButton("FLIGHT").Click
.Dialog("Flights Table").WinButton("OK").Click
.WinEdit("Name:").Set "Abhikansh"
.WinEdit("Tickets:").SetSelection 0,1
.WinEdit("Tickets:").Set "2"
.WinRadioButton("First").Set
.WinButton("Insert Order").Click
'.ActiveX("Threed Panel Control").WaitProperty "text", "Insert Done...", 2000 -
orderNo = Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")
MsgBox orderNo, vbInformation, "Order Number"
End With
As there is no sychronization after WinButton("Insert Order").Click , it will display blank message box, which is incorrect!
Think if you are paasing this number to other tests as argument, you might end-up with peculier results.
Now just uncomment this line in above code, and see the difference..
.ActiveX("Threed Panel Control").WaitProperty "text", "Insert Done...", 2000
As we can see in this example, synchronization is required here.
Synchronization points must be used whenever its necessary.
Following are different ways of synchronization :-
1. Exist property 'used above
2. WaitProperty 'used above
3. Wait 'used above
For further information, please post your comments. I'll try to cover all your queries in further posts.
For syncronisation or wait to loads a page following code can be used..
ReplyDeleteBrowser("").Page("").Waitproperty "loading" , "completed"
Machine Learning Projects for Final Year machine learning projects for final year
DeleteDeep Learning Projects assist final year students with improving your applied Deep Learning skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include Deep Learning projects for final year into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Deep Learning Projects for Final Year even arrange a more significant compensation.
Python Training in Chennai Project Centers in Chennai
Thanks Ashi for the way you found to load a page.
ReplyDeleteAdvertising is your main tool to have the business ready to go. Actually, everybody is busy in their company marketing over the World Wide Web. Unfortunately, online company is scammed with scammers. On occasion the provider hires you freelance, or occasionally it is a site designer which orders the copy google At an identical time, if you decide on the most suitable company having excellent reviews and reputation, you will enjoy well composed works.
ReplyDeletehttp://google.com/
Wow, thank you. I needed to write such code for a college, but I'm really bad at this thing. So I googled until I found your post) Thank you so much. Maybe I won't gate A or B, but at least I can have D and close that stupid course.
ReplyDeleteThank you so much! This is the best essay help ever! I will check your other posts.
ReplyDeleteVery interesting article, I really like what shering comrades on this page.
ReplyDeletePhd Dissertation Writing Services
This looks absolutely perfect. All these tiny details are made with lot of background knowledge. I like it a lot.
ReplyDeleteThat was a great message in my carrier, and It's wonderful commands like mind relaxes with understand words of knowledge by information's.
Sql server dba online training