How to use the wd.TouchAction function in wd

To help you get started, we’ve selected a few wd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kerrishotts / Mastering-PhoneGap-Code-Package / logology-v06 / test-ui / helpers / util.js View on Github external
.then(() => {
                                 let action = new wd.TouchAction(driver);
                                 action = action.tap({x, y});
                                 if (profile.platformName === "iOS") {
                                     action = action.release();  // Android doesn't like this much
                                 }
                                 action = action.wait({ms:1000});
                                 return action.perform();
                             })
                             .then(switchToWebViewContext);
github appium / appium-desktop / app / main / appium-method-handler.js View on Github external
let res = {};
    if (!_.isArray(args)) {
      args = [args];
    }

    if (elementId) {
      // Give the cached element a variable name (el1, el2, el3,...) the first time it's used
      cachedEl = this.elementCache[elementId];
      if (!cachedEl.variableName && cachedEl.variableType === 'string') {
        cachedEl.variableName = `el${this.elVariableCounter++}`;
      }
      res = await cachedEl.el[methodName].apply(cachedEl.el, args);
    } else {
      // Specially handle the tap and swipe method
      if (methodName === SCREENSHOT_INTERACTION_MODE.TAP) {
        res = await (new wd.TouchAction(this.driver))
          .tap({x: args[0], y: args[1]})
          .perform();
      } else if (methodName === SCREENSHOT_INTERACTION_MODE.SWIPE) {
        const [startX, startY, endX, endY] = args;
        res = await (new wd.TouchAction(this.driver))
          .press({x: startX, y: startY})
          .wait(500)
          .moveTo({x: endX, y: endY})
          .release()
          .perform();
      } else if (methodName !== 'source' && methodName !== 'screenshot') {
        res = await this.driver[methodName].apply(this.driver, args);
      }
    }

    // Give the source/screenshot time to change before taking the screenshot
github appium / appium-xcuitest-driver / test / functional / basic / gesture-e2e-specs.js View on Github external
it('should long press on an element with duration through press-wait-release', async function () {
        let el = await driver.elementByAccessibilityId(BTN_OK_CNCL);
        let action = new wd.TouchAction(driver);
        action.press({el}).wait(1200).release();
        await action.perform();

        await exitModal('Cancel');
      });
      it('should long press on an element with duration through pressOpts.duration', async function () {
github appium / appium-xcuitest-driver / test / functional / basic / gesture-e2e-specs.js View on Github external
async function doZoom () {
          let el = await driver.elementByClassName('XCUIElementTypeApplication');
          let thumb = new wd.TouchAction(driver);
          thumb.press({el, x: 100, y: 0}).moveTo({el, x: 50, y: 0}).release();

          let foreFinger = new wd.TouchAction(driver);
          foreFinger.press({el, x: 100, y: 0}).moveTo({el, x: 105, y: 0}).release();

          let zoom = new wd.MultiAction(driver);
          zoom.add(thumb, foreFinger);
          await zoom.perform();
        }
        await doZoom();
github staltz / manyverse / e2e / feed.js View on Github external
async function scrollUpUntil(driver, conditionFn) {
  for (let _ of Array(10)) {
    let action = new wd.TouchAction(driver);
    action
      .press({x: 600, y: 600})
      .wait(200)
      .moveTo({x: 600, y: 1100})
      .release();
    await action.perform();
    await driver.sleep(300);
    if (await conditionFn()) return;
  }
}
github Jonahss / appium-draws-its-logo / main.js View on Github external
var drawLine =function(x1, y1, x2, y2){
  var line = (new TouchAction(driver))
    .press({x:x1,y:y1})
    .moveTo({x:x2, y:y2})
    .release();
  driver.performTouchAction(line);
}
github appium / appium / sample-code / examples / node / helpers / actions.js View on Github external
]).then(function (res) {
    var size = res[0];
    var loc = res[1];
    var center = {
      x: loc.x + size.width / 2,
      y: loc.y + size.height / 2
    };
    var a1 = new wd.TouchAction(this);
    a1.press({el: el}).moveTo({el: el, x: center.x, y: center.y - 100}).release();
    var a2 = new wd.TouchAction(this);
    a2.press({el: el}).moveTo({el: el, x: center.x, y: center.y + 100}).release();
    var m = new wd.MultiAction(this);
    m.add(a1, a2);
    return m.perform();
  }.bind(this));
};
github appium / appium / sample-code / examples / node / android-complex.js View on Github external
.then(function () {
        var a1 = new wd.TouchAction();
        a1.press({x: 150, y: 100}).release();
        var a2 = new wd.TouchAction();
        a2.press({x: 250, y: 100}).release();
        var smile = new wd.TouchAction();
        smile
          .press({x:110, y:200})
          .moveTo({x:1, y:1})
          .moveTo({x:1, y:1})
          .moveTo({x:1, y:1})
          .moveTo({x:1, y:1})
          .moveTo({x:1, y:1})
          .moveTo({x:2, y:1})
          .moveTo({x:2, y:1})
          .moveTo({x:2, y:1})
          .moveTo({x:2, y:1})
          .moveTo({x:2, y:1})
          .moveTo({x:3, y:1})
          .moveTo({x:3, y:1})
github Jonahss / appium-draws-its-logo / main.js View on Github external
var arcAction = function(start, end) {
  var cos = Math.cos;
  var sin = Math.sin;
  var theta = start;

  var prev = {x: h+r*cos(theta), y: k+r*sin(theta)}
  var action = new TouchAction(driver);
  action.press(prev);
  for (; theta < end; theta+=2*pi/100) {
    var next = {x: h+r*cos(theta), y: k+r*sin(theta)}
    var offset = {x: next.x-prev.x, y: next.y-prev.y}
    action.moveTo(offset);
    prev = next;
  }
  action.release();
  return action;
}
github appium / appium / sample-code / examples / node / android-complex.js View on Github external
.then(function () {
        var a1 = new wd.TouchAction();
        a1.press({x: 150, y: 100}).release();
        var a2 = new wd.TouchAction();
        a2.press({x: 250, y: 100}).release();
        var smile = new wd.TouchAction();
        smile
          .press({x:110, y:200})
          .moveTo({x:1, y:1})
          .moveTo({x:1, y:1})
          .moveTo({x:1, y:1})
          .moveTo({x:1, y:1})
          .moveTo({x:1, y:1})
          .moveTo({x:2, y:1})
          .moveTo({x:2, y:1})
          .moveTo({x:2, y:1})
          .moveTo({x:2, y:1})
          .moveTo({x:2, y:1})
          .moveTo({x:3, y:1})
          .moveTo({x:3, y:1})
          .moveTo({x:3, y:1})
          .moveTo({x:3, y:1})