I have page that has a link whose text is a name - say country name "India" ... I come to this page by a navigation from other page where I search for country and matched country names are shown as hyper links.
In the test I need to click on such a link.... Since the name is not constant, I will have do something to deal with this ... First avenue was to look for regular experssions ... As I understand you can use reg ex when you have a string that has some fixed string and some variable as in "Welcome <name of the person> ".... My case is an extreeme .. no constant portion - the link name (obj rep name is completely dyanamic)
Next avenue is to look for using Description .. I looked at runtime properties that could possibly be used ..I need to get such a property whose value is not shown as link text(which varies depending upon the name) but something that programmer uses or has specified for the link object ...
What are the properties that fit such constraint ... ID, Index, innertext, outertext, outerhtml, inner html and so on ... This link that I am trying to crack has all these properties as blank.
One strange thing that happened is when I was executing a test with this link, QTP managed to click on "Russia" when the link name in the code executed was "France" ... when I looked at results -- I saw that "smart identification" was invoked to click on this link. But when I ran the same script again .... QTP could not recognize "Russia" and displayed error Link "France" could not be located.
Any views on how to handle such link where link text is variable, no other property could be used in DP and Smart identification works ON and OFF (not consistently)
The catch here is ... the name is linked to a code I do a serch for a name of the country using a code. The code is typically expected to return only one value when searched.
I would like to parameterise the search code so that any code can be searched. Another catch is that mapping between code and country name can be changed and there is no one general mapping between code and country.
>>> Now since you are running the test with some logic you should know at least at run-time which link to click. You store the value in variable x at run-time (you should know how to do it).
Unfortunately, there is no way to fetch the value of the variable x before I attempt to click on it
how about this ?
Let us query the parent object (webelement or some table cell) and get hold of child object array (here I dont need to know the details of the link - name, text etc).
In the child array I know that there is only one link.
I can suggest also two ideas:
<ul type="square">[*]You still can use Regular Expressions [img]/images/graemlins/smile.gif[/img]
For example, if you know that the name of link can be one of the following - "India", "Russia", "China", "USA", then RegExp can be:
[*]If you don't know the name of link, you can use Output Text Value. I explained it in my QTP video: QTP video tutorial - How to capture dynamic text in QTP?[/list]
I hope, these pieces of advice will be helpfull for you...