-1

i am new to QTP, i have a question regarding to Descriptive Programming, i want to update the Page url dynamically in the repository of the associated repository, when ever the page loads in the browser.

dim url,set_url

With Browser("Browser")
            url=    .GetROProperty("url")
            set_url= "title:='"&url&"'"
            MsgBox set_url
            .Page("title:='"&url&"'").Link("Home")
End With
Zain
  • 5,391
  • 11
  • 34
  • 34
  • I don't understand the question, descriptive programming is when you ***don't*** use the object repository (see [this question](http://stackoverflow.com/questions/2477519/what-is-descriptive-programming-in-qtp)). What exactly are you trying to do? – Motti Dec 30 '11 at 11:51
  • hi, forget about that, what i want is this that, i want to set the Page("url:='"&URL&"'") "URL" dynamically in the Page Object, but i am unable to do that. i have updated the code. Please help, it gave some error that page Obj doest supports this – Zain Jan 02 '12 at 05:19

2 Answers2

2

Yes, agree with Motti, DP(Descriptive Programming) is alternative to OR (Object Repository). If you are using DP, you do not need to add that object in OR

Community
  • 1
  • 1
Amol Chavan
  • 3,835
  • 1
  • 21
  • 32
  • hi, forget about that, what i want is this that, i want to set the Page("url:='"&URL&"'") "URL" dynamically in the Page Object, but i am unable to do that. i have updated the code. Please help, it gave some error that page Obj doest supports this – Zain Jan 02 '12 at 05:17
1

First of all you don't really need the URL to identify the page, a browser only has one Page object so using any description will do (e.g. Page("title:=.*"))

Looking at your code I see several problems:

  1. You have redundant single quotes ' around the URL.
  2. The title property isn't very likely to match the URL
  3. once you have descriptive programming you can't have a descendent from the object repository so you can't have Link("Home") under your page.

You should be using something like:

.Page("url:=" & url).Link("href:=.*home.*").Click
Motti
  • 110,860
  • 49
  • 189
  • 262
  • i want to make my script unified as i want to test the same scenarios different country languages, in that case the title becomes different(due to language translation) and is not understandable by the QTP, so want i want is to get the URL on run time and set that URL in the page Title. – Zain Jan 02 '12 at 10:42
  • While running this, .Page("url:=" & url).Link("href:=.*home.*").Click giving an error that Object doesn't support the property url .Page – Zain Jan 02 '12 at 11:04
  • dim url With Browser("Browser") url= .GetROProperty("url") .Page("url:=" & url) If .Link("Home").Exist Then MsgBox "home Link ","Home Link found on the Page" End If End With – Zain Jan 02 '12 at 11:05
  • I am doing something like this – Zain Jan 02 '12 at 11:05
  • AFAIK `Page` does support **url**, anyway as I said, you don't need to have a description for the page. – Motti Jan 02 '12 at 12:17
  • @Zain you can also parametrize the properties in the object repository. – Motti Jan 02 '12 at 12:18
  • next question was my that, but i am in a problem, whenever i want to parametrize the page url in repository, it is shown as disabled, how can i enable that? – Zain Jan 03 '12 at 08:11