c# - 如何使用 Selenium 从这段代码中获取值(value)?

标签 c# asp.net selenium testing

我希望这个值 201607000044 成为这段代码的字符串 -

<SPAN id=ctl00_ctl00_ctl00_ctl00_ContentPlaceHolderCenter_ContentPlaceHolderBody_ContentPlaceHolderBody_ContentPlaceHolderBody_txtNumber class=inputBold style="WIDTH: 200px; DISPLAY: inline-block">201607000044</SPAN>

因为这行不通-

IWebElement notificationNumberElement = FindElementById("ctl00_ctl00_ctl00_ctl00_ContentPlaceHolderCenter_ContentPlaceHolderBody_ContentPlaceHolderBody_ContentPlaceHolderBody_txtNumber");
        string notificationNumber = notificationNumberElement.GetAttribute("value");

最佳答案

值为文本。可以通过Text成员(member)

获取
string notificationNumber = notificationNumberElement.Text;

关于c# - 如何使用 Selenium 从这段代码中获取值(value)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38496208/

相关文章:

c# - 使用 Selenium for C# 登录 Facebook

c# - 包含未从Nest返回的同义词的结果

asp.net - 使用 R 将更多帖子从 RSS feed 提取到 CSV

c# - Selenium EventFiringWebDriver 导航事件

python - 什么是 python 的 useAutomationExtension for selenium?

asp.net - session 总是超时

c# - 如何在 C# 中序列化/反序列化不可变列表类型

c# - MVC 3 中带有 LINQ 表达式的自定义 html 助手

c# - 套接字自动关闭

asp.net - "The connection string specifies a local Sql Server Express instance",但事实并非如此