function touchAction(selector, actions) {
    var _this = this;

    if (typeof selector !== 'string' || TOUCH_ACTIONS.indexOf(selector) > -1) {
        actions = selector;
        selector = this.lastResult;
    }

    if (!Array.isArray(actions)) {
        actions = [actions];
    }

    /**
     * check if multiAction
     */
    if (Array.isArray(actions[0])) {
        actions = formatArgs(selector, actions);
        return _promise2.default.all(getSelectors.call(this, actions, true)).then(function (jsonElements) {
            actions = replaceSelectorsById(actions, jsonElements);
            return _this.performMultiAction({ actions });
        });
    }

    actions = formatArgs(selector, actions);
    return _promise2.default.all(getSelectors.call(this, actions)).then(function (jsonElements) {
        actions = replaceSelectorsById(actions, jsonElements);
        return _this.performTouchAction({ actions });
    });
}
The Touch Action API provides the basis of all gestures that can be automated in Appium.
It is currently only available to native apps and can not be used to interact with webapps.
At its core is the ability to chain together _ad hoc_ individual actions, which will then be
applied to an element in the application on the device. The basic actions that can be used are:

- press (pass selector or (x,y) or both)
- longPress (pass selector or (x,y) or both)
- tap (pass selector or (x,y) or both)
- moveTo (pass selector or (x,y) or both)
- wait (pass ms (as milliseconds))
- release (no arguments)

If you use the touchAction command with a selector you don't need to pass the selector to each
action. It will be propagated by the internally (if no x or y parameters are given).

<example>
    :touchAction.js
    it('should do a touch gesture', function () {
        var screen = $('//UITextbox');

        // simple touch action on element
        screen.touchAction('tap');
        // same as
        browser.touchAction('//UITextbox', 'tap')

        // simple touch action using x y variables
        browser.touchAction({
            action: 'tap', x: 300, y:200
        })

        // simple touch action using selector and x y variables
        // tap location is 30px right and 20px down relative from the center of the element
        browser.touchAction({
            action: 'tap', x: 30, y:20, selector: '//UIAApplication[1]/UIAElement[2]'
        })

        // multi action on an element (drag&drop)
        screen.touchAction([
            'press',
            { action: 'moveTo', x: 200, y: 0 },
            'release'
        ])
        // same as
        browser.touchAction('//UITextbox', [
            'press',
            { action: 'moveTo', x: 200, y: 0},
            'release'
        ])

        // drag&drop to element
        screen.touchAction([
            'press',
            { action: 'moveTo', selector: '//UIAApplication[1]/UIAElement[2]' },
            'release'
        ]))
    });

    :multiTouchAction.js
    it('should do a multitouch gesture', function () {
        // drag&drop with two fingers 200px down
        browser.touchAction([
            [{action: 'press', x:  10, y: 10}, { action: 'moveTo', x: 0, y: 200 }, 'release'],
            [{action: 'press', x: 100, y: 10}, { action: 'moveTo', x: 0, y: 200 }, 'release']]
        ])
    })
</example>

@param {String} selector  selector to execute the touchAction on
@param {String} action    action to execute

@see https://saucelabs.com/blog/appium-sauce-labs-bootcamp-chapter-2-touch-actions
@type mobile
@for android, ios
@uses mobile/performTouchAction, mobile/performMultiAction