Advertisement
Guest User

Untitled

a guest
May 29th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. var wd = require("wd");
  2. var Q = wd.Q;
  3. var _ = require('underscore');
  4. var chai = require("chai");
  5. var chaiAsPromised = require("chai-as-promised");
  6. chai.use(chaiAsPromised);
  7. chai.should();
  8. chaiAsPromised.transferPromiseness = wd.transferPromiseness;
  9.  
  10. var desired = {
  11. browserName: '',
  12. platformName: 'iOS',
  13. platformVersion: '7.1',
  14. deviceName: 'iPhone Simulator',
  15. app: '/Users/jonahss/Workspace/appium/sample-code/apps/TestApp/build/Release-iphonesimulator/TestApp.app',
  16. };
  17.  
  18. describe('notes app', function() {
  19. var browser = null;
  20. var values = [];
  21. this.timeout(300000);
  22.  
  23.  
  24. it('should fill two fields with numbers', function(done) {
  25. browser = wd.promiseChainRemote('localhost', 4723);
  26.  
  27. browser
  28. .init(desired)
  29. .elementsByIosUIAutomation('.textFields();').then(function(elems) {
  30. var seq = [];
  31. _(elems).each(function(elem) {
  32. seq.push(function() {
  33. var val = Math.round(Math.random()*10);
  34. values.push(val);
  35. return elem.sendKeys(val);
  36. });
  37. });
  38. return seq.reduce(Q.when, new Q());
  39. })
  40. .elementByIosUIAutomation('.buttons()')
  41. .click()
  42. .elementByClassName('UIAStaticText')
  43. .text().then(function(text) {
  44. var sum = values[0] + values[1];
  45.  
  46. sum.should.equal(parseInt(text, 10));
  47. })
  48. .quit()
  49. .nodeify(done);
  50. });
  51. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement