【问题标题】:how to get tooltip text which is generated dynamic如何获取动态生成的工具提示文本
【发布时间】:2013-07-25 12:14:27
【问题描述】:
<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>

在上面的代码中,当我将鼠标悬停在元素&lt;div class="dhx_cal_event_line Booked" style="position:absolute; top:2px; height: 17px; left:99px; width:28px;" event_id="1374736442513"&gt; 上时,我得到一个动态生成的提示提示;我无法使用火路捕捉它。我已经尝试过类似的动作类

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 作为元素文本。

【问题讨论】:

  • 你能给我们看一张工具提示的截图吗?我猜这不是一个小的基本工具提示,而是某种更大的支持 html 的面板?

标签: tooltip selenium-webdriver dhtml dhtmlx dhtmlx-scheduler


【解决方案1】:

当你这样做时:

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();,然后将该源保存在某处(或将其打印到控制台)

查看页面源代码,看看哪个元素中有工具提示文本,然后你可以为它编写一个选择器。

【讨论】:

  • 我提到的路径 ".//*[@id='scheduler']/div[3]/table/tbody/tr[2]/td[2]/div/div[ 4]" 如果表格行中还有一个元素并且 event_id="1374736442513" 由 dhtml-calendar 生成,则它是动态的则无效。现在如何获取元素?
  • 能否请您发布 HTML 源代码(元素中带有调度程序 ID 的任何内容)
猜你喜欢
  • 2017-06-11
  • 1970-01-01
  • 2012-01-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-16
  • 2015-08-06
相关资源
最近更新 更多