Merge pull request #2628 from sebv/master

ios6 testapp and uicatalog test fixes
This commit is contained in:
seb vincent
2014-05-21 19:23:16 +08:00
39 changed files with 1222 additions and 25 deletions

View File

@@ -27,7 +27,7 @@ describe('testapp - device', function () {
});
});
describe('deviceName', function () {
describe('deviceName @skip-ios6', function () {
var newDesired = _.extend(_.clone(desired), {deviceName: "iFailure 3.5-inch"});
var session = initSession(newDesired, {'no-retry': true});

View File

@@ -0,0 +1,71 @@
"use strict";
var env = require('../../../helpers/env')
, setup = require("../../common/setup-base")
, desired = require('./desired')
, io = require('socket.io-client')
, Q = require('q');
// setup websocket client...
var options = {
transports: ['websocket'],
'force new connection': true
};
describe('uicatalog - alerts @skip-ios7', function () {
var alertTag = env.IOS7 ? '@label' : '@value';
function waitForAlert() {
var deferred = Q.defer();
var client = io.connect('http://127.0.0.1:' + env.APPIUM_PORT, options);
client.on('alert', function () {
client.disconnect();
deferred.resolve();
});
return deferred.promise;
}
describe('alert dialog detection', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should detect Show Simple', function (done) {
driver
.elementByXPath("//UIAStaticText[contains(@label,'Alerts')]").click()
.waitForElementByXPath("//UIAStaticText[contains(" + alertTag + ",'Show Simple')]", 10000, 1000)
.elementsByXPath("//UIAStaticText[contains(" + alertTag + ",'Show Simple')]")
.at(1).click()
.resolve(waitForAlert())
.nodeify(done);
});
});
describe('alert dialog detection', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should detect Show OK-Cancel', function (done) {
driver
.elementByXPath("//UIAStaticText[contains(@label,'Alerts')]").click()
.waitForElementByXPath("//UIAStaticText[contains(" + alertTag + ",'Show OK-Cancel')]", 10000, 1000)
.elementsByXPath("//UIAStaticText[contains(" + alertTag + ",'Show OK-Cancel')]")
.at(1).click()
.resolve(waitForAlert())
.nodeify(done);
});
});
describe('alert dialog detection', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should detect Show Custom', function (done) {
driver
.elementByXPath("//UIAStaticText[contains(@label,'Alerts')]").click()
.waitForElementByXPath("//UIAStaticText[contains(" + alertTag + ",'Show Custom')]", 10000, 1000)
.elementsByXPath("//UIAStaticText[contains(" + alertTag + ",'Show Custom')]")
.at(1).click()
.resolve(waitForAlert())
.nodeify(done);
});
});
});

View File

@@ -0,0 +1,69 @@
"use strict";
var env = require('../../../helpers/env')
, setup = require("../../common/setup-base")
, desired = require('./desired');
describe('uicatalog - basic @skip-ios7', function () {
describe('api', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
if (env.FAST_TESTS) {
beforeEach(function (done) {
driver
.back()
.nodeify(function () { done(); });
});
}
it('should confirm element is not visible', function (done) {
driver
.elementByClassName('UIATableCell').click()
.elementByName("UIButtonTypeContactAdd").isDisplayed()
.should.not.eventually.be.ok
.nodeify(done);
});
it('should confirm element is visible', function (done) {
driver
.elementByClassName('UIATableCell').click()
.elementByName("UIButtonTypeRoundedRect").isDisplayed()
.should.eventually.be.ok
.nodeify(done);
});
it('should confirm element is selected @skip-ios7', function (done) {
driver
.elementByXPath("//UIATableCell/UIAStaticText[contains(@label, 'Pickers')]")
.click()
.elementByXPath("//UIAButton[contains(@label, 'UIPicker')]")
.isSelected().should.eventually.be.ok
.nodeify(done);
});
it('should confirm element is not selected returns false', function (done) {
driver
.elementByXPath("//UIATableCell/UIAStaticText[contains(@label, 'Pickers')]")
.click()
.elementByXPath("//UIAButton[contains(@label, 'Custom')]")
.isSelected().should.not.eventually.be.ok
.nodeify(done);
});
});
describe('appium ios @skip-ci', function () {
// todo: check this test, it does not do what it says
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should go back to using app from before', function (done) {
driver
.elementsByClassName('UIATableView')
.should.eventually.have.length.above(0)
.nodeify(done);
});
});
});

View File

