Click here to Skip to main content
13,398,516 members (35,098 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


Posted 29 Sep 2011

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

, 30 Sep 2011
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"

ExitTest //Exits the test
End If

End Function

Hope it helps. Happy scripting :)


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


About the Author

ria mazhar
Tester / Quality Assurance
Pakistan Pakistan
No Biography provided

You may also be interested in...

Comments and Discussions

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