This is a migrated thread and some comments may be shown as answers.

Clicking a link using Find methods.

1 Answer 86 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
SD
Top achievements
Rank 1
SD asked on 01 Jun 2010, 08:11 AM
Hi Guys, 

Pls refer to the attached image. 
Since the value of the txt is currently '7', the following will work with no issues: 
 Manager.ActiveBrowser.Find.ByContent<HtmlAnchor>("7").Click();

The thing is, the value ("7")  may change but I still want to click the same link. 
 As the id of an element may change from time to time, it's not a good practice to use Elements IDs...
 Manager.ActiveBrowser.Find.ById<HtmlAnchor>("dashboardForm:appAll").Click(); 

I've tried several other methods under Find and was not successful...
Manager.ActiveBrowser.Find.ByAttributes<HtmlAnchor>("value=all").Click();

Could you pls indicate what is is the preferred Find method to use if I wanted to find & click that link by it's Value (value= 'All') ?

Ta, 
SD. 






1 Answer, 1 is accepted

Sort by
0
Nikolai
Telerik team
answered on 01 Jun 2010, 09:15 AM
Hi SD,

 The reason that "Manager.ActiveBrowser.Find.ByAttributes<HtmlAnchor>("value=all").Click();" is not working is because as far as I see from the screen shot "Value" is not yet HTML attribute. In order for this to work as you wish this should be rewritten as so: Manager.ActiveBrowser.Find.ByAttributes<HtmlAnchor>("onclick=~clearFormHiddenParams").Click(); assuming there is only one html anchor with onclick attribute which value is starting with "clearForm...".

Here you can find useful samples on how to locate DOM elements: http://www.artoftest.com/support/webaii/topicsindex.aspx?topic=elementid

Kind regards,
Nikolai
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
SD
Top achievements
Rank 1
Answers by
Nikolai
Telerik team
Share this question
or