user1782799
user1782799

Reputation: 19

How to get label's text and pass it to a variable?

I would like to get a label value and pass it to a variable. Let's say I have:

<td class="label">
<label for="id5">**Text value**</label>

How can I pass string "Text value" to a variable? I tried:

string a = ie.Label(Find.ByFor("id5")).ToString();

but it doesn't get any value...

Upvotes: 1

Views: 670

Answers (1)

Mario S
Mario S

Reputation: 11955

You should use the Text-property (Gets the innertext of the element and the innertext of all the elements contained in the element.):

string a = ie.Label(Find.ByFor("id5")).Text;

Upvotes: 2

Related Questions