HTML:
<li class="dropdown current-user" dropdown="" on-toggle="toggled(open)">
<a aria-expanded="false" aria-haspopup="true" href="" class="dropdown-toggle" dropdown-toggle="">
<img src="assets/images/avatar-1.jpg"alt="{{user.FirstName}}">
<span class="username">
{{user.FirstName}} <i class="ti-angle-down"> </i> </i>
</span>
</a>
</li>
<ul>
<li>
<a href="Account/LogOff" ng-href="Account/LogOff">
Log Out
</a>
</li>
</ul>
现在在我的网站上,我需要点击链接,其中包含其他子链接,如个人资料,注销等,如何查找超级链接,然后单击子链接。
答案 0 :(得分:0)
试试这个
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
//Scroll the element into view
string title = (string)js.ExecuteScript("return document.getElementsByTagName('a')[1].scrollIntoViewIfNeeded()");
//Now, execute findElement
driver.FindElement(By.XPath("//a[@href='']/following::a"));