QTP VERSION 10.
APPLICATION : Sample Application Flight which comes with QTP10.
Test Step:
-
Don't enter value and hit OK
-
Enter a hit OK
-
Enter Invalid Password and username and Hit OK
-
Enter correct password and username and validate next page.
First I need all the recording of contention and get all the pop message and validation message and create variable and get all the validation message in GETROPROPERTY and now using If then endIF condition and try to check validation message with Variable and execute step according to Validation message.
Problem
I got validation message for first step that "Enter Username and Password" now when i am trying to get another message which " Username must be 4 digit required" now this message and static page value is not in OBJECT REPOSTORY and even i try to add in it and it is consider as first step static value which enter username and password. now i try to add from active screen too but it is not working and even add textcheckpoint too something wrong with static value.
Here is code :
SystemUtil.Run"C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dim ValidTex ,ValidTex1,ValidPass,WronPass
Dialog("Login").WinButton("OK").Click
ValidTex = Dialog("Login").Dialog("Flight Reservations").Static("Please enter agent name").GetROProperty("text")
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
If ValidTex = "Please enter agent name" Then
Dialog("Login").WinEdit("Agent Name:").Set "a"
Dialog("Login").WinButton("OK").Click
ValidTex1 = Dialog("Login").Dialog("Flight Reservations").Static("Agent name must be at least 4 characters long.").GetROProperty("text")
msgbox(ValidTex1)
If ValidTex1 = "Agent name must be at least 4 characters long." Then
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinEdit("Agent Name:").Set "admin"
Dialog("Login").WinButton("OK").Click
ValidPass = Dialog("Login").Dialog("Flight Reservations").Static("Please enter password").GetROProperty("text")
If ValidPass = "Please enter password" Then
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinEdit("Password:").SetSecure "4fe23773f09965919fa8269a0927d143"
Dialog("Login").WinButton("OK").Click
WronPass = Dialog("Login").Dialog("Flight Reservations").Static("Incorrect password. Please try again").GetROProperty("text")
If WronPass = "Incorrect password. Please try again" Then
Dialog("Login").WinEdit("Password:").SetSecure "4fe2377997ce1b7724cfd7f10c577e2d50a391ab"
Dialog("Login").WinEdit("Password:").Type micReturn
Window("Flight Reservation").WinButton("Button").Click
End If
End If
End If
End If
Dialog("Login").WinEdit("Password:").SetSecure "4fe23773f09965919fa8269a0927d143"
Dialog("Login").WinEdit("Password:").Type micReturn
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Type micReturn