gpt4 book ai didi

c# - 天界壁虎。如何按类名单击项目?

转载 作者:太空宇宙 更新时间:2023-11-03 23:46:48 25 4
gpt4 key购买 nike

这个项目看起来像这样:

//First "button"
<td ref="somethink_ref1" class="class_name">
<b>Text_1</b><br>
text<span class="class_name_1">text</span><br>
<span class="class_name_2">text</span><br>
<span class="class_name_3">text</span>text
</td>
//Second "button"
<td ref="somethink_ref2" class="class_name">
<b>Text_1</b><br>
text<span class="class_name_1">text</span><br>
<span class="class_name_2">text</span><br>
<span class="class_name_3">text</span>text
</td>

没有任何 id,当我使用它时:

        GeckoElementCollection tagsCollection = geckoWebBrowser1.Document.GetElementsByTagName("td");

foreach (GeckoElement currentTag in tagsCollection)
{
if (currentTag.GetAttribute("class").Equals("class_name"))
{
//currentTag.CLICK THIS!;
}
//delay some seconds to click next button...
}

我不知道要将“currentTag.CLICK THIS”替换为真正的点击调用...

最佳答案

如果您使用相对较新的版本 geckofx那么你可以这样做:

foreach (GeckoElement currentTag in tagsCollection)
{
if (currentTag.GetAttribute("class").Equals("class_name"))
{
((GeckoHtmlElement)currentTag).Click()
}
//delay some seconds to click next button...
}

虽然我可能会这样做:

var elements = geckoWebBrowser1.Document.GetElementsByClassName("class_name").Where(x is GeckoHtmlElement)

定位节点。

关于c# - 天界壁虎。如何按类名单击项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27364436/

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