【问题标题】:How to get the 'text' value return from 'Textbox'?如何从“文本框”获取“文本”值返回?
【发布时间】:2023-04-05 17:52:01
【问题描述】:

我正在使用 White 编写脚本进行 UI 自动化测试。我需要从“文本框”获取实际的文本值返回。

我首先使用以下行搜索 TextBox,AutomationId ("vwSearched_Number") 表示实际的文本值(例如 123456)。我想获取此文本值 (123456) 返回以用于下一个方法。但该脚本失败并出现来自 Assert 验证的错误消息,这意味着没有返回“SearchedNumber”值。

  TextBox SearchedNumber = MainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("vwSearched_Number"));

   Assert.IsNotNull(SearchedNumber, "SearchedNumber is not valid");

【问题讨论】:

  • 您可能应该为您使用的语言添加一个标签,因为从问题中不清楚(至少对我来说)。
  • @Herms:它是 C#。不幸的是,我必须自己添加一些声望点。

标签: c# textbox white-framework


【解决方案1】:

似乎 MainWindow.Get() 函数正在返回一个 TextBox.. 所以 SearchedNumber.Text 应该可以得到你想要的。

【讨论】:

    猜你喜欢
    • 2012-06-04
    • 1970-01-01
    • 2021-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-28
    • 1970-01-01
    相关资源
    最近更新 更多