gpt4 book ai didi

watin - 如何使用 WATIN 在表格网格上查找项目

转载 作者:行者123 更新时间:2023-12-01 22:52:10 25 4
gpt4 key购买 nike

我在尝试查找表中的项目时遇到一些问题 - 它要么为 null,要么我得到一个数组越界异常。这就是我想要做的。

这是我从页面解析的示例 html....

<table id="ctl00__defaultCont__ctrlHeader__ctrlHeader_p_Providerd33">
<tr>
<td class="w90 ta-right lbl">
<span>Provider ID</span>
</td>
<td class="fieldWithNoBorderClass">
<div id="ob_iT_providerIDContainer" class="ob_iTCN" style="width:220px;"><div class="ob_iTL"></div><div class="ob_iTR"></div><div class="ob_iTC"><input name="ctl00$_defaultContent$_ctrlHeader$_ctrlHeader$_providerID" type="text" value="P13040620" id="ctl00__defaultContent__ctrlHeader__ctrlHeader__providerID" class="ob_iTIE" /></div><div class="ob_iCallbackScript" style="display:none;"></div></div>
</td>
</tr>

这是我的开始:

我基本上是在尝试查找 PROVIDER ID。例如……

Table table = browser.Table(Find.ById("ctl00__defaultContent__ctrlHeader__ctrlHeader_p_Provider3"));
TableRowCollection tableRows = table.TableRows;
TableRow row = tableRows[3];
ElementCollection rowData = row.Elements;

string name = rowData[0].OuterText;
string membername = rowData[1].OuterText;

最佳答案

我做了类似的事情,它适用于我的一个项目。也许这会给您一些线索。

注意:访问 Watin 表非常慢。

      Table table = browser.Table("ctl00_defaultContent_ctrlHeader__ctrlHeader_p_Provider3");
if (table == null)
{
DebugLog("Could not find table");
throw new Exception("Results table missing.");
}
TableRow tr = table.TableRows[3];
while( tr != null)
{
string words = tr.TableCells[1].Text;
tr = (TableRow)tr.NextSibling;
}

关于watin - 如何使用 WATIN 在表格网格上查找项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6425716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com