Merge pull request #2615 from sebv/master

Started to fix ios tests
This commit is contained in:
seb vincent
2014-05-20 17:51:20 +08:00
6 changed files with 42 additions and 31 deletions

View File

@@ -8,12 +8,8 @@ var env = require('../../../helpers/env')
, Q = require("q")
, fs = require('fs')
, path = require('path')
, _ = require("underscore");
function filterVisible(selector) {
return selector.replace(/;$/, '.withPredicate("isVisible == 1");');
// return selector.replace(/;$/, '.withValueForKey(1, "isVisible");');
}
, _ = require("underscore")
, filterVisible = require('../../../helpers/ios-uiautomation').filterVisible;
describe('testapp - basic', function () {
@@ -40,7 +36,6 @@ describe('testapp - basic', function () {
values = [];
return driver
.elementsByIosUIAutomation(filterVisible('.textFields();'))
//.elementsByClassName('UIATextField')
.then(function (elems) {
var sequence = _(elems).map(function (elem) {
var val = Math.round(Math.random() * 10);

View File

@@ -58,9 +58,10 @@ describe('testapp - location - 3', function () {
_.extend(newDesired, {
locationServicesAuthorized: true
});
var title = this.title;
it('should not work without bundleId', function (done) {
initSession(newDesired, {'no-retry': true, 'no-reset': true})
.setUp(this.parent.title + " " + this.title)
.setUp(title)
.then(function (err) {
err.cause.value.message.should.contain("bundleId");
throw err;

View File

@@ -5,7 +5,8 @@
var setup = require("../../common/setup-base")
, desired = require('./desired')
, Q = require("q")
, _ = require('underscore');
, _ = require('underscore')
, filterVisible = require('../../../helpers/ios-uiautomation').filterVisible;
describe('testapp - simple', function () {
@@ -15,7 +16,9 @@ describe('testapp - simple', function () {
var values = [];
var populate = function (driver) {
return driver.elementsByClassName('UIATextField').then(function (elems) {
return driver
.elementsByIosUIAutomation(filterVisible('.textFields();'))
.then(function (elems) {
var sequence = _(elems).map(function (elem) {
var val = Math.round(Math.random() * 10);
values.push(val);

View File

@@ -30,12 +30,12 @@ describe('uicatalog - alerts', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should detect Show Simple', function (done) {
it('should detect 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()
.elementByXPath("//UIAStaticText[contains(@label,'Alert Views')]").click()
.waitForElementByXPath("//UIAStaticText[contains(" + alertTag + ",'Simple')]", 10000, 1000)
.elementByXPath("//UIAStaticText[contains(" + alertTag + ",'Simple')]")
.click()
.resolve(waitForAlert())
.nodeify(done);
});
@@ -44,12 +44,12 @@ describe('uicatalog - alerts', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should detect Show OK-Cancel', function (done) {
it('should detect Okay', 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()
.elementByXPath("//UIAStaticText[contains(@label,'Alert Views')]").click()
.waitForElementByXPath("//UIAStaticText[contains(" + alertTag + ",'Okay')]", 10000, 1000)
.elementByXPath("//UIAStaticText[contains(" + alertTag + ",'Okay')]")
.click()
.resolve(waitForAlert())
.nodeify(done);
});
@@ -58,12 +58,13 @@ describe('uicatalog - alerts', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('should detect Show Custom', function (done) {
it('should detect Other', 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()
.elementByXPath("//UIAStaticText[contains(@label,'Alert Views')]").click()
//.sleep(60000)
.waitForElementByXPath("//UIAStaticText[contains(" + alertTag + ",'Other')]", 10000, 1000)
.elementByXPath("//UIAStaticText[contains(" + alertTag + ",'Other')]")
.click()
.resolve(waitForAlert())
.nodeify(done);
});

View File

@@ -5,6 +5,7 @@ var env = require('../../../helpers/env')
, desired = require('./desired');
describe('uicatalog - basic', function () {
var textTag = env.IOS7 ? '@label' : '@value';
describe('api', function () {
var driver;
@@ -20,21 +21,23 @@ describe('uicatalog - basic', function () {
it('should confirm element is not visible', function (done) {
driver
.elementByClassName('UIATableCell').click()
.elementByName("UIButtonTypeContactAdd").isDisplayed()
.elementByXPath("//UIAStaticText[contains(" + textTag + ", 'Buttons')]").click()
.elementByXPath("//UIAButton[contains(@name, 'UINavigationBarBackIndicatorDefault')]")
.isDisplayed()
.should.not.eventually.be.ok
.nodeify(done);
});
it('should confirm element is visible', function (done) {
driver
.elementByClassName('UIATableCell').click()
.elementByName("UIButtonTypeRoundedRect").isDisplayed()
.elementByXPath("//UIAStaticText[contains(" + textTag + ", 'Buttons')]").click()
.elementByXPath("//UIATableGroup[@name = 'SYSTEM (CONTACT ADD)']")
.should.eventually.be.ok
.nodeify(done);
});
it('should confirm element is selected @skip-ios7', function (done) {
it('should confirm element is selected @skip-ios7', function (done) {
// TODO: review select implementation for ios7
driver
.elementByXPath("//UIAStaticText[contains(@label, 'Pickers')]").click()
.elementByXPath("//UIAButton[contains(@label, 'UIPicker')]").isSelected()
@@ -42,7 +45,8 @@ describe('uicatalog - basic', function () {
.nodeify(done);
});
it('should confirm element is not selected returns false', function (done) {
it('should confirm element is not selected returns false @skip-ios7', function (done) {
// TODO: review select implementation for ios7
driver
.elementByXPath("//UIAStaticText[contains(@label, 'Pickers')]").click()
.elementByXPath("//UIAButton[contains(@label, 'Custom')]").isSelected()

View File

@@ -0,0 +1,7 @@
"use strict";
exports.filterVisible = function (selector) {
return selector.replace(/;$/, '.withPredicate("isVisible == 1");');
// return selector.replace(/;$/, '.withValueForKey(1, "isVisible");');
};