Implement functional test helpers (#10209)

Backports PR #8362

**Commit 1:**
[functionalTests] implement common.tryMethod() helper

* Original sha: 69fb068d55
* Authored by spalger <email@spalger.com> on 2016-09-20T01:43:59Z

**Commit 2:**
[functionalTests] implement common.findAllTestSubjects() helper

* Original sha: 6b220cfc2b
* Authored by spalger <email@spalger.com> on 2016-09-20T01:44:48Z
This commit is contained in:
jasper 2017-02-06 19:12:05 -05:00 committed by Spencer
parent 01cf8ff3a5
commit 2de7cecaef

View file

@ -1,6 +1,7 @@
import bluebird, {
promisify
promisify,
filter as filterAsync
} from 'bluebird';
import fs from 'fs';
import _ from 'lodash';
@ -214,6 +215,10 @@ export default class Common {
return Try.try(block);
}
tryMethod(object, method, ...args) {
return this.try(() => object[method](...args));
}
log(...args) {
Log.log(...args);
}
@ -265,4 +270,11 @@ export default class Common {
.findDisplayedByCssSelector(testSubjSelector(selector));
}
async findAllTestSubjects(selector) {
this.debug('in findAllTestSubjects: ' + testSubjSelector(selector));
const remote = this.remote.setFindTimeout(defaultFindTimeout);
const all = await remote.findAllByCssSelector(testSubjSelector(selector));
return await filterAsync(all, el => el.isDisplayed());
}
}