Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger 'swipeleft' event in e2e test (protractor)

For example, i have this html-code of application:

<div class="swipe-cover" ng-swipe-left="func()"></div>

and such test:

it('test', function() {
   browser.executeScript( 'angular.element(".swipe-cover").triggerHandler("swipeleft")' );
});

but it doesn't work.

If i use 'click' insteaf of 'swipeleft', it works.

How can i trigger 'swipeleft' event for e2e tests?

like image 467
Alexandr Alex Avatar asked Jul 09 '15 12:07

Alexandr Alex


1 Answers

Simulating a gesture work better using a serie of actions:

driver.actions()
        .mouseDown(element(by.css('.filter-editorial-rating .ngrs-handle-max')))
        .mouseMove({x: -50, y: 0}) // try different value of x
        .mouseUp()
        .perform();

See https://github.com/angular/angular.js/blob/master/src/ngTouch/directive/ngSwipe.js#L74 to help tou figure out the right value if -50 does work out.

like image 173
Julien Bérubé Avatar answered Sep 21 '22 06:09

Julien Bérubé