Click here to Skip to main content
Click here to Skip to main content

Tagged as

Useful function to get and compare runtime URLs using QTP - vbs

, 30 Sep 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
This article helps in getting the runtime URL and compare with user defined, if that is correct it logs into the application otherwise exits the application
When you are automating your application using QTP, you might have to deal with multiple URLs handling, i.e., if your application is deployed on multiple servers/environments every time you ran a script, it has to be configured with correct credentials.
 
Here is a quick function that can be applicable in all such conditions. Make a VBS file, set the login credentials, i.e., username and password and make a function call.
 
Public Function FunctionName() //Function Declaration

browserURL=Browser("title:=http.*://.*Login.aspx.*").Page("url:=http.*://.*Login.aspx.*").GetROProperty("URL")  //Gets the runtime URL and assign the value in the variable

Browser("title:=http.*Login.aspx.*").Page("url:=http.*Login.aspx.*").Image("File name:=login_btn.png").Click //Click on the Login button

wait 10
 
If instr(browserURL, "Dashboard") > 0 Then // Conditional statement that checks the variable value with the user defined value  (Use first page name)
Reporter.ReportEvent micPass, "Login success", "Correct credentials. Authenticated successfully"
				
Elseif(Browser("title:=http.*Login.aspx.*").Exist(05)) then 
Reporter.ReportEvent micFail, "Invalid / Wrong credentials", "Incorrect credentials. Authentication Failed"
 
Browser("title:=http.*://.*Login.aspx.*").close
ExitTest //Exits the test
End If
 
End Function
 
Hope it helps. Happy scripting Smile | :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ria mazhar
Tester / Quality Assurance
Pakistan Pakistan
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 30 Sep 2011
Article Copyright 2011 by ria mazhar
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid