Setting input textbox text and then retrieving it in Specflow & Selenium

爱⌒轻易说出口 提交于 2019-12-12 02:22:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!