量角器+ AngularJS +茉莉 - 测试preSS和持有项目
与AngularJS和量角器很新,但我想我会在正确的方向为止。
Very new with AngularJS and Protractor, but I think I am going to the right direction so far.
我的网站,当你点击并按住X秒项目的项目列表,它会打开一个模态窗口。
My site has a list of items when you click and hold the item for X seconds, it opens a modal window.
我怎么能模拟量角器/茉莉花这种行为?
How can I simulate that behavior in Protractor/Jasmine?
我知道有一个点击()事件,但我想要的点击并按住事件
I know there is the "click()" event, but I want the "click and hold" event
我肯定有一个人知道如何来模拟。
I am sure there is someone that knows how to simulate that.
大在此先感谢!
我们的想法是使用的 鼠标按下()
第一:
The idea is to use mouseDown()
first:
/**
* Presses a mouse button. The mouse button will not be released until
* {@link #mouseUp} is called, regardless of whether that call is made in this
* sequence or another. The behavior for out-of-order events (e.g. mouseDown,
* click) is undefined.
...
*/
然后,调用 browser.sleep()
X秒。
然后,调用 mouseUp事件()
释放鼠标点击:
Then, call mouseUp()
to release the mouse click:
/**
* Releases a mouse button. Behavior is undefined for calling this function
* without a previous call to {@link #mouseDown}.
...
*/
code:
browser.actions().mouseDown(element).perform();
browser.sleep(5000);
browser.actions().mouseUp(element).perform();
其中,元素
是目标元素点击并持有
。
工作示例(基于本的jsfiddle ):
require('jasmine-expect');
describe('Test Click And Hold', function () {
beforeEach(function () {
browser.ignoreSynchronization = true;
browser.get('http://jsfiddle.net/LysCF/13/embedded/result/');
browser.sleep(5000);
});
it('should show appropriate list elements after click and hold', function () {
var frame = browser.findElement(by.xpath('//div[@id="result"]/iframe'));
browser.switchTo().frame(frame);
var element = browser.findElement(by.css('div.hold_trigger'));
browser.actions().mouseDown(element).perform();
browser.sleep(5000);
browser.actions().mouseUp().perform();
// check expectations
});
});