swipe and click a button protractor

放肆的年华 提交于 2020-01-21 09:41:53

问题


i need to swipe an item and need to click on a button in that item, i used this the test is success but i could not view that button this test case is written to swipe left and make a button visible and click on that button

it('should delete a product',function(){
        browser.driver.actions().mouseMove({x:-50,y:0}).perform();
browser.sleep(3000);
            });

could someone help me to swipe the delete button is

<ion-option-button ng-show="!userService.isOffline" class="button button-assertive button disable-user-behavior" on-tap="deleteLead(leads)">Delete</ion-option-button>

回答1:


I am doing something similar, with an ion-list, with ion-items, and ion-option-buttons. My swipe works, and looks like this:

var elements = element(by.id("item-list")).all(by.tagName("ion-item"));
var item1 = elements.get(0);
item1.getLocation().then((location) => {
  var startLocation = {
    x: location.x + 300,
    y: location.y + 50
  }
  var newLocation = {
    x: startLocation.x - 100,
    y: startLocation.y
  };
  browser.driver.touchActions()
                .tapAndHold(startLocation)
                .move(newLocation)
                .perform();
}

So I think you should use touchActions() instead of actions()

By the way, does on-tap work? Why not using ng-click?



来源:https://stackoverflow.com/questions/33209499/swipe-and-click-a-button-protractor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!