我试图从linktext获取名称或href,但没有办法。
我能够点击它,但不能在字符串中获取名称或href;
var linkElems = driver.FindElements(By.ClassName(" sorting_1"));
for (int i = 0; i < linkElems.Count; i++)
{
IWebElement tableElement2 = driver.FindElement(By.LinkText(linkElems[i].Text.ToString()));
tableElement2.Click();
}
Get the name or the href from a tag
<a href="#" name="42710962" alt="Click to open details in new window" onclick="window.open('/OTCS/llisapi.dll?func=ll&objid=11743301&objAction=RunReport&SearchView=1&PROCESSID=42710962&ProjCode=0401-BIM','Document_Details','resizable=yes,scrollbars=yes,width=700px,height=600')">Architectura001</a>
请有办法获取名称或href。
答案 0 :(得分:0)
无需获取文本然后单击它。链接文本定位器将自动执行该操作。请在下方使用。
driver.FindElement(By.LinkText(linkElems[i].ToString()));
编辑
如你所说,你想要一个可以通过
找到的属性值tableElement2.GetAttribute("name");
这将返回42710962