@@ -0,0 +1,52 @@
"use strict";
var env = require('../../../helpers/env')
, setup = require("../../common/setup-base")
, desired = require('./desired');
describe('uicatalog - controls @skip-ios7', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
if (env.FAST_TESTS) {
afterEach(function (done) {
driver
.clickBack()
.nodeify(done);
});
}
it('should be able to get and set a picker value', function (done) {
var picketIdx = env.IOS7 ? 0 : 2; // TODO: why?
driver
.elementByXPath("//UIAStaticText[contains(@label,'Pickers')]").click()
.elementsByClassName("UIAPicker").at(picketIdx)
.elementByClassName('>', "UIAPickerWheel")
.then(function (wheel) {
return wheel
.getAttribute("values").then(function (values) {
return values[1];
}).should.become("Chris Armstrong")
.then(function () {
return wheel.type("Serena Auroux")
.getAttribute("value").should.become("Serena Auroux. 3 of 7");
});
})
.nodeify(done);
});
it('should be able to get and set a slider value', function (done) {
driver
.elementByXPath("//UIAStaticText[contains(@label,'Controls')]").click()
.elementByClassName("UIASlider").then(function (slider) {
return slider
.getAttribute("value").should.become('50%')
.then(function () {
return slider.sendKeys(0.8).getAttribute("value").then(function (val) {
['80%', '82%'].should.include(val); // irregular 82% occurence
});
});
}).nodeify(done);
});
});

View File

@@ -0,0 +1,5 @@
"use strict";
module.exports = {
app: "assets/UICatalog6.1.app.zip"
};

View File

@@ -0,0 +1,36 @@
"use strict";
var env = require('../../../helpers/env'),
setup = require("../../common/setup-base"),
desired = require('./desired');
describe('uicatalog - device @skip-ios7', function () {
describe('lock device', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
var allowance = env.IOS7 ? 5 : 2;
it("should lock the device for 4 of seconds (+/- " + allowance + " secs)", function (done) {
var before = new Date().getTime() / 1000;
driver
.lockDevice(4)
.then(function () {
var now = (new Date().getTime() / 1000);
(now - before).should.be.above(4);
(now - before).should.be.below(4 + allowance + 1);
}).nodeify(done);
});
});
describe('background app', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it("should background the app for 4 of seconds (+/- 6 secs)", function (done) {
var before = new Date().getTime() / 1000;
driver
.backgroundApp(4)
.then(function () {
((new Date().getTime() / 1000) - before).should.be.below(11);
}).nodeify(done);
});
});
});

View File

@@ -0,0 +1,26 @@
"use strict";
var setup = require("../../common/setup-base"),
desired = require('./desired');
describe('uicatalog - execute @skip-ios7', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should do UIAutomation commands if not in web frame', function (done) {
driver
.execute("UIATarget.localTarget().frontMostApp().bundleID()")
.should.eventually.include(".UICatalog")
.nodeify(done);
});
it('should not fail if UIAutomation command blows up', function (done) {
driver
.execute("UIATarget.foobarblah()")
.should.be.rejectedWith(/status: 17/)
.nodeify(done);
});
it('should not fail with quotes', function (done) {
driver.execute('console.log(\'hi\\\'s\');')
.nodeify(done);
});
});

View File

