mirror of
https://github.com/appium/appium.git
synced 2026-05-02 00:09:28 -05:00
wd upgrade, updated node touch action api
This commit is contained in:
@@ -2030,6 +2030,7 @@ var mergeStates = function (states) {
|
||||
touch: []
|
||||
};
|
||||
_.each(slice, function (action) {
|
||||
console.log('AKAK action -->', action);
|
||||
obj.touch.push(action.touch[0]);
|
||||
});
|
||||
merged.push(obj);
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@
|
||||
"socks": "~0.0.1",
|
||||
"underscore-cli": "~0.2.17",
|
||||
"unorm": "~1.3.3",
|
||||
"wd": "~0.2.27",
|
||||
"wd": "~0.3.0",
|
||||
"yiewd": "~0.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
mocha sample-code/examples/node/ios-simple.js
|
||||
mocha sample-code/examples/node/ios-complex.js
|
||||
mocha sample-code/examples/node/ios-webview.js
|
||||
mocha sample-code/examples/node/ios-actions.js
|
||||
mocha sample-code/examples/node/ios-local-server.js
|
||||
```
|
||||
### dev (run against locally built app)
|
||||
@@ -20,6 +21,7 @@ mocha sample-code/examples/node/ios-local-server.js
|
||||
DEV=1 mocha sample-code/examples/node/ios-simple.js
|
||||
DEV=1 mocha sample-code/examples/node/ios-complex.js
|
||||
DEV=1 mocha sample-code/examples/node/ios-webview.js
|
||||
DEV=1 mocha sample-code/examples/node/ios-actions.js
|
||||
DEV=1 mocha sample-code/examples/node/ios-local-server.js
|
||||
```
|
||||
|
||||
@@ -33,6 +35,7 @@ export SAUCE_ACCESS_KEY=<SAUCE_ACCESS_KEY>
|
||||
SAUCE=1 mocha sample-code/examples/node/ios-simple.js
|
||||
SAUCE=1 mocha sample-code/examples/node/ios-complex.js
|
||||
SAUCE=1 mocha sample-code/examples/node/ios-webview.js
|
||||
SAUCE=1 mocha sample-code/examples/node/ios-actions.js
|
||||
```
|
||||
|
||||
### Sauce Labs + Sauce Connect
|
||||
|
||||
@@ -186,7 +186,7 @@ describe("android complex", function () {
|
||||
.release();
|
||||
|
||||
var ma = new wd.MultiAction().add(a1, a2, smile);
|
||||
return driver.performMultiTouch(ma)
|
||||
return driver.performMultiAction(ma)
|
||||
// so you can see it
|
||||
.sleep(10000)
|
||||
.back().sleep(1000)
|
||||
|
||||
@@ -9,5 +9,5 @@ exports.swipe = function (opts) {
|
||||
.wait(opts.duration)
|
||||
.moveTo({x: opts.endX, y: opts.endY})
|
||||
.release();
|
||||
return this.performTouch(action);
|
||||
return this.performTouchAction(action);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
"use strict";
|
||||
|
||||
require("./helpers/setup");
|
||||
|
||||
var wd = require("wd"),
|
||||
_ = require('underscore'),
|
||||
actions = require("./helpers/actions"),
|
||||
serverConfigs = require('./helpers/appium-servers');
|
||||
|
||||
wd.addPromiseChainMethod('swipe', actions.swipe);
|
||||
|
||||
describe("ios actions", function () {
|
||||
this.timeout(300000);
|
||||
var driver;
|
||||
var allPassed = true;
|
||||
|
||||
before(function () {
|
||||
var serverConfig = process.env.SAUCE ?
|
||||
serverConfigs.sauce : serverConfigs.local;
|
||||
driver = wd.promiseChainRemote(serverConfig);
|
||||
require("./helpers/logging").configure(driver);
|
||||
|
||||
var desired = _.clone(require("./helpers/caps").ios71);
|
||||
desired.app = require("./helpers/apps").iosTestApp;
|
||||
if (process.env.SAUCE) {
|
||||
desired.name = 'ios - actions';
|
||||
desired.tags = ['sample'];
|
||||
}
|
||||
return driver.init(desired);
|
||||
});
|
||||
|
||||
after(function () {
|
||||
return driver
|
||||
.quit()
|
||||
.finally(function () {
|
||||
if (process.env.SAUCE) {
|
||||
return driver.sauceJobStatus(allPassed);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
allPassed = allPassed && this.currentTest.state === 'passed';
|
||||
});
|
||||
|
||||
it("should execute a simple action", function () {
|
||||
return driver.chain()
|
||||
.elementByAccessibilityId('ComputeSumButton')
|
||||
.then(function (el) {
|
||||
var action = new wd.TouchAction(driver);
|
||||
action
|
||||
.tap({el: el, x: 10, y: 10})
|
||||
.release();
|
||||
return driver.performTouchAction(action);
|
||||
})
|
||||
.elementByAccessibilityId('ComputeSumButton')
|
||||
.then(function (el) {
|
||||
var action = new wd.TouchAction(driver);
|
||||
action
|
||||
.tap({el: el, x: 10, y: 10})
|
||||
.release();
|
||||
return action.perform();
|
||||
});
|
||||
});
|
||||
|
||||
it("should execute a multi action", function () {
|
||||
return driver.chain()
|
||||
.then(function () {
|
||||
return driver
|
||||
.elementByAccessibilityId('ComputeSumButton')
|
||||
.then(function (el) {
|
||||
var a1 = new wd.TouchAction();
|
||||
a1
|
||||
.tap({el: el, x: 10, y: 10});
|
||||
var a2 = new wd.TouchAction();
|
||||
a2
|
||||
.tap({el: el});
|
||||
var m = new wd.MultiAction();
|
||||
m.add(a1, a2);
|
||||
return driver.performMultiAction(m);
|
||||
});
|
||||
})
|
||||
.then(function () {
|
||||
return driver
|
||||
.elementByAccessibilityId('ComputeSumButton')
|
||||
.then(function (el) {
|
||||
var a1 = new wd.TouchAction();
|
||||
a1
|
||||
.tap({el: el, x: 10, y: 10});
|
||||
var a2 = new wd.TouchAction();
|
||||
a2
|
||||
.tap({el: el});
|
||||
var m = new wd.MultiAction(driver);
|
||||
m.add(a1, a2);
|
||||
return m.perform();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should swipe", function () {
|
||||
return driver
|
||||
.waitForElementByName('Test Gesture', 5000).click()
|
||||
.sleep(1000)
|
||||
.elementByName('OK').click()
|
||||
.sleep(1000)
|
||||
.elementByXPath('//UIAMapView').getLocation()
|
||||
.then(function (loc) {
|
||||
return driver.swipe({ startX: loc.x, startY: loc.y,
|
||||
endX: 0.5, endY: loc.y, duration: 800 });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -5,11 +5,8 @@ require("./helpers/setup");
|
||||
var wd = require("wd"),
|
||||
_ = require('underscore'),
|
||||
Q = require('q'),
|
||||
actions = require("./helpers/actions"),
|
||||
serverConfigs = require('./helpers/appium-servers');
|
||||
|
||||
wd.addPromiseChainMethod('swipe', actions.swipe);
|
||||
|
||||
describe("ios simple", function () {
|
||||
this.timeout(300000);
|
||||
var driver;
|
||||
@@ -69,16 +66,4 @@ describe("ios simple", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("should swipe", function () {
|
||||
return driver
|
||||
.waitForElementByName('Test Gesture', 5000).click()
|
||||
.sleep(1000)
|
||||
.elementByName('OK').click()
|
||||
.sleep(1000)
|
||||
.elementByXPath('//UIAMapView').getLocation()
|
||||
.then(function (loc) {
|
||||
return driver.swipe({ startX: loc.x, startY: loc.y,
|
||||
endX: 0.5, endY: loc.y, duration: 800 });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
var okIfAlert = require('../../../helpers/alert').okIfAlert,
|
||||
setup = require("../../common/setup-base"),
|
||||
desired = require('./desired');
|
||||
|
||||
describe('testapp - pinchOpen/pinchClose', function () {
|
||||
var driver;
|
||||
setup(this, desired).then(function (d) { driver = d; });
|
||||
|
||||
it('should pinchOpen and pinchClose map after tapping Test Gesture', function (done) {
|
||||
driver
|
||||
.elementsByClassName('UIAButton').at(5).click()
|
||||
.sleep(1000).then(function () { okIfAlert(driver); })
|
||||
.elementByXPath('//UIAMapView')
|
||||
.execute("mobile: pinchOpen", [{startX: 114.0, startY: 198.0, endX: 257.0,
|
||||
endY: 256.0, duration: 5.0}])
|
||||
.elementByXPath('//UIAMapView')
|
||||
.execute("mobile: pinchClose", [{startX: 114.0, startY: 198.0, endX: 257.0,
|
||||
endY: 256.0, duration: 5.0}])
|
||||
.nodeify(done);
|
||||
});
|
||||
});
|
||||
@@ -6,61 +6,51 @@ var okIfAlert = require('../../../helpers/alert').okIfAlert,
|
||||
TouchAction = require('wd').TouchAction,
|
||||
MultiAction = require('wd').MultiAction;
|
||||
|
||||
describe('testapp - pinch gesture', function () {
|
||||
|
||||
describe('pinchOpen and pinchClose gesture', function () {
|
||||
var driver;
|
||||
setup(this, desired).then(function (d) { driver = d; });
|
||||
|
||||
it('should pinchOpen and pinchClose map after tapping Test Gesture', function (done) {
|
||||
driver
|
||||
.elementsByClassName('UIAButton').at(5).click()
|
||||
.sleep(1000).then(function () { okIfAlert(driver); })
|
||||
.elementByXPath('//UIAWindow[1]/UIAMapView[1]')
|
||||
.execute("mobile: pinchOpen", [{startX: 114.0, startY: 198.0, endX: 257.0,
|
||||
endY: 256.0, duration: 5.0}])
|
||||
.elementByXPath('//UIAWindow[1]/UIAMapView[1]')
|
||||
.execute("mobile: pinchClose", [{startX: 114.0, startY: 198.0, endX: 257.0,
|
||||
endY: 256.0, duration: 5.0}])
|
||||
.nodeify(done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// most of these tests do not actually test anything.
|
||||
// They need to be watched to make sure they are doing something right/wrong.
|
||||
describe('testapp - touch actions @skip-ios-all -', function () {
|
||||
describe('testapp - touch actions', function () {
|
||||
var driver;
|
||||
setup(this, desired).then(function (d) { driver = d; });
|
||||
var tap = (new TouchAction()).tap();
|
||||
|
||||
function goToMap() {
|
||||
return driver
|
||||
.elementByXPathOrNull('//UIAMapView')
|
||||
.then(function (el) {
|
||||
if (!el) {
|
||||
return driver.elementsByClassName('UIAButton').at(5)
|
||||
.then(function (el) {
|
||||
var tap = (new TouchAction(driver)).tap({el: el});
|
||||
return driver.performTouchAction(tap);
|
||||
}).sleep(500)
|
||||
.then(function () { okIfAlert(driver); })
|
||||
.sleep(500);
|
||||
}
|
||||
});
|
||||
}
|
||||
describe('tap', function () {
|
||||
it('should tap on a specified element', function (done) {
|
||||
driver
|
||||
.elementsByClassName('UIAButton').at(3)
|
||||
.performTouch(tap)
|
||||
.sleep(1000).then(function () { okIfAlert(driver); })
|
||||
.then(function (el) {
|
||||
var tap = (new TouchAction()).tap({el: el});
|
||||
return driver.performTouchAction(tap);
|
||||
}).sleep(1000).then(function () { okIfAlert(driver); })
|
||||
.elementsByClassName('UIAButton').at(3)
|
||||
.then(function (el) { return el.performTouch(tap); })
|
||||
.sleep(1000).then(function () { okIfAlert(driver); })
|
||||
.elementsByClassName('UIAButton').at(3)
|
||||
.then(function (el) { return tap.performOn(el); })
|
||||
.sleep(1000).then(function () { okIfAlert(driver); })
|
||||
.sleep(3000)
|
||||
.nodeify(done);
|
||||
.then(function (el) {
|
||||
var tap = (new TouchAction(driver)).tap({el: el});
|
||||
return tap.perform();
|
||||
}).sleep(1000).then(function () { okIfAlert(driver); })
|
||||
.nodeify(done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('swipe', function () {
|
||||
it('should move the page', function (done) {
|
||||
driver
|
||||
.elementsByClassName('UIAButton').at(5)
|
||||
.performTouch(tap)
|
||||
.sleep(500).then(function () { okIfAlert(driver); })
|
||||
.sleep(500)
|
||||
.elementByXPath('//UIAWindow[1]/UIAMapView[1]')
|
||||
.performTouch((new TouchAction()).press().moveTo({ x: 0, y: 100 }).release())
|
||||
.sleep(15000)
|
||||
.resolve(goToMap())
|
||||
.elementByXPath('//UIAMapView')
|
||||
.then(function (el) {
|
||||
return driver.performTouchAction((new TouchAction())
|
||||
.press({el: el}).moveTo({el: el, x: 0, y: 100 }).release());
|
||||
}).sleep(5000)
|
||||
.nodeify(done);
|
||||
});
|
||||
});
|
||||
@@ -68,38 +58,48 @@ describe('testapp - touch actions @skip-ios-all -', function () {
|
||||
describe('wait', function () {
|
||||
it('should move the page and wait a bit', function (done) {
|
||||
driver
|
||||
.elementByXPath('//UIAWindow[1]/UIAMapView[1]')
|
||||
.performTouch(new TouchAction().press().moveTo({ x: 0, y: 100 })
|
||||
.wait({ ms: 5000 }).moveTo({ x: 0, y: -100 }).release())
|
||||
.sleep(15000)
|
||||
.resolve(goToMap())
|
||||
.elementByXPath('//UIAMapView')
|
||||
.then(function (el) {
|
||||
return driver.performTouchAction(
|
||||
new TouchAction().press({el: el}).moveTo({el: el, x: 0, y: 100 })
|
||||
.wait({ ms: 5000 }).moveTo({el: el, x: 0, y: 0 }).release());
|
||||
}).sleep(5000)
|
||||
.nodeify(done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('pinch', function () {
|
||||
it('should do some pinching', function (done) {
|
||||
var multiAction = (new MultiAction()).add(
|
||||
(new TouchAction()).press().moveTo({ x: -100, y: 0 }).release(),
|
||||
(new TouchAction()).press().moveTo({ x: 100, y: 0 }).release()
|
||||
);
|
||||
driver
|
||||
.sleep(500)
|
||||
.elementByXPath('//UIAWindow[1]/UIAMapView[1]')
|
||||
.performMultiTouch(multiAction)
|
||||
.sleep(15000)
|
||||
.resolve(goToMap())
|
||||
.elementByXPath('//UIAMapView')
|
||||
.then(function (el) {
|
||||
var multiAction = (new MultiAction()).add(
|
||||
(new TouchAction()).press({el: el}).moveTo({el: el, x: 0, y: 0 }).release(),
|
||||
(new TouchAction()).press({el: el}).moveTo({el: el, x: 100, y: 100 }).release()
|
||||
);
|
||||
return driver
|
||||
.performMultiAction(multiAction);
|
||||
})
|
||||
.sleep(5000)
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
it('should do more involved pinching in and out', function (done) {
|
||||
var multiAction = (new MultiAction()).add(
|
||||
(new TouchAction()).press().moveTo({ x: -100, y: 0 }).wait(3000).moveTo({ x: 100, y: 0 }).release(),
|
||||
(new TouchAction()).press().moveTo({ x: 100, y: 0 }).wait({ ms: 3000 }).moveTo({ x: -100, y: 0 }).release()
|
||||
);
|
||||
driver
|
||||
.sleep(500)
|
||||
.elementByXPath('//UIAWindow[1]/UIAMapView[1]')
|
||||
.performMultiTouch(multiAction)
|
||||
.sleep(15000)
|
||||
.resolve(goToMap())
|
||||
.elementByXPath('//UIAMapView')
|
||||
.then(function (el) {
|
||||
var multiAction = (new MultiAction()).add(
|
||||
(new TouchAction()).press({el: el}).moveTo({el: el, x: 25, y: 25 })
|
||||
.wait(3000).moveTo({el: el, x: 100, y: 100 }).release(),
|
||||
(new TouchAction()).press({el: el}).moveTo({el: el, x: 100, y: 0 })
|
||||
.wait({ ms: 3000 }).moveTo({el: el, x: 0, y: 0 }).release()
|
||||
);
|
||||
return driver.performMultiAction(multiAction);
|
||||
})
|
||||
.sleep(5000)
|
||||
.nodeify(done);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user