Skip to content

Commit 3e2e5ab

Browse files
committed
new methods working - pick first not started household
1 parent bbe7b39 commit 3e2e5ab

File tree

6 files changed

+89
-26
lines changed

6 files changed

+89
-26
lines changed

helpers/promise-utils.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"use strict";
22

3-
let Q = require('q'),
4-
_ = require('underscore');
3+
let Q = require('q');
4+
let _ = require('underscore');
5+
let store = require('../helpers/store');
6+
57

68
exports.each = function (fn) {
79
return function (els) {
@@ -32,10 +34,42 @@ exports.filter = function (fn) {
3234
};
3335
};
3436

37+
38+
39+
40+
41+
3542
exports.printNames = exports.each(function (el, i) {
3643
return el.getAttribute('name').print(i + "--> ");
3744
});
3845

46+
exports.saveHouseNames = exports.each(function(el, i) {
47+
return el.getAttribute('name').then(function (attr) {
48+
var this_key = 'houseHold_' + i;
49+
var this_value = attr;
50+
store.get('houseHolds')[this_key] = this_value;
51+
})
52+
});
53+
54+
// creating a function to pick the first "not started" household without saving the whole list.
55+
// exports.pickFirstNotStarted = exports.each(function (el, i) {
56+
// return driver
57+
// .elementByClassName('XCUIElementTypeTable')
58+
// .elementsByClassName('>','XCUIElementTypeCell')
59+
// .then(function () {
60+
// return exports.each(function (el, i) {
61+
// return el.getAttribute('name').then(function (attr) {
62+
// var this_key = 'houseHold_' + i;
63+
// var this_value = attr;
64+
// store.get('houseHolds')[this_key] = this_value;
65+
// })
66+
// })
67+
// })
68+
69+
70+
71+
72+
3973
exports.filterDisplayed = exports.filter(function (el) {
4074
return el.isDisplayed();
4175
});

loadTimeLogs/loadTimesLog_4_12_2017_20_19_37.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Log In: 0 hours, 0 minutes, 1.950 seconds.
2+
Load Survey List: 0 hours, 0 minutes, 0.584 seconds.
3+
Load Survey: 0 hours, 0 minutes, 3.186 seconds.
4+
Home Page to Household: 0 hours, 0 minutes, 39.771 seconds.

run.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ for (var i in args ) {
2626
switch ( arg ) {
2727
case '-sim' : {
2828
appium = childProcess.spawn( 'appium', [
29-
'-p','4725', //non-default args
30-
'-cp','4725', //non-default args
31-
'-bp','4726', //non-default args
32-
'--selendroid-port', '8081', //non-default args
33-
'--chromedriver-port', '9516', //non-default args
34-
'--webkit-debug-proxy-port', '27754', //non-default args
29+
//'-p','4725', //non-default args
30+
//'-cp','4725', //non-default args
31+
//'-bp','4726', //non-default args
32+
//'--selendroid-port', '8081', //non-default args
33+
//'--chromedriver-port', '9516', //non-default args
34+
//'--webkit-debug-proxy-port', '27754', //non-default args
3535
'--session-override',
3636
'--log-level', 'debug',
3737
'--debug-log-spacing',

sample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe("Visiting all pages in Walk", function() {
125125
});
126126

127127
//tested and works
128-
it("should print every menu item", function () {
128+
it.only("should print every menu item", function () {
129129
return driver
130130
.elementByClassName('XCUIElementTypeTable')
131131
.elementsByClassName('>','XCUIElementTypeCell')

tests/icon_colors.js

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
"use strict";
22

33
module.exports = function () {
4-
4+
55
require('colors');
66
let wd = require("wd");
7-
let assert = require('assert');
7+
let assert = require('assert');
88
let _ = require('underscore');
99
let Q = require('q');
1010
let fsExtra = require('fs-extra');
1111
let fs = require('fs');
1212
let _p = require('../helpers/promise-utils');
1313
let elements = require('../helpers/elements');
1414
let actions = require('../helpers/actions');
15+
let store = require('../helpers/store');
1516
let pry = require('pryjs');
1617
let config = require('../helpers/config');
1718
let serverConfigs = require('../helpers/appium-servers');
@@ -24,7 +25,7 @@ module.exports = function () {
2425

2526

2627
describe("Test all icon colors", function() {
27-
28+
2829
this.timeout(3000000);
2930
let allPassed = true;
3031
console.log(('RUNNING ' + __filename.slice(__dirname.length + 1) + ' for iOS').green.bold.underline);
@@ -35,9 +36,14 @@ module.exports = function () {
3536
.fullLogin()
3637
});
3738

38-
it('Should turn the house blue: one primary target not home', function () {
39-
console.log('Should turn the house blue: one primary target not home'.green.bold.underline);
39+
it.only('Should login quick', function () {
40+
return driver
41+
.loginQuick()
42+
});
4043

44+
it.only('Should turn the house blue: one primary target not home', function () {
45+
console.log('Should turn the house blue: one primary target not home'.green.bold.underline);
46+
store.set('houseHolds', {})
4147
// Not home 1 primary target turns house blue
4248
// Survey: DO NOT USE: Mobile Automation Survey 1.0
4349

@@ -53,19 +59,42 @@ module.exports = function () {
5359
.elementById('DO NOT USE: Mobile Automation Survey 1.0')
5460
.click()
5561
.waitForElementById(elements.survey.start, 10000)
62+
.sleep(1000)
5663
.elementById(elements.survey.start)
5764
.click()
5865
.startTime('Load Survey')
59-
.waitForElementById('Select Walkbook', 10000)
66+
.waitForElementById('Select Walkbook', 13000)
6067
.endTotalAndLogTime('Load Survey')
6168
.elementByXPath(elements.survey.walkbook1)
6269
.click()
63-
.waitForElementById(elements.survey.popoverOpenBook, 10000)
70+
.waitForElementById(elements.survey.popoverOpenBook, 13000)
6471
.elementById(elements.survey.popoverOpenBook)
6572
.click()
6673
.startTime('Load Walkbook')
67-
.waitForElementByXPath(elements.walkbook.houseHold1, 10000)
68-
.click()
74+
.waitForElementByClassName('XCUIElementTypeTable', 13000)
75+
76+
//save household IDs
77+
.elementByClassName('XCUIElementTypeTable')
78+
.elementsByClassName('>','XCUIElementTypeCell')
79+
.then(_p.saveHouseNames)
80+
81+
//pick the first notstarted household
82+
.then(function () {
83+
var houseHolds = store.get('houseHolds');
84+
for (var key in houseHolds){
85+
var regexp = /.*notstarted.*/i;
86+
var this_value = houseHolds[key];
87+
if (regexp.test(this_value) === true) {
88+
console.log('Using ' + houseHolds[key])
89+
config.thisHousehold = this_value
90+
return driver
91+
.elementById(config.thisHousehold)
92+
.click()
93+
break;
94+
}
95+
}
96+
})
97+
6998
.waitForElementById(elements.walkbook.popoverOpenHouse, 10000)
7099
.elementById(elements.walkbook.popoverOpenHouse)
71100
.click()
@@ -91,7 +120,7 @@ module.exports = function () {
91120
//
92121
// return driver
93122
//
94-
//
123+
//
95124
// });
96125
// it('Should turn the house blue: xxxxxxxxxxx', function () {
97126
// console.log('Should turn the house blue: xxxxxxxxxxx'.green.bold.underline);
@@ -101,7 +130,7 @@ module.exports = function () {
101130
//
102131
// return driver
103132
//
104-
//
133+
//
105134
// });
106135
// it('Should turn the house blue: xxxxxxxxxxx', function () {
107136
// console.log('Should turn the house blue: xxxxxxxxxxx'.green.bold.underline);
@@ -111,7 +140,7 @@ module.exports = function () {
111140
//
112141
// return driver
113142
//
114-
//
143+
//
115144
// });
116145
// it('Should turn the house blue: xxxxxxxxxxx', function () {
117146
// console.log('Should turn the house blue: xxxxxxxxxxx'.green.bold.underline);
@@ -121,7 +150,7 @@ module.exports = function () {
121150
//
122151
// return driver
123152
//
124-
//
153+
//
125154
// });
126155

127156

0 commit comments

Comments
 (0)