@@ -0,0 +1,327 @@
"use strict";
var setup = require("../../common/setup-base")
, desired = require('./desired')
, Q = require("q")
, _ = require("underscore")
, spinWait = require("../../../helpers/spin.js").spinWait;
describe('uicatalog - find element @skip-ios7', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should find a single element by id @skip-ios6', function (done) {
// ById don't seem to be supported since appium 1.0
driver
.elementById('ButtonsExplain')
.should.eventually.exist
.nodeify(done);
});
it('should find a single element by id wrapped in array for multi @skip-ios6', function (done) {
// ById don't seem to be supported since appium 1.0
driver
.elementsById('ButtonsExplain')
.then(function (els) {
els.length.should.equal(1);
})
.nodeify(done);
});
it('should find a single element using elementByName', function (done) {
driver
.elementByName('UICatalog').then(function (el) {
el.should.exist;
}).nodeify(done);
});
it('should find an element within descendants', function (done) {
driver
.elementByClassName('UIATableView').then(function (el) {
el.should.exist;
return el.elementByClassName('UIAStaticText').getAttribute('name')
.should.become("Buttons, Various uses of UIButton");
}).nodeify(done);
});
it('should not find an element not within itself', function (done) {
driver
.elementByClassName('UIATableView').then(function (el) {
el.should.exist;
return el.elementByClassName('UIANavigationBar')
.should.be.rejectedWith(/status: 7/);
}).nodeify(done);
});
it('should find some elements within itself', function (done) {
driver
.elementByClassName('UIATableCell').then(function (el) {
el.should.exist;
return el.elementsByClassName('UIAStaticText')
.should.eventually.have.length(1);
}).nodeify(done);
});
it('should not find elements not within itself', function (done) {
driver
.elementByClassName('UIATableCell').then(function (el) {
el.should.exist;
el.elementsByClassName('UIANavigationBar')
.should.eventually.have.length(0);
}).nodeify(done);
});
it('should not allow found elements to be mixed up', function (done) {
var el1, el2, el1Name, el2Name;
driver
.elementByClassName('UIATableCell')
.then(function (el) {
el1 = el;
return el1.getAttribute('name').then(function (name) {
el1Name = name;
});
})
.elementByClassName('UIATableCell')
.click()
.delay(1000)
.elementByClassName('UIATableCell')
.then(function (el) {
el2 = el;
el2.value.should.not.equal(el1.value);
return el2.getAttribute('name').then(function (name) {
el2Name = name;
});
}).then(function () {
el1.value.should.not.equal(el2.value);
el1Name.should.not.equal(el2Name);
// el1 is gone, so it doesn't have a name anymore
return el1.getAttribute('name')
.should.eventually.equal("");
})
.back()
.nodeify(done);
});
// TODO: CI hangs on those disabling, investigation needed
describe('find elements using accessibility id locator strategy @skip-ci', function () {
it('should find an element by name', function (done) {
driver.element('accessibility id', 'UICatalog').then(function (el) {
el.should.exist;
}).nodeify(done);
});
it('should find a deeply nested element by name', function (done) {
driver.element('accessibility id', 'Toolbar, Uses of UIToolbar').then(function (el) {
el.should.exist;
}).nodeify(done);
});
it('should find an element by name beneath another element', function (done) {
driver.element('accessibility id', 'Empty list').then(function (el) {
el.element('accessibility id', 'Controls, Various uses of UIControl').then(function (innerEl) {
innerEl.should.exist;
}).nodeify(done);
});
});
it('should return an array of one element if the plural "elements" is used', function (done) {
driver.elements('accessibility id', 'UICatalog').then(function (els) {
els.length.should.equal(1);
}).nodeify(done);
});
});
describe('findElementsByClassName', function () {
it('should return all image elements with internally generated ids', function (done) {
driver.elementsByClassName('UIAImage').then(function (els) {
els.length.should.be.above(0);
_(els).each(function (el) {
el.should.exist;
});
}).nodeify(done);
});
});
describe('findElementsByClassName textfield case', function () {
after(function (done) {
driver.clickBack()
.nodeify(done);
});
it('should find only one textfield', function (done) {
driver
.elementsByClassName('UIATableCell').then(function (els) { return els[2]; })
.click()
.elementByName('Rounded')
.elementsByClassName('>', 'UIATextField')
.should.eventually.have.length(1)
.nodeify(done);
});
});
describe('findElement(s)ByXPath', function () {
var setupXpath = function (driver) {
return driver.elementByClassName('UIATableCell').click();
};
if (process.env.FAST_TESTS) {
afterEach(function (done) {
driver
.back()
.nodeify(done);
});
}
it('should return the last button', function (done) {
driver
.resolve(setupXpath(driver))
.elementByXPath("//UIAButton[last()]").text()
.should.become("Add contact")
.nodeify(done);
});
it('should return a single element', function (done) {
driver
.resolve(setupXpath(driver))
.elementByXPath("//UIAButton").text()
.should.become("Back")
.nodeify(done);
});
it('should return multiple elements', function (done) {
driver
.resolve(setupXpath(driver))
.elementsByXPath("//UIAButton")
.should.eventually.have.length.above(5)
.nodeify(done);
});
it('should filter by name', function (done) {
driver
.resolve(setupXpath(driver))
.elementByXPath("//UIAButton[@name='Rounded']").text()
.should.become("Rounded")
.nodeify(done);
});
it('should know how to restrict root-level elements', function (done) {
driver
.resolve(setupXpath(driver))
.elementByXPath("/UIAButton")
.should.be.rejectedWith(/status: 7/)
.nodeify(done);
});
it('should search an extended path by child', function (done) {
driver
.resolve(setupXpath(driver))
.then(function () {
return spinWait(function () {
return driver.elementByXPath("//UIANavigationBar/UIAStaticText")
.text().should.become('Buttons');
});
}).nodeify(done);
});
it('should search an extended path by descendant', function (done) {
driver
.resolve(setupXpath(driver))
.elementsByXPath("//UIATableCell//UIAButton").then(function (els) {
return Q.all(_(els).map(function (el) { return el.text(); }));
}).then(function (texts) {
texts.should.not.include("Button");
texts.should.include("Gray");
}).nodeify(done);
});
it('should filter by indices', function (done) {
driver
.resolve(setupXpath(driver))
.then(function () {
return spinWait(function () {
return driver.elementByXPath("//UIATableCell[2]//UIAStaticText[1]").getAttribute('name')
.should.become("ButtonsViewController.m:\r(UIButton *)grayButton");
});
}).nodeify(done);
});
it('should filter by partial text', function (done) {
driver
.resolve(setupXpath(driver))
.elementByXPath("//UIATableCell//UIAButton[contains(@name, 'Gr')]").text()
.should.become("Gray")
.nodeify(done);
});
});
describe('FindElement(s)ByUIAutomation', function () {
var byUIA = '-ios uiautomation';
var filterDisplayed = function (els) {
return Q.all(_.map(els, function (el) { return el.isDisplayed(); }))
.then(function (res) { return _.filter(els, function (el, i) { return res[i]; }); });
};
before(function (done) {
driver
.element(byUIA, '.navigationBars()[0]')
.getAttribute('name').then(function (name) {
if (name !== 'UICatalog') {
return driver.back().delay(2000);
} else {
return Q.delay(500);
}
}
).nodeify(done);
});
it('should process most basic UIAutomation query', function (done) {
driver
.elements(byUIA, '.elements()').then(filterDisplayed)
.should.eventually.have.length(2)
.nodeify(done);
});
it('should process UIAutomation queries if user leaves out the first period', function (done) {
driver
.elements(byUIA, 'elements()').then(filterDisplayed)
.should.eventually.have.length(2)
.nodeify(done);
});
it('should get a single element', function (done) {
driver.element(byUIA, '.elements()[0]').getAttribute('name')
.should.become('UICatalog')
.nodeify(done);
});
it('should get a single element', function (done) {
driver.element(byUIA, '.elements()[1]').getAttribute('name')
.should.become('Empty list')
.nodeify(done);
});
it('should get single element as array', function (done) {
driver
.elements(byUIA, '.tableViews()[0]')
.should.eventually.have.length(1)
.nodeify(done);
});
it('should find elements by index multiple times', function (done) {
driver.element(byUIA, '.elements()[1].cells()[2]').getAttribute('name')
.should.become('TextFields, Uses of UITextField')
.nodeify(done);
});
it('should find elements by name', function (done) {
driver.element(byUIA, '.elements()["UICatalog"]').getAttribute('name')
.should.become('UICatalog')
.nodeify(done);
});
it('should find elements by name and index', function (done) {
driver.element(byUIA, '.elements()["Empty list"].cells()[3]').getAttribute('name')
.should.become('SearchBar, Use of UISearchBar')
.nodeify(done);
});
describe('start from a given context instead of root target', function () {
it('should process a simple query', function (done) {
driver.element(byUIA, '.elements()[1]').then(function (el) {
el
.elements(byUIA, '.elements()')
.should.eventually.have.length(12)
.nodeify(done);
});
});
it('should find elements by name', function (done) {
driver.element(byUIA, '.elements()[1]').then(function (el) {
el
.element(byUIA, '.elements()["Buttons, Various uses of UIButton"]')
.should.eventually.exist
.nodeify(done);
});
});
});
});
});

