QTP code -Using Programmatic Descriptions

Sponsored Links:

Using Programmatic Descriptions to interact with a web page.

This example will illustrate how to use programmatic descriptions to interact with a web page, www.QTPHelper.com to be more exact...

Note that I've used a simple regular expression in the Browser and Page description, just in case the titles change in the future.

' click the Home link
Browser("Title:=QTP Helper.*").Page("Title:=QTP Helper.*").Link("Text:=Home").Click 

' check that the user isn't already logged in
If Browser("Title:=QTP Helper.*").Page("Title:=QTP Helper.*").WebButton("Name:=Logout").Exist(1Then

    ' click logout
    Browser("Title:=QTP Helper.*").Page("Title:=QTP Helper.*").WebButton("Name:=Logout").Click

End If ' user logged in

' set the username
Browser("Title:=QTP Helper.*").Page("Title:=QTP Helper.*").WebEdit("Name:=username").Set "User"

' set the password
Browser("Title:=QTP Helper.*").Page("Title:=QTP Helper.*").WebEdit("Name:=passwd").Set "Password"

' tick the remember-me tickbox
Browser("Title:=QTP Helper.*").Page("Title:=QTP Helper.*").WebCheckBox("Name:=remember").Set "ON"

Source: http://qtphelper.com

No comments: