C# Watin:在元素的子元素中搜索

C# Watin:在元素的子元素中搜索,c#,testing,automated-tests,watin,C#,Testing,Automated Tests,Watin,我想使用Watin进行“两步”搜索。例如,我想搜索类别为“abc”的ul标签。然后我想在该元素中搜索某个li标记。代码可能如下所示: ie.ElementWithTag("ul", Find.ByClass("abc")).ElementsWithTag("li", Find.ByXYZ()); 但元素没有ElementWithTag方法。有没有关于如何使用Watin的提示? 更新 事实上,我刚刚看到信息,现在有ie.ElementWithTag,请看问题。 所以这篇文章的其余部分可能不会有什

我想使用Watin进行“两步”搜索。例如,我想搜索类别为“abc”的ul标签。然后我想在该元素中搜索某个li标记。代码可能如下所示:

ie.ElementWithTag("ul", Find.ByClass("abc")).ElementsWithTag("li", Find.ByXYZ());
但元素没有ElementWithTag方法。有没有关于如何使用Watin的提示?


更新

事实上,我刚刚看到信息,现在有ie.ElementWithTag,请看问题。
所以这篇文章的其余部分可能不会有什么帮助


没有现成的解决方案,但可能是一个起点。
很久以前,我正在为一个页面编写一些自动化脚本。我使用了powershell,但它应该很容易迁移到C(我假设您使用)

所以在脚本的这一部分中,我将搜索具有标记输入的页面元素,该元素名为savechanges


所以,如果您将查找元素的Save Changes属性(并删除getProperty声明)的循环中的一部分替换为check for property类,那么它就应该做到这一点。

Watin的作者告诉我,下一个版本将支持这一点。目前,这可以通过使用过滤器和lambdas来实现。

在其新版本2.0.50.11579中实现

    #getting property from com object::IHTMLDOMAttribute
    function getProperty ([System.__ComObject] $obj, [string] $prop)
    {
        [System.__ComObject].InvokeMember($prop, [System.Reflection.BindingFlags]::GetProperty, $null, $obj, $null)
    }



    $ie = new-object -com "InternetExplorer.Application";


    $ie.visible = $true;
    $ie.navigate("http://mytestpage.com");
    $doc = $ie.Document;

 $saveButton = $null;
 $inputElts = $null;
 $inputElts = $doc.getElementsByTagName('input')
 foreach ($elt in $inputElts)
 {
     $a = $elt.getAttributeNode('value')
  if ($a -and (getProperty $a 'nodeValue') -eq 'Save changes')
     {
         $saveButton = $elt;
   break;
     }
 }