View File

@@ -0,0 +1,490 @@
"use strict";
var env = require('../../../helpers/env')
, setup = require("../../common/setup-base")
, desired = require('./desired')
, spinWait = require('../../../helpers/spin.js').spinWait
, textBlock = "Now is the time for all good developers to come to serve their country.\n";
// sebv: had to cut down original textBlock, cause text retrieved depends on device size
// textBlock = "Now is the time for all good developers to come to serve their country.\n\nNow is the time for all good developers to come to serve their country.\n\nThis text view can also use attributed strings.";
var SLOW_DOWN_MS = 1000;
describe('uicatalog - gestures @skip-ios7', function () {
describe('flick @skip-ios7', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
if (env.FAST_TESTS) {
afterEach(function (done) {
driver
.flick(0, 100, false)
.flick(0, 100, false)
.sleep(SLOW_DOWN_MS)
.nodeify(done);
});
}
it('should work via webdriver method', function (done) {
driver
.elementByClassName('UIATableCell').getLocation()
.then(function (location1) {
return driver
.flick(0, -100, false)
.elementByClassName('UIATableCell').getLocation()
.then(function (location2) {
location2.x.should.equal(location1.x);
location2.y.should.not.equal(location1.y);
});
}).nodeify(done);
});
it('should work via mobile only method', function (done) {
driver
.elementByClassName('UIATableCell').getLocation()
.then(function (location1) {
return driver
.execute("mobile: flick", [{endX: 0, endY: 0}])
.elementByClassName('UIATableCell').getLocation()
.then(function (location2) {
location2.x.should.equal(location1.x);
location2.y.should.not.equal(location1.y);
});
}).nodeify(done);
});
it('should not complete instantaneously', function (done) {
var start = Date.now();
driver
.execute("mobile: flick", [{endX: 0, endY: 0}])
.then(function () { (Date.now() - start).should.be.above(2500); })
.nodeify(done);
});
it('should work via mobile only method with percentage', function (done) {
var opts = {startX: 0.75, startY: 0.75, endX: 0.25, endY: 0.25};
driver
.elementByClassName('UIATableCell').getLocation()
.then(function (location1) {
return driver
.execute("mobile: flick", [opts])
.elementByClassName('UIATableCell').getLocation()
.then(function (location2) {
location2.x.should.equal(location1.x);
location2.y.should.not.equal(location1.y);
});
}).nodeify(done);
});
});
describe('swipe gesture @skip-ios7', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
if (env.FAST_TESTS) {
afterEach(function (done) {
driver
.flick(0, 70, false)
.flick(0, 70, false)
.sleep(SLOW_DOWN_MS)
.nodeify(done);
});
}
it('should work with wd function in pixels', function (done) {
driver
.elementByClassName('UIATableCell').getLocation()
.then(function (location1) {
return spinWait(function () {
return driver
.flick(0, -70, true)
.elementByClassName('UIATableCell').getLocation()
.then(function (location2) {
((location2.x === location1.x) &&
(location2.y !== location1.y)
).should.be.ok;
});
}, 5000);
}).nodeify(done);
});
it('should work with wd function in percent', function (done) {
driver
.elementByClassName('UIATableCell').getLocation()
.then(function (location1) {
return driver
.flick(0, -0.1, true) // flaky
.flick(0, -0.1, true)
.flick(0, -0.1, true)
.elementByClassName('UIATableCell').getLocation()
.then(function (location2) {
location2.x.should.equal(location1.x);
location2.y.should.not.equal(location1.y, '===y');
});
}).nodeify(done);
});
it('should work with mobile function in pixels', function (done) {
var opts = {startX: 50, startY: 400, endX: 50, endY: 300, duration: 2};
driver
.elementByClassName('UIATableCell').getLocation()
.then(function (location1) {
return spinWait(function () {
return driver
.execute("mobile: swipe", [opts])
.elementByClassName('UIATableCell').getLocation()
.then(function (location2) {
location2.x.should.equal(location1.x);
location2.y.should.not.equal(location1.y);
});
});
}).nodeify(done);
});
it('should work with mobile function in percent', function (done) {
var opts = {startX: 0.5, startY: 0.9, endX: 0.5, endY: 0.7, duration: 2};
driver
.elementByClassName('UIATableCell').getLocation()
.then(function (location1) {
return spinWait(function () {
return driver
.execute("mobile: swipe", [opts])
.elementByClassName('UIATableCell').getLocation()
.then(function (location2) {
location2.x.should.equal(location1.x);
location2.y.should.not.equal(location1.y);
});
});
}).nodeify(done);
});
it('should not complete instantaneously', function (done) {
var start = Date.now();
var opts = {startX: 0.5, startY: 0.9, endX: 0.5, endY: 0.7, duration: 2};
driver
.execute("mobile: swipe", [opts])
.then(function () {
(Date.now() - start).should.be.above(1999);
}).nodeify(done);
});
});
describe("flick element @skip-ios7", function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
if (env.FAST_TESTS) {
afterEach(function (done) {
driver
.elementByClassName("UIASlider")
.then(function (el) { if (el) return el.sendKeys(0.5); })
.then(function (el) { if (el) return el.sendKeys(0.5); })
.clickBack()
.sleep(SLOW_DOWN_MS)
.nodeify(done);
});
}
it("slider value should change", function (done) {
var valueBefore, slider;
driver
.elementsByClassName('UIATableCell').then(function (els) { return els[1]; })
.click()
.elementByClassName("UIASlider").then(function (el) { slider = el; })
.then(function () { return slider.getAttribute("value"); })
.then(function (value) { valueBefore = value; })
.then(function () { return slider.flick(-0.5, 0, 1); })
.then(function () { return slider.getAttribute("value"); })
.then(function (valueAfter) {
valueBefore.should.not.equal("0%");
valueAfter.should.equal("0%");
}).nodeify(done);
});
it("should work with mobile flick", function (done) {
var valueBefore, slider;
driver
.elementsByClassName('UIATableCell').then(function (els) { return els[1]; })
.click()
.elementByClassName("UIASlider").then(function (el) { slider = el; })
.then(function () { return slider.getAttribute("value"); })
.then(function (value) { valueBefore = value; })
.then(function () {
var opts = {element: slider.value, endX: -50, endY: 0};
return driver.execute("mobile: flick", [opts]);
})
.then(function () { return slider.getAttribute("value"); })
.then(function (valueAfter) {
valueBefore.should.not.equal("0%");
valueAfter.should.equal("0%");
}).nodeify(done);
});
it("should work with mobile flick and percent", function (done) {
var valueBefore, slider;
driver
.elementsByClassName('UIATableCell').then(function (els) { return els[1]; })
.click()
.elementByClassName("UIASlider").then(function (el) { slider = el; })
.then(function () { return slider.getAttribute("value"); })
.then(function (value) { valueBefore = value; })
.then(function () {
var opts = {element: slider.value, startX: 0.5, startY: 0.0,
endX: 0.0, endY: 0.0};
return driver.execute("mobile: flick", [opts]);
})
.then(function () { return slider.getAttribute("value"); })
.then(function (valueAfter) {
valueBefore.should.not.equal("0%");
valueAfter.should.equal("0%");
}).nodeify(done);
});
});
describe("swipe element @skip-ios7", function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
if (env.FAST_TESTS) {
afterEach(function (done) {
driver
.elementByClassName("UIASlider")
.then(function (el) { if (el) return el.sendKeys(0.5); })
.clickBack()
.sleep(SLOW_DOWN_MS)
.nodeify(done);
});
}
it("slider value should change", function (done) {
var valueBefore, slider;
driver
.elementsByClassName('UIATableCell').then(function (els) { return els[1]; })
.click()
.elementByClassName("UIASlider").then(function (el) { slider = el; })
.then(function () { return slider.getAttribute("value"); })
.then(function (value) { valueBefore = value; })
.then(function () {
var opts = {startX: 0.5, startY: 0.5, endX: 0.25, endY: 0.5,
duration: 0.3, element: slider.value};
return driver.execute("mobile: swipe", [opts]);
})
.then(function () { return slider.getAttribute("value"); })
.then(function (valueAfter) {
valueBefore.should.equal("50%");
valueAfter.should.equal("20%");
}).nodeify(done);
});
it("slider value should change by pixels", function (done) {
var valueBefore, slider;
driver
.elementsByClassName('UIATableCell').then(function (els) { return els[1]; })
.click()
.elementByClassName("UIASlider").then(function (el) { slider = el; })
.then(function () { return slider.getAttribute("value"); })
.then(function (value) { valueBefore = value; })
.then(function () {
var opts = {endX: 15, endY: 10, duration: 0.3, element: slider.value};
return driver.execute("mobile: swipe", [opts]);
})
.then(function () { return slider.getAttribute("value"); })
.then(function (valueAfter) {
valueBefore.should.equal("50%");
valueAfter.should.equal("5%");
}).nodeify(done);
});
});
describe('complex tap', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
if (env.FAST_TESTS) {
afterEach(function (done) {
driver
.clickBack()
.sleep(SLOW_DOWN_MS)
.nodeify(done);
});
}
it('should work with custom options', function (done) {
var tapOpts = {
tapCount: 1 // how many taps
, duration: 2.3 // how long
, touchCount: 3 // how many fingers
, x: 100 // in pixels from left
, y: 250 // in pixels from top
};
driver
.execute("mobile: tap", [tapOpts])
.elementByClassName("UIATextView").text()
.then(function (text) {
text.should.include(textBlock);
})
.nodeify(done);
});
it('should work in relative units @skip-ios7', function (done) {
var tapOpts = {
tapCount: 1 // how many taps
, duration: 2.3 // how long
, touchCount: 3 // how many fingers
, x: 0.5 // 50% from left of screen
, y: 0.55 // 55% from top of screen
};
driver
.execute("mobile: tap", [tapOpts])
.elementByClassName('UIATextView').text()
.then(function (text) {
text.should.include(textBlock);
})
.nodeify(done);
});
it('should work with default options @skip-ios7', function (done) {
driver
.execute("mobile: tap")
.elementByClassName('UIATextView').text()
.then(function (text) {
text.should.include(textBlock);
})
.nodeify(done);
});
});
describe('complex tap on element', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
if (env.FAST_TESTS) {
afterEach(function (done) {
driver
.clickBack()
.sleep(SLOW_DOWN_MS)
.nodeify(done);
});
}
it('should work in relative units', function (done) {
driver
.elementsByClassName('UIATableCell').then(function (els) { return els[4]; })
.then(function (el) {
var tapOpts = {
x: 0.5 // in relative width from left
, y: 0.5 // in relative height from top
, element: el.value
};
return driver
.execute("mobile: tap", [tapOpts]);
}).elementByClassName('UIATextView').text()
.then(function (text) {
text.should.include(textBlock);
}).nodeify(done);
});
it('should work in pixels', function (done) {
driver
.elementsByClassName('UIATableCell').then(function (els) { return els[4]; })
.then(function (el) {
var tapOpts = {
x: 150 // in pixels from left
, y: 30 // in pixels from top
, element: el.value
};
return driver
.execute("mobile: tap", [tapOpts]);
}).elementByClassName('UIATextView').text()
.then(function (text) {
text.should.include(textBlock);
}).nodeify(done);
});
});
describe('scroll to element @skip-ios7', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
if (env.FAST_TESTS) {
afterEach(function (done) {
driver
.flick(0, 100, false)
.flick(0, 100, false)
.sleep(SLOW_DOWN_MS)
.nodeify(done);
});
}
it('should bring the element into view', function (done) {
var el, scrollOpts, location1;
driver.elementsByClassName('UIATableCell').then(function (els) {
el = els[10];
scrollOpts = { element: el.value };
})
.then(function () { return el.getLocation(); })
.then(function (loc) { location1 = loc; })
.then(function () {
return driver.execute("mobile: scrollTo", [scrollOpts]);
}).then(function () { return el.getLocation(); })
.then(function (location2) {
location2.x.should.equal(location1.x);
location2.y.should.not.equal(location1.y);
}).nodeify(done);
});
});
describe('mobile: scroll', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should scroll down and up', function (done) {
var firstEl, location1, location2;
driver
.elementByClassName('UIATableCell')
.then(function (el) { firstEl = el; return el.getLocation(); })
.then(function (loc) { location1 = loc; })
.then(function () {
return driver.execute("mobile: scroll", [{direction: 'down'}]);
})
.then(function () { return firstEl.getLocation(); })
.then(function (loc2) {
location2 = loc2;
loc2.x.should.equal(location1.x);
loc2.y.should.not.equal(location1.y);
})
.then(function () {
return driver.execute("mobile: scroll", [{direction: 'up'}]);
})
.then(function () { return firstEl.getLocation(); })
.then(function (loc3) {
loc3.x.should.equal(location2.x);
loc3.y.should.not.equal(location2.y);
})
.nodeify(done);
});
it('should scroll down and up using element', function (done) {
var firstEl, location1, location2, table_view;
driver.elementByClassName('UIATableView').then(function (el) {
table_view = el;
})
.elementByClassName('UIATableCell')
.then(function (el) { firstEl = el; return el.getLocation(); })
.then(function (loc) { location1 = loc; })
.then(function () {
return driver.execute("mobile: scroll", [{element: table_view.value, direction: 'down'}]);
})
.then(function () { return firstEl.getLocation(); })
.then(function (loc2) {
location2 = loc2;
loc2.x.should.equal(location1.x);
loc2.y.should.not.equal(location1.y);
})
.then(function () {
return driver.execute("mobile: scroll", [{element: table_view.value, direction: 'up'}]);
})
.then(function () { return firstEl.getLocation(); })
.then(function (loc3) {
loc3.x.should.equal(location2.x);
loc3.y.should.not.equal(location2.y);
})
.nodeify(done);
});
});
describe('mobile shake', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should not error', function (done) {
driver.shakeDevice().nodeify(done);
});
});
});

