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

Using ActiveBrowser to Find and Click on a Link with a Variable Name

1 Answer 54 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 04 Sep 2012, 10:01 PM
Hi,

I need to use ActiveBrowser to find a link with a name that includes an extracted variable from a previous step.  The name is not an exact match with the variable, but has 1 letter that is different.  How can I use a coded step to find this variable link and perform an onclick on it?

1 Answer, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 05 Sep 2012, 12:45 PM
Hi Dan,
you state:
find a link with a name
I assume we're actually talking about a "name" attribute?

You'll have to use Find Expressions and it might look something like this:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/write-tests-in-code/intermediate-topics/element-identification/find-expressions.aspx

If so your code might look something like this:
searchWord = (String) this.GetExtractedValue("MyVariableName"); //Get extracted variable
HtmlAnchor a = Find.ByExpression<HtmlAnchor>("name=~"+searchWord);  //Look for link by using a "contains" condition for the name

I hope this helps. Let me know how it goes.

Greetings,
Stoich
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Dan
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Share this question
or