<tbody>
<tr class="" style="height:65px;">
<tr class="" style="height:65px;">
<td class="dhx_matrix_scell" style="width:99px; height:64px;">Ashmita </td>
<td>
<div class="dhx_matrix_line" style="width:1181px; height:65px; position:relative;">
<div class="dhx_marked_timespan dhx_matrix_now_time" style="height: 64px; left: 105px; width: 1px; top: 0px;"></div>
<div class="dhx_marked_timespan gray_section" style="height: 64px; left: 588px; width: 591px; top: 0px;"></div>
<div class="dhx_cal_event_line Booked" style="position:absolute; top:2px; height: 17px; left:99px; width:28px;" event_id="1374736442513">
<table class="" cellspacing="0" cellpadding="0" style="width:1181px; height:65px;">
</div>
</td>
</tr>
<tr class="" style="height:65px;">
<tr class="" style="height:65px;">
<tr class="" style="height:65px;">
<tr class="" style="height:65px;">
</tbody>
在上面的代码中,当我将鼠标悬停在元素<div class="dhx_cal_event_line Booked" style="position:absolute; top:2px; height: 17px; left:99px; width:28px;" event_id="1374736442513">
上时,我得到一个动态生成的工具提示tipsy;我无法使用firepath捕获它。我尝试过像
Actions action = new Actions(driver);
WebElement element = driver.findElement(By.xpath(".//*[@id='scheduler']/div[3]/table/tbody/tr[2]/td[2]/div/div[4]"));
action.moveToElement(element).build().perform();
System.out.println("the tool tip text is"+element.getText());
action.moveToElement(element).release().build().perform();
但我得到null作为元素文本。
答案 0 :(得分:2)
执行此操作时:
Actions action = new Actions(driver);
WebElement element = driver.findElement(By.xpath(".//*[@id='scheduler']/div[3]/table/tbody/tr[2]/td[2]/div/div[4]"));
action.moveToElement(element).build().perform();
放一个String source = driver.getPageSource();
,然后将该源保存在某处(或将其打印到控制台)
查看页面源代码,查看哪个元素包含工具提示文本,然后您可以为其编写选择器。