Micro Focus QTP (UFT) Forums
Do you think it professional QTP code ? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Do you think it professional QTP code ? (/Thread-Do-you-think-it-professional-QTP-code)



Do you think it professional QTP code ? - learnqtp - 06-21-2012

Hello

i am new to QTP and learning code. I try to implement some programming and try to test and it working fine but i don't know how much professional code it is and can i use during job ?

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.
============code ===
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")



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")

  msgbox(ValidPass)

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


IF IT IS NOT PROFESSIONAL CODE THEN HOW YOU WILL WRITE PROFESSIONAL CODE AND TRY TO UNDERSTAND INDUSTRIAL STANDARD.

THANK YOU VERY MUCH TO ALL OF YOU...