如何在量角器中模拟拖放动作? [英] How to simulate a drag and drop action in protractor?
问题描述
我有一个双滑块,我想测试它是否可操作并返回正确的数据.滑块有一个最小值和一个最大值处理程序,它还有一些我可以挂钩的断点."
I have a double slider and I'd like to test that it's operable and return's the right data. The slider has a min and a max handler, it also has some "breakpoints that I can hook to. "
我要模拟的是
- .handler-max"元素的 touchStart
- 将拇指移到类为.step-3"的元素上
- .handler-max"元素的 touchEnd
虽然我找到了如何触发 touchStart 和 touchEnd 事件.我对如何模拟拇指的移动一无所知
while I found how to trigger a touchStart and a touchEnd event. I'm clueless on how to simulate the move of the thumb
browser.executeScript('angular.element(arguments[0]).triggerHandler("touchstart");', filterHandler);
// <--- move event????
browser.executeScript('angular.element(arguments[0]).triggerHandler("touchend");', filterHandler);
附言这个问题的范围是一个集成测试,测试当用户与双滑块指令交互时应用程序发生的情况是否是理想的结果.
P.S. The scope of this question is an integration test that tests if what happens to the application when a user interact's with a double slider directive is the desirable result.
推荐答案
elem = 要移动的元素;
elem = Element you want to move;
target = 要放置元素的元素;
target = Element where you want to drop elem;
对于 WebdriverJS:-
For WebdriverJS:-
browser.driver.actions().dragAndDrop(elem,target).mouseUp().perform();
对于量角器:-
browser.actions().dragAndDrop(elem,target).mouseUp().perform();
这篇关于如何在量角器中模拟拖放动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!