View File

@@ -0,0 +1,22 @@
"use strict";
var env = require('../../../../helpers/env')
, setup = require("../../../common/setup-base")
, path = require('path');
describe('uicatalog - basic @skip-ios7', function () {
describe('load zipped app', function () {
var driver;
var appZip = path.resolve(env.SAUCE? '/Users/chef/appium' : process.cwd(), 'assets/UICatalog6.0.app.zip');
setup(this, {app: appZip})
.then(function (d) { driver = d; });
it('should load a zipped app via path', function (done) {
driver.elementByClassName('UIATableView')
.should.eventually.exist
.nodeify(done);
});
});
});

View File

@@ -0,0 +1,20 @@
"use strict";
var setup = require("../../../common/setup-base");
describe('uicatalog - basic @skip-ios7', function () {
describe('load zipped app with relative path', function () {
var driver;
var appZip = "assets/UICatalog6.0.app.zip";
setup(this, {app: appZip})
.then(function (d) { driver = d; });
it('should load a zipped app via path', function (done) {
driver.elementByClassName('UIATableView')
.should.eventually.exist
.nodeify(done);
});
});
});

View File

@@ -0,0 +1,21 @@
"use strict";
var setup = require("../../../common/setup-base");
describe('uicatalog - basic @skip-ios7', function () {
describe('load zipped app via url', function () {
var driver;
var appUrl = 'http://appium.s3.amazonaws.com/UICatalog6.0.app.zip';
setup(this, {app: appUrl})
.then(function (d) { driver = d; });
it('should load a zipped app via url', function (done) {
driver
.elementByClassName('UIATableView')
.should.eventually.exist
.nodeify(done);
});
});
});

