我试图单击外部跨度内的span元素,该属性通过属性“ data-qid” =“ 3606”可以识别。外跨度内的那些元素代表5星评级。
我想在外部跨度中单击第一个跨度。我尝试使用elem.InvokeMember(“ Click”),该方法执行单击,但是如何选择第一颗星(外部跨度内的第一跨度)?
HTML代码:
<span id="quote-rate" class="rank-icon" title="rate it" data-qid="3606" data-nv="9" data-score="4.22"><span class="sf"></span><span class="sf"></span><span class="sf"></span><span class="sf"></span><span class="se"></span></span>
C#代码:
private void Button3_Click(object sender, EventArgs e)
{
foreach(HtmlElement elem in webBrowser1.Document.GetElementsByTagName("span"))
{
if (elem.GetAttribute("data-qid")=="3606")
//How can I perform click on first span inside an outter span?
}
}