首页 > 解决方案 > 双击在量角器类型脚本中不起作用

问题描述

双击不起作用。

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();

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

标签: typescriptseleniumprotractor

解决方案


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

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

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

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

推荐阅读