量角器browser.actions().dragandDrop异步等待不起作用 [英] Protractor browser.actions().dragandDrop async await not working

查看:45
本文介绍了量角器browser.actions().dragandDrop异步等待不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 节点版本:8.2.1
  • 量角器版本:5.2.2

我正在将现有测试转换为与量角器一起使用async await,但似乎无法使此代码正常工作.我意识到,它至少没有根据量角器

I am converting existing tests to use async await with protractor, and I can't seem to get this code to work properly. I realized it doesn't return a promise, at least according to the protractor docs.

似乎发生的动作是,单击我要拖动的区域,然后将其拖动到它的区域将选择所有文本.

The action that seems to happen is, that it clicks the area that I want to drag, then the area I want it to drag to it will select all the text.

因此,它就像单击了第一个元素,但不以某种方式将其拖动.

So it's like it clicks the first element, but somehow doesn't drag it.

有人用dragAndDrop和async等待成功吗?

Has anyone had any success with dragAndDrop and async await?

我愿意接受其他解决方法.

I'm open to alternative workarounds.

    browser.actions()
    .dragAndDrop(
        elem1,
        elem2
    ).perform());

推荐答案

因此,经过多次尝试并尝试了不同的方法.我发现此解决方案有效.我将把它实现为一个前进的辅助函数.

So after many attempts and trying different things. I have found this solution to work. I am going to implement it into a helper function moving forward.

    await browser.actions().mouseMove(elem1).perform();
    await browser.actions().mouseDown().perform();
    await browser.actions().mouseMove(elem2).perform();
    await browser.actions().mouseUp().perform();

这篇关于量角器browser.actions().dragandDrop异步等待不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