【问题标题】:RFT get .text value from Html.SELECT and compare with a reg expRFT 从 Html.SELECT 获取 .text 值并与 reg exp 进行比较
【发布时间】:2015-04-01 00:06:41
【问题描述】:

我需要从我的应用程序中识别 Html.SELECT 对象并选择它。 我成功地做到了这一点,但现在我不能在我的代码中写出整个 .text 字符串,因为它是所有位置的长列表。 如何提取该值并将其与正则表达式进行比较。 例如 - .text 是 District................................................. .....

我想要一个字符串变量作为 District.* 在下面的代码中,我需要字符串名称作为正则表达式

SelectMCASDistrict("District.*");

public static void SelectMCASDistrict(String name)
{
   GuiTestObject textObj = findTextObjectDist(name);
   if (textObj != null) {

    ((SelectGuiSubitemTestObject) textObj).select("Abington.*");
     } else {
       throw new ObjectNotFoundException();
   }
} 


private static GuiTestObject findTextObjectDist(String name)
{

    TestObject[] tobs = find(atDescendant(".class", "Html.SELECT", ".text", name ), true);

    if(tobs.length == 0)
        return null;
    return (GuiTestObject)tobs[0];
 }

【问题讨论】:

    标签: rft


    【解决方案1】:

    你问的是可能的。您可以使用Property 类,如here 所述,而不是以String 格式提供find 方法搜索条件。

    这样,您的代码将变为:

    private static GuiTestObject findTextObjectDist(String name) {
        // Build searching filters
        Property[] props = new Property[2];
        props[0] = new Property(".class", "Html.SELECT");
        props[1] = new Property(".text", 
            new RegularExpression("District.*", false));
    
        // Search for objects
        TestObject[] tobs = find(atDescendant(props), true);
        // Return them
        if(tobs.length == 0)
            return null;
        return (GuiTestObject)tobs[0];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-15
      • 2022-12-12
      • 1970-01-01
      • 2013-08-21
      • 1970-01-01
      • 2012-02-07
      相关资源
      最近更新 更多