如何使用Selenium和C#获取文本输入的值? [英] How can one get the value of a text input using Selenium with C#?
本文介绍了如何使用Selenium和C#获取文本输入的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 Selenium for .NET ,如何获得来自html输入的当前值?
Using Selenium for .NET, how can I get the current value from a html input?
可以 .GetAttribute()
来获取 value
属性,但这是html属性,而不是在文本框中输入的当前值;与jQuery的 .val()
类似,而不是jQuery的 .attr()
。
It's possible to .GetAttribute()
to get the value
attribute but this is the html attribute rather than the current value entered into the text box; an approach similar to jQuery's .val()
rather than jQuery's .attr()
.
推荐答案
Element.Text
对我不起作用。我使用了 element.GetAttribute( value)
Element.Text
didn't work for me. I used element.GetAttribute("value")
查看此Q& A
设置输入文本框文本,然后在Specflow&硒
Check out this Q&A Setting input textbox text and then retrieving it in Specflow & Selenium
这篇关于如何使用Selenium和C#获取文本输入的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文