0

HtmlDiv hd = new HtmlDiv(UINewTabWindowsInterneWindow); hd.SearchProperties.Add(HtmlDiv.PropertyNames.Id, "ContentPlaceHolder1_WebPartManager1_gwpucHorizo​​ntalAgentQueueGrid1_ucHorizo​​ntalAgentQueueGrid1_bottomWebPartHeaderMiddle1");

        HtmlControl htc1 = new HtmlControl(hd);
        htc1.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "TABLE");
        UITestControlCollection collection = htc1.FindMatchingControls();


        foreach (UITestControl uitabs in collection)
        {

            HtmlTable ht = (HtmlTable)uitabs;
            UITestControlCollection temp1 ;
            if (ht.Id == "ctl00_ContentPlaceHolder1_WebPartManager1_gwpucHorizontalAgentQueueGrid1_ucHorizontalAgentQueueGrid1_RadGrid1_ctl00")
            {                   

                HtmlControl htc_tr = new HtmlControl(ht);
                htc_tr.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "TR");
                UITestControlCollection collection_tr = htc_tr.FindMatchingControls();

                UITestControl tr;
                for (int i = 0; i < collection_tr.Count; i++)
                {
                    tr= collection_tr[i];

                   // HtmlRow hr = (HtmlRow)tr;  //getting error not able to cntrol htmlol to html row
4

1 に答える 1

0

あなたが行っているすべての変換の後に、何かが混乱していると思います。私は次のことを試しましたが、あなたのシナリオでもうまくいくはずです。

HtmlDiv htc1 = new HtmlDiv(UINewTabWindowsInternWindow);
htc1.SearchProperties["id"] = yourID;

HtmlTable table = new HtmlTable(htc1);
table.SearchProperties["id"] = "ct100_ContentPlaceHolder1...";

HtmlRow row = new HtmlRow(table);
row.SearchProperties["TagName"] = "TR";

UITestControlCollection rows = row.FindMatchingControls();

foreach (UITestControl myRow in rows)
{
    HtmlRow thisRow = (HtmlRow)myRow;
    // Do your thing here.
}

UITestControl から行に変換し直さなくても、行に対して必要なアクションを実行することさえできるかもしれません。行のほとんどのプロパティとメソッドは、親クラスで使用できます。

于 2014-06-06T12:41:26.910 に答える