View File

@@ -0,0 +1,20 @@
"use strict";
var setup = require("../../common/setup-base"),
desired = require('./desired');
describe('uicatalog - move @skip-ios7', function () {
describe('moveTo and click', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should be able to click on arbitrary x-y elements', function (done) {
driver
.elementByClassName('UIATableCell').moveTo(10, 10).click()
.elementByXPath("//UIAButton[@name='Rounded']")
.should.eventually.exist
.nodeify(done);
});
});
});

View File

@@ -0,0 +1,23 @@
"use strict";
var setup = require("../../common/setup-base"),
desired = require('./desired');
describe('uicatalog - reset @skip-ios7', function () {
describe('app reset', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it("should be able to find elements after a soft reset", function (done) {
driver
.elementsByClassName('UIATableView')
.should.eventually.have.length(1)
.resetApp()
.sleep(3000)
.elementsByClassName('UIATableView')
.should.eventually.have.length(1)
.nodeify(done);
});
});
});

View File

@@ -0,0 +1,15 @@
"use strict";
var setup = require("../../common/setup-base"),
desired = require('./desired');
describe('uicatalog - contexts @skip-ios7', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('getting contexts should do nothing when no webview open', function (done) {
driver
.contexts().should.eventually.have.length(1)
.nodeify(done);
});
});

