Created
April 20, 2015 19:06
-
-
Save Jonahss/c4b87a7bce2d5d309381 to your computer and use it in GitHub Desktop.
simpletest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wd = require("wd"); | |
var Q = wd.Q; | |
var _ = require('underscore'); | |
var chai = require("chai"); | |
var chaiAsPromised = require("chai-as-promised"); | |
chai.use(chaiAsPromised); | |
chai.should(); | |
chaiAsPromised.transferPromiseness = wd.transferPromiseness; | |
var desired = { | |
browserName: '', | |
platformName: 'iOS', | |
platformVersion: '7.1', | |
deviceName: 'iPhone Simulator', | |
app: '/Users/jonahss/Workspace/appium/sample-code/apps/TestApp/build/Release-iphonesimulator/TestApp.app', | |
}; | |
describe('notes app', function() { | |
var browser = null; | |
var values = []; | |
this.timeout(300000); | |
it('should fill two fields with numbers', function(done) { | |
browser = wd.promiseChainRemote('localhost', 4723); | |
browser | |
.init(desired) | |
.elementsByIosUIAutomation('.textFields();').then(function(elems) { | |
var seq = []; | |
_(elems).each(function(elem) { | |
seq.push(function() { | |
var val = Math.round(Math.random()*10); | |
values.push(val); | |
return elem.sendKeys(val); | |
}); | |
}); | |
return seq.reduce(Q.when, new Q()); | |
}) | |
.elementByIosUIAutomation('.buttons()') | |
.click() | |
.elementByClassName('UIAStaticText') | |
.text().then(function(text) { | |
var sum = values[0] + values[1]; | |
sum.should.equal(parseInt(text, 10)); | |
}) | |
.quit() | |
.nodeify(done); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment