【问题标题】:double click not working in protractor type script双击在量角器类型脚本中不起作用
【发布时间】:2019-10-04 20:26:36
【问题描述】:

双击无效。

html:

<div class="dhx_scale_hour" style="height: 851px; width: 50px;">
   <div style="height:72px;line-height:30px;">::before "06:00 pm"/div>
   <div style="height:72px;line-height:30px;">::before "06:05 pm"</div>
   <div style="height:72px;line-height:30px;">::before "06:10 pm"</div>
   <div style="height:72px;line-height:30px;">::before "06:15 pm"</div>
   <div style="height:72px;line-height:30px;">::before "06:20 pm"</div>
   <div style="height:72px;line-height:30px;">::before "06:25 pm"</div>
   <div style="height:72px;line-height:30px;">::before "06:30 pm"</div>
   <div style="height:72px;line-height:30px;">::before "06:35 pm"</div>
   <div style="height:72px;line-height:30px;">::before "06:40 pm"</div>
   <div style="height:72px;line-height:30px;">::before "06:45 pm"</div>
   <div style="height:72px;line-height:30px;">::before "06:50 pm"</div>
   <div style="height:72px;line-height:30px;">::before "06:55 pm"</div>
</div>

量角器类型脚本:

browser.actions().doubleClick(element(by.xpath('//*[@id="appointmentSchedulerControl"]/div[3]/div[7]/div[19]/div[1]'))).perform();

不会出现任何错误,只是不会双击指定的元素。

【问题讨论】:

  • 你要从下拉列表中选择任何值吗?
  • 你确定它正确定位了元素吗?
  • @kunduk 没有下拉菜单,因为它是包含时间的侧面板。我想双击它
  • @KunduK 我如何为此创建 xpath?

标签: typescript selenium protractor


【解决方案1】:

doubleclick()perform() 都返回承诺。 您必须确保您的代码包含以下方式之一。

  1. 使用异步/等待。
  2. 链 thenables。

对于选项 2,请参阅以下内容:

perform().then( function () { 
       browser.sleep(1000); // or you can write if there is some validation here
})

【讨论】:

  • 建议的 xpath 可能是什么。 ?
  • 分享代码sn-p写在这行之前 browser.actions().doubleClick(element(by.xpath('//*[@id="appointmentSchedulerControl"]/div[3]/div [7]/div[19]/div[1]'))).perform();
猜你喜欢
  • 2016-08-20
  • 2019-08-24
  • 1970-01-01
  • 1970-01-01
  • 2011-10-29
  • 2015-01-11
  • 1970-01-01
  • 2015-11-27
  • 2016-09-10
相关资源
最近更新 更多