mechanic + uiauto upgrade

This commit is contained in:
sebv
2014-06-13 13:48:05 +08:00
parent 57a903585c
commit 0af9c5afa7
7 changed files with 104 additions and 44 deletions

View File

@@ -67,7 +67,6 @@ run_ios_tests() {
echo "Did not find /Applications/Xcode-$1.app, using default"
fi
fi
echo
DEVICE=$2 time $appium_mocha -g $3 -i \
test/functional/common \
test/functional/ios

View File

@@ -44,7 +44,7 @@
"appium-adb": "~1.0.2",
"appium-atoms": "~0.0.5",
"appium-instruments": "~1.0.0",
"appium-uiauto": "~1.1.0",
"appium-uiauto": "~1.2.0-beta1",
"argparse": "~0.1.15",
"async": "~0.9.0",
"binary-cookies": "~0.1.1",

View File

@@ -13,10 +13,15 @@ var options = {
};
describe('uicatalog - alerts @skip-ios7', function () {
var alertTag = env.IOS7 ? '@label' : '@value';
var driver;
setup(this, desired).then(function (d) { driver = d; });
function waitForAlert() {
// The socket.io logic below only works locally.
if (env.SAUCE) return new Q();
var deferred = Q.defer();
var client = io.connect('http://127.0.0.1:' + env.APPIUM_PORT, options);
client.on('alert', function () {
@@ -26,46 +31,51 @@ describe('uicatalog - alerts @skip-ios7', function () {
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);
});
afterEach(function (done) {
driver.back()
.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);
});
it('should detect Show Simple', function (done) {
var alertReceived;
driver
.elementByXPath("//UIAStaticText[contains(@label,'Alerts')]").click()
.waitForElementByXPath("//UIAStaticText[contains(" + alertTag + ",'Show Simple')]", 10000, 1000)
.then(function () { alertReceived = waitForAlert(); })
.elementsByXPath("//UIAStaticText[contains(" + alertTag + ",'Show Simple')]")
.at(1).click()
// .alertText().should.eventually.include('A Short Title Is Best')
.resolve(alertReceived)
.dismissAlert()
.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);
});
it('should detect Show OK-Cancel', function (done) {
var alertReceived;
driver
.elementByXPath("//UIAStaticText[contains(@label,'Alerts')]").click()
.waitForElementByXPath("//UIAStaticText[contains(" + alertTag + ",'Show OK-Cancel')]", 10000, 1000)
.then(function () { alertReceived = waitForAlert(); })
.elementsByXPath("//UIAStaticText[contains(" + alertTag + ",'Show OK-Cancel')]")
.at(1).click()
// .alertText().should.eventually.include('A Short Title Is Best')
.resolve(alertReceived)
.acceptAlert()
.nodeify(done);
});
it('should detect Show Custom', function (done) {
var alertReceived;
driver
.elementByXPath("//UIAStaticText[contains(@label,'Alerts')]").click()
.waitForElementByXPath("//UIAStaticText[contains(" + alertTag + ",'Show Custom')]", 10000, 1000)
.then(function () { alertReceived = waitForAlert(); })
.elementsByXPath("//UIAStaticText[contains(" + alertTag + ",'Show Custom')]")
.at(1).click()
// .alertText().should.eventually.include('A Short Title Is Best')
.resolve(alertReceived)
.dismissAlert()
.nodeify(done);
});
});

View File

@@ -109,7 +109,8 @@ describe('uicatalog - find element @skip-ios7', function () {
}).nodeify(done);
});
it('should find a deeply nested element by name', function (done) {
driver.element('accessibility id', 'Toolbar, Uses of UIToolbar').then(function (el) {
driver
.element('accessibility id', 'Toolbar, Uses of UIToolbar').then(function (el) {
el.should.exist;
}).nodeify(done);
});
@@ -122,7 +123,7 @@ describe('uicatalog - find element @skip-ios7', function () {
});
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);
els.length.should.equal(2);
}).nodeify(done);
});
});
@@ -154,6 +155,32 @@ describe('uicatalog - find element @skip-ios7', function () {
});
});
describe('findElement(s) containing name', function () {
after(function (done) {
driver.clickBack()
.nodeify(done);
});
it('should find one element', function (done) {
driver
.elementsByClassName('UIATableCell').then(function (els) { return els[2]; })
.click()
.elementByName('*Rounded*').getAttribute('name')
.should.become('UITextField Rounded')
.nodeify(done);
});
it('should find several element', function (done) {
driver
.elementsByClassName('UIATableCell').then(function (els) { return els[2]; })
.click()
.elementsByName('*Rounded*')
.should.eventually.have.length.above(3)
.nodeify(done);
});
});
describe('findElement(s)ByXPath', function () {
var setupXpath = function (driver) {
return driver.elementByClassName('UIATableCell').click();

View File

@@ -134,4 +134,28 @@ describe('uicatalog - find - basics @skip-ios6', function () {
});
});
describe('findElement(s) containing name', function () {
after(function (done) {
driver.clickBack()
.nodeify(done);
});
it('should find one element', function (done) {
driver
.elementByXPath("//UIAStaticText[contains(@label,'Action Sheets')]").click()
.elementByName('*Okay*').getAttribute('name')
.should.become('Okay / Cancel')
.nodeify(done);
});
it('should find several element', function (done) {
driver
.elementByXPath("//UIAStaticText[contains(@label,'Action Sheets')]").click()
.elementsByName('*Okay*')
.should.eventually.have.length(2)
.nodeify(done);
});
});
});

View File

@@ -40,7 +40,7 @@ describe('uicatalog - find by accessibility id @skip-ios6', function () {
driver
.elementByXPath("//UIAStaticText[contains(@label,'Action Sheets')]").click()
.elements('accessibility id', 'Okay / Cancel').then(function (els) {
els.length.should.equal(1);
els.length.should.equal(2);
})
.nodeify(done);
});