繁体   English   中英

如何使用Selenium WebDriver获取文本框值

[英]How to get textbox value using Selenium WebDriver

我正在使用Selenium库进行测试。

我有这个小代码:

Dim driver As New FirefoxDriver()
driver.Navigate().GoToUrl("C:\Users\Amodio\Desktop\HTMLPage1.htm")
driver.FindElement(By.Id("30")).SendKeys("1234")
MsgBox(driver.FindElement(By.Id("30")).Text)

问题是,在消息框中我看不到控件的值。

它可以正确发送密钥,但是在下一行中,代码无法捕获该值。

就像您在问题标题中说的那样,您想显示文本框的value

对于文本框, element.GetAttribute("value")是您想要的文本框,而不是element.Text

MsgBox(driver.FindElement(By.Id("30")).GetAttribute("value"))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM