【发布时间】:2019-01-14 00:44:13
【问题描述】:
我正在尝试在 div 中定位工具提示,然后提取当我将鼠标悬停在工具提示上时可见的工具提示文本。 从 UI 复制下面的代码快照 --
<div class="w-table w-table-hover ng-star-inserted">
<table class="w-table w-table-hover">
<tbody>
<tr class="w-table-border">
<td class="w-table-row pl-3 w-table-width-60">
John Spiderman (123456)
</td>
<td class="w-table-row pl-2 w-table-width-25">
Open
</td>
<td class="w-table-row text-right px-2 w-table-width-15">
<!---->
<div class="w-table-row-text ng-star-inserted">
Unavailable
<i class="fa fa-question-circle w-icon-question-circle"
container="body"
placement="right"
id="tooltip-report-account-123456">
</i>
</div>
<!---->
</td>
</tr>
</tbody>
</table>
我尝试执行以下操作来定位元素,然后从中获取文本,但是它不起作用,因为文本仅在鼠标悬停时显示
var tooltipElement = driver.FindElement(By.Id("tooltip-report-account-" + accountNumber));
Assert.AreEqual(tooltipElement.Text.ToLower().Trim(), 'This account is unavailable');
找不到元素
【问题讨论】:
-
为什么不将帐号存储在上下文中并从中检索。据我记得工具提示仅适用于鼠标悬停。你检查过这个link
-
locate a tooltip within a div大概文本 Unavailable 似乎是工具提示,但您不一定将鼠标悬停在工具提示上,您需要更新您需要鼠标悬停的元素的问题
标签: c# selenium selenium-webdriver