3

Could someone explain to me why in the following .Net Specflow code if my textboxElement's text is empty, then I send keys to it, why is text still empty? (when on screen the textbox's text changes):

textboxElement.SendKeys("John Smith");
var text = textboxElement.Text;
// text == ""

Is it not possible to "refresh" the value of an element? (or have I just missed something really obvious :-))

1
  • 3
    You'll want to use textBoxElement.GetAttribute("value");. It's an input element. input elements don't usually store their displayed text like other elements, but rather in their value properties. Commented Jun 3, 2014 at 14:23

1 Answer 1

19

Since it's an input element, you'll need to get it's value property as opposed to it's text.

So:

textBoxElement.GetAttribute("value");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.