问题
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:
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");
来源:https://stackoverflow.com/questions/24016888/setting-input-textbox-text-and-then-retrieving-it-in-specflow-selenium