I am new to QTP and am trying to use version 11 to automate my project.
Using descriptive programming, how QTP can find a link in a web page. The HTML for the link is written in the Onclick function (like onclick="navigationClick('Link Name');
)
I tried this:
If Browser(Browsername).Page(Pagename).Link("html tag:='Value',"id:=X","title:=Y","class:=Z").Exist(50)Then
Browser(Browsername).Page(Pagename).Link("html tag:='Value',"id:=X","title:=Y","class:=Z").click
Else
MsgBox "Link cannot be found"
But when i run the script, it always shows Link Cannot be found.
Note:
Using the same descriptive programming, i can able to find the link in the web page, if the HTML for the link is wrriten as OnClick='javascript.navigationClick(Link);"href='javascript:void(0);
Best Answer
On second reading of your question I think the problem is that the link you're trying to identify doesn't have an
href
. QTP does not consider links with nohref
to be real links. Perhaps if you try to use aWebElement
rather than aLink
the identification will succeed.Also note that QTP uses the
html id
property instead of the DOM'sid
.(my original answer follows)
You can access the
onclick
attribute by using theattribute/
syntax for accessing native DOM attributes.Note that descriptive programming uses regular expressions so you have to escape special characters (like the parentheses in this example).