View File

@@ -12,7 +12,7 @@ var options = {
'force new connection': true
};
describe('uicatalog - alerts', function () {
describe('uicatalog - alerts @skip-ios6', function () {
var alertTag = env.IOS7 ? '@label' : '@value';

View File

@@ -4,7 +4,7 @@ var env = require('../../../helpers/env')
, setup = require("../../common/setup-base")
, desired = require('./desired');
describe('uicatalog - basic', function () {
describe('uicatalog - basic @skip-ios6', function () {
var textTag = env.IOS7 ? '@label' : '@value';
describe('api', function () {

View File

@@ -4,7 +4,7 @@ var env = require('../../../helpers/env')
, setup = require("../../common/setup-base")
, desired = require('./desired');
describe('uicatalog - controls', function () {
describe('uicatalog - controls @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -4,7 +4,7 @@ var env = require('../../../helpers/env'),
setup = require("../../common/setup-base"),
desired = require('./desired');
describe('uicatalog - device', function () {
describe('uicatalog - device @skip-ios6', function () {
describe('lock device', function () {
var driver;

View File

@@ -3,7 +3,7 @@
var setup = require("../../common/setup-base"),
desired = require('./desired');
describe('uicatalog - execute', function () {
describe('uicatalog - execute @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -4,7 +4,7 @@ var setup = require("../../common/setup-base")
, desired = require('./desired')
, _ = require('underscore');
describe('uicatalog - find - basics', function () {
describe('uicatalog - find - basics @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -3,7 +3,7 @@
var setup = require("../../common/setup-base")
, desired = require('./desired');
describe('uicatalog - find by accessibility id', function () {
describe('uicatalog - find by accessibility id @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -6,7 +6,7 @@ var setup = require("../../common/setup-base")
, _ = require("underscore")
, filterVisible = require('../../../helpers/ios-uiautomation').filterVisible;
describe('uicatalog - find by ios-ui-automation', function () {
describe('uicatalog - find by ios-ui-automation @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -6,7 +6,7 @@ var setup = require("../../common/setup-base")
, _ = require("underscore")
, spinWait = require("../../../helpers/spin.js").spinWait;
describe('uicatalog - find by xpath', function () {
describe('uicatalog - find by xpath @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -6,7 +6,7 @@ var env = require('../../../../helpers/env')
var SLOW_DOWN_MS = 1000;
describe('uicatalog - gestures - complex tap', function () {
describe('uicatalog - gestures - complex tap @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -6,7 +6,7 @@ var env = require('../../../../helpers/env')
var SLOW_DOWN_MS = 1000;
describe('uicatalog - gestures - flick @skip-ios7', function () {
describe('uicatalog - gestures - flick @skip-ios7 @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -3,7 +3,7 @@
var setup = require("../../../common/setup-base")
, desired = require('../desired');
describe('uicatalog - gestures - mobile scroll', function () {
describe('uicatalog - gestures - mobile scroll @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -3,7 +3,7 @@
var setup = require("../../../common/setup-base")
, desired = require('../desired');
describe('uicatalog - gestures - mobile shake', function () {
describe('uicatalog - gestures - mobile shake @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -6,7 +6,7 @@ var env = require('../../../../helpers/env')
var SLOW_DOWN_MS = 1000;
describe('uicatalog - gestures - scroll to el @skip-ios7', function () {
describe('uicatalog - gestures - scroll to el @skip-ios7 @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -6,7 +6,7 @@ var env = require('../../../../helpers/env')
var SLOW_DOWN_MS = 1000;
describe("uicatalog - gestures - swipe element @skip-ios7", function () {
describe("uicatalog - gestures - swipe element @skip-ios7 @skip-ios6", function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -7,7 +7,7 @@ var env = require('../../../../helpers/env')
var SLOW_DOWN_MS = 1000;
describe('uicatalog - gestures - swipe @skip-ios7', function () {
describe('uicatalog - gestures - swipe @skip-ios7 @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

View File

@@ -8,7 +8,7 @@ var env = require('../../../../helpers/env')
describe('uicatalog - basic', function () {
describe('load app with absolute path', function () {
describe('load app with absolute path @skip-ios6', function () {
var driver;
var appPath = path.resolve(env.SAUCE? '/Users/chef/appium' : process.cwd(), desired.app);
setup(this, _.defaults({'app': appPath}, desired))

View File

@@ -6,7 +6,7 @@ var env = require('../../../../helpers/env')
describe('uicatalog - basic', function () {
describe('load zipped app', function () {
describe('load zipped app @skip-ios6', function () {
var driver;
var appZip = path.resolve(env.SAUCE? '/Users/chef/appium' : process.cwd(), 'assets/UICatalog6.0.app.zip');
setup(this, {app: appZip})

View File

@@ -7,7 +7,7 @@ var setup = require("../../../common/setup-base")
describe('uicatalog - basic', function () {
describe('load app with relative path', function () {
describe('load app with relative path @skip-ios6', function () {
var driver;
var appPath = path.relative(process.cwd(), desired.app);
setup(this, _.defaults({'app': appPath}, desired))

View File

@@ -4,7 +4,7 @@ var setup = require("../../../common/setup-base");
describe('uicatalog - basic', function () {
describe('load zipped app with relative path', function () {
describe('load zipped app with relative path @skip-ios6', function () {
var driver;
var appZip = "assets/UICatalog6.0.app.zip";
setup(this, {app: appZip})

View File

@@ -4,7 +4,7 @@ var setup = require("../../../common/setup-base");
describe('uicatalog - basic', function () {
describe('load zipped app via url', function () {
describe('load zipped app via url @skip-ios6', function () {
var driver;
var appUrl = 'http://appium.s3.amazonaws.com/UICatalog6.0.app.zip';
setup(this, {app: appUrl})

View File

@@ -3,7 +3,7 @@
var setup = require("../../common/setup-base"),
desired = require('./desired');
describe('uicatalog - move', function () {
describe('uicatalog - move @skip-ios6', function () {
describe('moveTo and click', function () {
var driver;

View File

@@ -3,7 +3,7 @@
var setup = require("../../common/setup-base"),
desired = require('./desired');
describe('uicatalog - reset', function () {
describe('uicatalog - reset @skip-ios6', function () {
describe('app reset', function () {
var driver;

View File

@@ -3,7 +3,7 @@
var setup = require("../../common/setup-base"),
desired = require('./desired');
describe('uicatalog - contexts', function () {
describe('uicatalog - contexts @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });