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

Need to store a collection of links, and Click on them

3 Answers 60 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Federico
Top achievements
Rank 1
Federico asked on 26 Mar 2014, 08:11 PM
I am relatively new to test studio and i am trying to store a collection of links that i get from Find.AllByAttributes("id=
~linktext");

Then the idea is to click one from the list. Currently i am trying this code to get the last:

HtmlAnchor dellink= alllinks.Last();
dellink.Click();

I am having issues on creating the list containing the elements and then casting the link into the
HtmlAnchor... Any ideas?

Thanks and Regards.

3 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 27 Mar 2014, 02:04 PM
Hello Federico,

Here is how to create a list of HtmlAnchors:

IList<HtmlAnchor> list = ActiveBrowser.Find.AllByAttributes<HtmlAnchor>("id=~linktext");

Hope this helps.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Federico
Top achievements
Rank 1
answered on 27 Mar 2014, 06:23 PM
Hello Boyan,

Thanks for the code, actually I was using the find without the ActiveBrowser, the rest was pretty much the same. Still something interesting that happened was that the issue persisted even with the new code. It was present until I deleted the test case and pasted the code in a new test case, with a new coded step inside... After that it worked as charm.

Code:
IList<HtmlAnchor> l = ActiveBrowser.Find.AllByAttributes<HtmlAnchor>("id=~textlink");
HtmlAnchor dellink = l.Last();
dellink.Click();

Thanks again and Regards, 

Federico
0
Boyan Boev
Telerik team
answered on 01 Apr 2014, 08:19 AM
Hello Federico,

Thank you for informing us and I am really glad that the code works.

If you need further help, please let us know.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Federico
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Federico
Top achievements
Rank 1
Share this question
or