@webex/test-helper-automation 2.36.1 → 2.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -18
- package/dist/index.js.map +1 -1
- package/dist/wd/accept-grant.js +1 -3
- package/dist/wd/accept-grant.js.map +1 -1
- package/dist/wd/login.js +3 -9
- package/dist/wd/login.js.map +1 -1
- package/dist/wd/print-logs.js +1 -3
- package/dist/wd/print-logs.js.map +1 -1
- package/dist/wd/submit-password.js +2 -11
- package/dist/wd/submit-password.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +7 -5
- package/src/wd/accept-grant.js +6 -10
- package/src/wd/login.js +3 -8
- package/src/wd/print-logs.js +2 -4
- package/src/wd/submit-password.js +5 -7
package/dist/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
6
|
-
|
|
7
5
|
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
8
|
-
|
|
9
6
|
/*!
|
|
10
7
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
11
8
|
*/
|
|
@@ -14,26 +11,20 @@ var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/n
|
|
|
14
11
|
if (typeof _promise.default === 'undefined') {
|
|
15
12
|
// eslint-disable-next-line global-require
|
|
16
13
|
require('es6-promise').polyfill();
|
|
17
|
-
}
|
|
18
|
-
// @webex/test-helper-chai.
|
|
19
|
-
|
|
14
|
+
}
|
|
20
15
|
|
|
16
|
+
// Reminder: this is intentionally a different instance of chai than
|
|
17
|
+
// @webex/test-helper-chai.
|
|
21
18
|
var path = require('path');
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
var chai = require('chai');
|
|
20
|
+
// Note: this is probably the only place we should use chai-as-promised; it's
|
|
24
21
|
// incompatible with IE 11, so can't go into browser tests. Once we move to
|
|
25
22
|
// wdio, it can be removed from here as well.
|
|
26
|
-
|
|
27
|
-
|
|
28
23
|
var chaiAsPromised = require('chai-as-promised');
|
|
29
|
-
|
|
30
24
|
var _require = require('lodash'),
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
defaults = _require.defaults;
|
|
33
26
|
var requireDir = require('require-dir');
|
|
34
|
-
|
|
35
27
|
var wd = require('wd');
|
|
36
|
-
|
|
37
28
|
chai.use(chaiAsPromised);
|
|
38
29
|
chai.should();
|
|
39
30
|
chaiAsPromised.transferPromiseness = wd.transferPromiseness;
|
|
@@ -49,17 +40,14 @@ module.exports = {
|
|
|
49
40
|
if (!pkg) {
|
|
50
41
|
throw new Error('pkg is required');
|
|
51
42
|
}
|
|
52
|
-
|
|
53
43
|
if (!browserDef) {
|
|
54
44
|
browserDef = {
|
|
55
45
|
browserName: 'chrome'
|
|
56
46
|
};
|
|
57
47
|
}
|
|
58
|
-
|
|
59
48
|
if (!browserDef) {
|
|
60
49
|
throw new Error('No browser definition available');
|
|
61
50
|
}
|
|
62
|
-
|
|
63
51
|
browserDef = defaults(browserDef, {
|
|
64
52
|
build: process.env.BUILD_NUMBER || "local-".concat(process.env.USER, "-").concat(pkg.name, "-").concat((0, _now.default)()),
|
|
65
53
|
name: "".concat(pkg.name, " (automation)"),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","polyfill","path","chai","chaiAsPromised","defaults","requireDir","wd","use","should","transferPromiseness","join","__dirname","module","exports","createBrowser","pkg","browserDef","Error","browserName","build","process","env","BUILD_NUMBER","USER","name","public","tunnelIdentifier","SC_TUNNEL_IDENTIFIER","browser","promiseChainRemote","init","setImplicitWaitTimeout","setWindowSize","then"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n
|
|
1
|
+
{"version":3,"names":["require","polyfill","path","chai","chaiAsPromised","defaults","requireDir","wd","use","should","transferPromiseness","join","__dirname","module","exports","createBrowser","pkg","browserDef","Error","browserName","build","process","env","BUILD_NUMBER","USER","name","public","tunnelIdentifier","SC_TUNNEL_IDENTIFIER","browser","promiseChainRemote","init","setImplicitWaitTimeout","setWindowSize","then"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* istanbul ignore next */\nif (typeof Promise === 'undefined') {\n // eslint-disable-next-line global-require\n require('es6-promise').polyfill();\n}\n\n// Reminder: this is intentionally a different instance of chai than\n// @webex/test-helper-chai.\nconst path = require('path');\n\nconst chai = require('chai');\n// Note: this is probably the only place we should use chai-as-promised; it's\n// incompatible with IE 11, so can't go into browser tests. Once we move to\n// wdio, it can be removed from here as well.\nconst chaiAsPromised = require('chai-as-promised');\nconst {defaults} = require('lodash');\nconst requireDir = require('require-dir');\nconst wd = require('wd');\n\nchai.use(chaiAsPromised);\nchai.should();\nchaiAsPromised.transferPromiseness = wd.transferPromiseness;\n\nrequireDir(path.join(__dirname, 'wd'));\n\nmodule.exports = {\n /**\n * Resolves with a wd browser instance\n * @param {Object} pkg package.json as JavaScript Object\n * @param {Object} browserDef wd-compatible browser definition\n * @returns {Promise}\n */\n createBrowser: function createBrowser(pkg, browserDef) {\n if (!pkg) {\n throw new Error('pkg is required');\n }\n\n if (!browserDef) {\n browserDef = {browserName: 'chrome'};\n }\n\n if (!browserDef) {\n throw new Error('No browser definition available');\n }\n\n browserDef = defaults(browserDef, {\n build: process.env.BUILD_NUMBER || `local-${process.env.USER}-${pkg.name}-${Date.now()}`,\n name: `${pkg.name} (automation)`,\n public: 'team',\n tunnelIdentifier: process.env.SC_TUNNEL_IDENTIFIER,\n });\n\n const browser = process.env.SC_TUNNEL_IDENTIFIER\n ? wd.promiseChainRemote('ondemand.saucelabs.com', 80)\n : wd.promiseChainRemote();\n\n return browser\n .init(browserDef)\n .setImplicitWaitTimeout(10000)\n .setWindowSize(1600, 1200)\n .then(() => browser);\n },\n\n wd,\n};\n"],"mappings":";;;;;AAAA;AACA;AACA;;AAEA;AACA,IAAI,uBAAc,KAAK,WAAW,EAAE;EAClC;EACAA,OAAO,CAAC,aAAa,CAAC,CAACC,QAAQ,EAAE;AACnC;;AAEA;AACA;AACA,IAAMC,IAAI,GAAGF,OAAO,CAAC,MAAM,CAAC;AAE5B,IAAMG,IAAI,GAAGH,OAAO,CAAC,MAAM,CAAC;AAC5B;AACA;AACA;AACA,IAAMI,cAAc,GAAGJ,OAAO,CAAC,kBAAkB,CAAC;AAClD,eAAmBA,OAAO,CAAC,QAAQ,CAAC;EAA7BK,QAAQ,YAARA,QAAQ;AACf,IAAMC,UAAU,GAAGN,OAAO,CAAC,aAAa,CAAC;AACzC,IAAMO,EAAE,GAAGP,OAAO,CAAC,IAAI,CAAC;AAExBG,IAAI,CAACK,GAAG,CAACJ,cAAc,CAAC;AACxBD,IAAI,CAACM,MAAM,EAAE;AACbL,cAAc,CAACM,mBAAmB,GAAGH,EAAE,CAACG,mBAAmB;AAE3DJ,UAAU,CAACJ,IAAI,CAACS,IAAI,CAACC,SAAS,EAAE,IAAI,CAAC,CAAC;AAEtCC,MAAM,CAACC,OAAO,GAAG;EACf;AACF;AACA;AACA;AACA;AACA;EACEC,aAAa,EAAE,SAASA,aAAa,CAACC,GAAG,EAAEC,UAAU,EAAE;IACrD,IAAI,CAACD,GAAG,EAAE;MACR,MAAM,IAAIE,KAAK,CAAC,iBAAiB,CAAC;IACpC;IAEA,IAAI,CAACD,UAAU,EAAE;MACfA,UAAU,GAAG;QAACE,WAAW,EAAE;MAAQ,CAAC;IACtC;IAEA,IAAI,CAACF,UAAU,EAAE;MACf,MAAM,IAAIC,KAAK,CAAC,iCAAiC,CAAC;IACpD;IAEAD,UAAU,GAAGZ,QAAQ,CAACY,UAAU,EAAE;MAChCG,KAAK,EAAEC,OAAO,CAACC,GAAG,CAACC,YAAY,oBAAaF,OAAO,CAACC,GAAG,CAACE,IAAI,cAAIR,GAAG,CAACS,IAAI,cAAI,mBAAU,CAAE;MACxFA,IAAI,YAAKT,GAAG,CAACS,IAAI,kBAAe;MAChCC,MAAM,EAAE,MAAM;MACdC,gBAAgB,EAAEN,OAAO,CAACC,GAAG,CAACM;IAChC,CAAC,CAAC;IAEF,IAAMC,OAAO,GAAGR,OAAO,CAACC,GAAG,CAACM,oBAAoB,GAC5CrB,EAAE,CAACuB,kBAAkB,CAAC,wBAAwB,EAAE,EAAE,CAAC,GACnDvB,EAAE,CAACuB,kBAAkB,EAAE;IAE3B,OAAOD,OAAO,CACXE,IAAI,CAACd,UAAU,CAAC,CAChBe,sBAAsB,CAAC,KAAK,CAAC,CAC7BC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CACzBC,IAAI,CAAC;MAAA,OAAML,OAAO;IAAA,EAAC;EACxB,CAAC;EAEDtB,EAAE,EAAFA;AACF,CAAC"}
|
package/dist/wd/accept-grant.js
CHANGED
|
@@ -5,17 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/* eslint-disable no-invalid-this */
|
|
8
|
-
var wd = require('wd');
|
|
9
8
|
|
|
9
|
+
var wd = require('wd');
|
|
10
10
|
wd.addPromiseChainMethod('acceptGrant', function acceptGrant() {
|
|
11
11
|
var _this = this;
|
|
12
|
-
|
|
13
12
|
var selector = 'input[value="Accept"]';
|
|
14
13
|
return this.hasElementByCssSelector(selector).then(function (has) {
|
|
15
14
|
if (has) {
|
|
16
15
|
return _this.waitForElementByCssSelector(selector).click();
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
return _this;
|
|
20
18
|
});
|
|
21
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["wd","require","addPromiseChainMethod","acceptGrant","selector","hasElementByCssSelector","then","has","waitForElementByCssSelector","click"],"sources":["accept-grant.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-disable no-invalid-this */\n\nconst wd = require('wd');\n\nwd.addPromiseChainMethod('acceptGrant', function acceptGrant() {\n const selector = 'input[value=\"Accept\"]';\n\n return this
|
|
1
|
+
{"version":3,"names":["wd","require","addPromiseChainMethod","acceptGrant","selector","hasElementByCssSelector","then","has","waitForElementByCssSelector","click"],"sources":["accept-grant.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-disable no-invalid-this */\n\nconst wd = require('wd');\n\nwd.addPromiseChainMethod('acceptGrant', function acceptGrant() {\n const selector = 'input[value=\"Accept\"]';\n\n return this.hasElementByCssSelector(selector).then((has) => {\n if (has) {\n return this.waitForElementByCssSelector(selector).click();\n }\n\n return this;\n });\n});\n"],"mappings":";;AAAA;AACA;AACA;;AAEA;;AAEA,IAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AAExBD,EAAE,CAACE,qBAAqB,CAAC,aAAa,EAAE,SAASC,WAAW,GAAG;EAAA;EAC7D,IAAMC,QAAQ,GAAG,uBAAuB;EAExC,OAAO,IAAI,CAACC,uBAAuB,CAACD,QAAQ,CAAC,CAACE,IAAI,CAAC,UAACC,GAAG,EAAK;IAC1D,IAAIA,GAAG,EAAE;MACP,OAAO,KAAI,CAACC,2BAA2B,CAACJ,QAAQ,CAAC,CAACK,KAAK,EAAE;IAC3D;IAEA,OAAO,KAAI;EACb,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/wd/login.js
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/* eslint-disable no-invalid-this */
|
|
8
|
-
var _require = require('lodash'),
|
|
9
|
-
defaults = _require.defaults;
|
|
10
8
|
|
|
9
|
+
var _require = require('lodash'),
|
|
10
|
+
defaults = _require.defaults;
|
|
11
11
|
var wd = require('wd');
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* @method login
|
|
14
15
|
* @memberof wd
|
|
@@ -18,29 +19,22 @@ var wd = require('wd');
|
|
|
18
19
|
* @param {Object} options
|
|
19
20
|
* @param {number} options.remainingRetries
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
22
|
wd.addPromiseChainMethod('login', function login(user, options) {
|
|
24
23
|
var _this = this;
|
|
25
|
-
|
|
26
24
|
options = options || {};
|
|
27
25
|
defaults(options, {
|
|
28
26
|
remainingRetries: 3
|
|
29
27
|
});
|
|
30
|
-
|
|
31
28
|
if (!user.email) {
|
|
32
29
|
throw new Error('`user.email` is required');
|
|
33
30
|
}
|
|
34
|
-
|
|
35
31
|
if (!user.password) {
|
|
36
32
|
throw new Error('`user.password` is required');
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
return this.hasElementByCssSelector('#IDToken1[readonly]').then(function (emailAlreadyEntered) {
|
|
40
35
|
if (!emailAlreadyEntered) {
|
|
41
36
|
return _this.elementById('IDToken1').sendKeys(user.email).elementById('IDButton2').click();
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
return _this;
|
|
45
39
|
}).submitPassword(user, options).acceptGrant();
|
|
46
40
|
});
|
package/dist/wd/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","defaults","wd","addPromiseChainMethod","login","user","options","remainingRetries","email","Error","password","hasElementByCssSelector","then","emailAlreadyEntered","elementById","sendKeys","click","submitPassword","acceptGrant"],"sources":["login.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-disable no-invalid-this */\n\nconst {defaults} = require('lodash');\nconst wd = require('wd');\n\n/**\n * @method login\n * @memberof wd\n * @param {Object} user\n * @param {stirng} user.email\n * @param {stirng} user.password\n * @param {Object} options\n * @param {number} options.remainingRetries\n */\nwd.addPromiseChainMethod('login', function login(user, options) {\n options = options || {};\n defaults(options, {\n remainingRetries: 3
|
|
1
|
+
{"version":3,"names":["require","defaults","wd","addPromiseChainMethod","login","user","options","remainingRetries","email","Error","password","hasElementByCssSelector","then","emailAlreadyEntered","elementById","sendKeys","click","submitPassword","acceptGrant"],"sources":["login.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-disable no-invalid-this */\n\nconst {defaults} = require('lodash');\nconst wd = require('wd');\n\n/**\n * @method login\n * @memberof wd\n * @param {Object} user\n * @param {stirng} user.email\n * @param {stirng} user.password\n * @param {Object} options\n * @param {number} options.remainingRetries\n */\nwd.addPromiseChainMethod('login', function login(user, options) {\n options = options || {};\n defaults(options, {\n remainingRetries: 3,\n });\n\n if (!user.email) {\n throw new Error('`user.email` is required');\n }\n\n if (!user.password) {\n throw new Error('`user.password` is required');\n }\n\n return this.hasElementByCssSelector('#IDToken1[readonly]')\n .then((emailAlreadyEntered) => {\n if (!emailAlreadyEntered) {\n return this.elementById('IDToken1').sendKeys(user.email).elementById('IDButton2').click();\n }\n\n return this;\n })\n .submitPassword(user, options)\n .acceptGrant();\n});\n"],"mappings":";;AAAA;AACA;AACA;;AAEA;;AAEA,eAAmBA,OAAO,CAAC,QAAQ,CAAC;EAA7BC,QAAQ,YAARA,QAAQ;AACf,IAAMC,EAAE,GAAGF,OAAO,CAAC,IAAI,CAAC;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAE,EAAE,CAACC,qBAAqB,CAAC,OAAO,EAAE,SAASC,KAAK,CAACC,IAAI,EAAEC,OAAO,EAAE;EAAA;EAC9DA,OAAO,GAAGA,OAAO,IAAI,CAAC,CAAC;EACvBL,QAAQ,CAACK,OAAO,EAAE;IAChBC,gBAAgB,EAAE;EACpB,CAAC,CAAC;EAEF,IAAI,CAACF,IAAI,CAACG,KAAK,EAAE;IACf,MAAM,IAAIC,KAAK,CAAC,0BAA0B,CAAC;EAC7C;EAEA,IAAI,CAACJ,IAAI,CAACK,QAAQ,EAAE;IAClB,MAAM,IAAID,KAAK,CAAC,6BAA6B,CAAC;EAChD;EAEA,OAAO,IAAI,CAACE,uBAAuB,CAAC,qBAAqB,CAAC,CACvDC,IAAI,CAAC,UAACC,mBAAmB,EAAK;IAC7B,IAAI,CAACA,mBAAmB,EAAE;MACxB,OAAO,KAAI,CAACC,WAAW,CAAC,UAAU,CAAC,CAACC,QAAQ,CAACV,IAAI,CAACG,KAAK,CAAC,CAACM,WAAW,CAAC,WAAW,CAAC,CAACE,KAAK,EAAE;IAC3F;IAEA,OAAO,KAAI;EACb,CAAC,CAAC,CACDC,cAAc,CAACZ,IAAI,EAAEC,OAAO,CAAC,CAC7BY,WAAW,EAAE;AAClB,CAAC,CAAC"}
|
package/dist/wd/print-logs.js
CHANGED
|
@@ -5,12 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/* eslint max-nested-callbacks: [0] */
|
|
8
|
-
|
|
9
8
|
/* eslint no-console: [0] */
|
|
10
|
-
|
|
11
9
|
/* eslint-disable no-invalid-this */
|
|
12
|
-
var wd = require('wd');
|
|
13
10
|
|
|
11
|
+
var wd = require('wd');
|
|
14
12
|
wd.addPromiseChainMethod('printLogs', function printLogs() {
|
|
15
13
|
return this.log('browser').then(function (logs) {
|
|
16
14
|
logs.forEach(function (log) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["wd","require","addPromiseChainMethod","printLogs","log","then","logs","forEach","message","JSON","parse","method","console","level","text","err","catch","reason","warn"],"sources":["print-logs.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint max-nested-callbacks: [0] */\n/* eslint no-console: [0] */\n/* eslint-disable no-invalid-this */\n\nconst wd = require('wd');\n\nwd.addPromiseChainMethod('printLogs', function printLogs() {\n return this
|
|
1
|
+
{"version":3,"names":["wd","require","addPromiseChainMethod","printLogs","log","then","logs","forEach","message","JSON","parse","method","console","level","text","err","catch","reason","warn"],"sources":["print-logs.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint max-nested-callbacks: [0] */\n/* eslint no-console: [0] */\n/* eslint-disable no-invalid-this */\n\nconst wd = require('wd');\n\nwd.addPromiseChainMethod('printLogs', function printLogs() {\n return this.log('browser')\n .then((logs) => {\n logs.forEach((log) => {\n try {\n log.message = JSON.parse(log.message);\n const method = console[log.message.message.level] || console.log;\n\n console[method]('broser log:', log.message.message.text);\n } catch (err) {\n console.log('browser log:', log.message);\n }\n });\n })\n .catch((reason) => {\n console.warn('failed to fetch browser logs', reason);\n });\n});\n"],"mappings":";;AAAA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,IAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AAExBD,EAAE,CAACE,qBAAqB,CAAC,WAAW,EAAE,SAASC,SAAS,GAAG;EACzD,OAAO,IAAI,CAACC,GAAG,CAAC,SAAS,CAAC,CACvBC,IAAI,CAAC,UAACC,IAAI,EAAK;IACdA,IAAI,CAACC,OAAO,CAAC,UAACH,GAAG,EAAK;MACpB,IAAI;QACFA,GAAG,CAACI,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACN,GAAG,CAACI,OAAO,CAAC;QACrC,IAAMG,MAAM,GAAGC,OAAO,CAACR,GAAG,CAACI,OAAO,CAACA,OAAO,CAACK,KAAK,CAAC,IAAID,OAAO,CAACR,GAAG;QAEhEQ,OAAO,CAACD,MAAM,CAAC,CAAC,aAAa,EAAEP,GAAG,CAACI,OAAO,CAACA,OAAO,CAACM,IAAI,CAAC;MAC1D,CAAC,CAAC,OAAOC,GAAG,EAAE;QACZH,OAAO,CAACR,GAAG,CAAC,cAAc,EAAEA,GAAG,CAACI,OAAO,CAAC;MAC1C;IACF,CAAC,CAAC;EACJ,CAAC,CAAC,CACDQ,KAAK,CAAC,UAACC,MAAM,EAAK;IACjBL,OAAO,CAACM,IAAI,CAAC,8BAA8B,EAAED,MAAM,CAAC;EACtD,CAAC,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
6
|
-
|
|
7
5
|
/*!
|
|
8
6
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
9
7
|
*/
|
|
10
8
|
|
|
11
9
|
/* eslint-disable no-invalid-this */
|
|
12
|
-
|
|
13
10
|
/* eslint-disable max-nested-callbacks */
|
|
11
|
+
|
|
14
12
|
var wd = require('wd');
|
|
13
|
+
|
|
15
14
|
/**
|
|
16
15
|
* Returns a promise that resolves after 'timeout' milliseconds
|
|
17
16
|
* @param {number} timeout
|
|
18
17
|
* @private
|
|
19
18
|
* @returns {Promise}
|
|
20
19
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
20
|
function delay(timeout) {
|
|
24
21
|
return new _promise.default(function (resolve) {
|
|
25
22
|
setTimeout(resolve, timeout);
|
|
@@ -33,15 +30,11 @@ function delay(timeout) {
|
|
|
33
30
|
* @param {Object} options
|
|
34
31
|
* @param {Object} options.remainingRetries
|
|
35
32
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
33
|
wd.addPromiseChainMethod('submitPassword', function submitPassword(user, options) {
|
|
39
34
|
var _this = this;
|
|
40
|
-
|
|
41
35
|
if (!user.password) {
|
|
42
36
|
throw new Error('`user.password` is required');
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
options = options || {
|
|
46
39
|
remainingRetries: 3
|
|
47
40
|
};
|
|
@@ -53,10 +46,8 @@ wd.addPromiseChainMethod('submitPassword', function submitPassword(user, options
|
|
|
53
46
|
_this.submitPassword(user, options);
|
|
54
47
|
});
|
|
55
48
|
}
|
|
56
|
-
|
|
57
49
|
throw new Error('Failed to login after several attempts');
|
|
58
50
|
}
|
|
59
|
-
|
|
60
51
|
return null;
|
|
61
52
|
});
|
|
62
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["wd","require","delay","timeout","resolve","setTimeout","addPromiseChainMethod","submitPassword","user","options","password","Error","remainingRetries","elementById","sendKeys","click","hasElementByClassName","then","isPresent"],"sources":["submit-password.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-disable no-invalid-this */\n/* eslint-disable max-nested-callbacks */\n\nconst wd = require('wd');\n\n/**\n * Returns a promise that resolves after 'timeout' milliseconds\n * @param {number} timeout\n * @private\n * @returns {Promise}\n */\nfunction delay(timeout) {\n return new Promise((resolve) => {\n setTimeout(resolve, timeout);\n });\n}\n/**\n * @method submitPassword\n * @memberof wd\n * @param {Object} user\n * @param {string} user.password\n * @param {Object} options\n * @param {Object} options.remainingRetries\n */\nwd.addPromiseChainMethod('submitPassword', function submitPassword(user, options) {\n if (!user.password) {\n throw new Error('`user.password` is required');\n }\n\n options = options || {\n remainingRetries: 3
|
|
1
|
+
{"version":3,"names":["wd","require","delay","timeout","resolve","setTimeout","addPromiseChainMethod","submitPassword","user","options","password","Error","remainingRetries","elementById","sendKeys","click","hasElementByClassName","then","isPresent"],"sources":["submit-password.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-disable no-invalid-this */\n/* eslint-disable max-nested-callbacks */\n\nconst wd = require('wd');\n\n/**\n * Returns a promise that resolves after 'timeout' milliseconds\n * @param {number} timeout\n * @private\n * @returns {Promise}\n */\nfunction delay(timeout) {\n return new Promise((resolve) => {\n setTimeout(resolve, timeout);\n });\n}\n/**\n * @method submitPassword\n * @memberof wd\n * @param {Object} user\n * @param {string} user.password\n * @param {Object} options\n * @param {Object} options.remainingRetries\n */\nwd.addPromiseChainMethod('submitPassword', function submitPassword(user, options) {\n if (!user.password) {\n throw new Error('`user.password` is required');\n }\n\n options = options || {\n remainingRetries: 3,\n };\n\n return this.elementById('IDToken2')\n .sendKeys(user.password)\n .elementById('Button1')\n .click()\n .hasElementByClassName('generic-error')\n .then((isPresent) => {\n if (isPresent) {\n if (options.remainingRetries > 0) {\n options.remainingRetries -= 1;\n\n return delay(1000).then(() => {\n this.submitPassword(user, options);\n });\n }\n throw new Error('Failed to login after several attempts');\n }\n\n return null;\n });\n});\n"],"mappings":";;;;AAAA;AACA;AACA;;AAEA;AACA;;AAEA,IAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,KAAK,CAACC,OAAO,EAAE;EACtB,OAAO,qBAAY,UAACC,OAAO,EAAK;IAC9BC,UAAU,CAACD,OAAO,EAAED,OAAO,CAAC;EAC9B,CAAC,CAAC;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAH,EAAE,CAACM,qBAAqB,CAAC,gBAAgB,EAAE,SAASC,cAAc,CAACC,IAAI,EAAEC,OAAO,EAAE;EAAA;EAChF,IAAI,CAACD,IAAI,CAACE,QAAQ,EAAE;IAClB,MAAM,IAAIC,KAAK,CAAC,6BAA6B,CAAC;EAChD;EAEAF,OAAO,GAAGA,OAAO,IAAI;IACnBG,gBAAgB,EAAE;EACpB,CAAC;EAED,OAAO,IAAI,CAACC,WAAW,CAAC,UAAU,CAAC,CAChCC,QAAQ,CAACN,IAAI,CAACE,QAAQ,CAAC,CACvBG,WAAW,CAAC,SAAS,CAAC,CACtBE,KAAK,EAAE,CACPC,qBAAqB,CAAC,eAAe,CAAC,CACtCC,IAAI,CAAC,UAACC,SAAS,EAAK;IACnB,IAAIA,SAAS,EAAE;MACb,IAAIT,OAAO,CAACG,gBAAgB,GAAG,CAAC,EAAE;QAChCH,OAAO,CAACG,gBAAgB,IAAI,CAAC;QAE7B,OAAOV,KAAK,CAAC,IAAI,CAAC,CAACe,IAAI,CAAC,YAAM;UAC5B,KAAI,CAACV,cAAc,CAACC,IAAI,EAAEC,OAAO,CAAC;QACpC,CAAC,CAAC;MACJ;MACA,MAAM,IAAIE,KAAK,CAAC,wCAAwC,CAAC;IAC3D;IAEA,OAAO,IAAI;EACb,CAAC,CAAC;AACN,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
/* istanbul ignore next */
|
|
7
6
|
if (typeof Promise === 'undefined') {
|
|
8
7
|
// eslint-disable-next-line global-require
|
|
@@ -52,16 +51,19 @@ module.exports = {
|
|
|
52
51
|
build: process.env.BUILD_NUMBER || `local-${process.env.USER}-${pkg.name}-${Date.now()}`,
|
|
53
52
|
name: `${pkg.name} (automation)`,
|
|
54
53
|
public: 'team',
|
|
55
|
-
tunnelIdentifier: process.env.SC_TUNNEL_IDENTIFIER
|
|
54
|
+
tunnelIdentifier: process.env.SC_TUNNEL_IDENTIFIER,
|
|
56
55
|
});
|
|
57
56
|
|
|
58
|
-
const browser = process.env.SC_TUNNEL_IDENTIFIER
|
|
57
|
+
const browser = process.env.SC_TUNNEL_IDENTIFIER
|
|
58
|
+
? wd.promiseChainRemote('ondemand.saucelabs.com', 80)
|
|
59
|
+
: wd.promiseChainRemote();
|
|
59
60
|
|
|
60
|
-
return browser
|
|
61
|
+
return browser
|
|
62
|
+
.init(browserDef)
|
|
61
63
|
.setImplicitWaitTimeout(10000)
|
|
62
64
|
.setWindowSize(1600, 1200)
|
|
63
65
|
.then(() => browser);
|
|
64
66
|
},
|
|
65
67
|
|
|
66
|
-
wd
|
|
68
|
+
wd,
|
|
67
69
|
};
|
package/src/wd/accept-grant.js
CHANGED
|
@@ -9,15 +9,11 @@ const wd = require('wd');
|
|
|
9
9
|
wd.addPromiseChainMethod('acceptGrant', function acceptGrant() {
|
|
10
10
|
const selector = 'input[value="Accept"]';
|
|
11
11
|
|
|
12
|
-
return this
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return this
|
|
17
|
-
.waitForElementByCssSelector(selector)
|
|
18
|
-
.click();
|
|
19
|
-
}
|
|
12
|
+
return this.hasElementByCssSelector(selector).then((has) => {
|
|
13
|
+
if (has) {
|
|
14
|
+
return this.waitForElementByCssSelector(selector).click();
|
|
15
|
+
}
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
return this;
|
|
18
|
+
});
|
|
23
19
|
});
|
package/src/wd/login.js
CHANGED
|
@@ -19,7 +19,7 @@ const wd = require('wd');
|
|
|
19
19
|
wd.addPromiseChainMethod('login', function login(user, options) {
|
|
20
20
|
options = options || {};
|
|
21
21
|
defaults(options, {
|
|
22
|
-
remainingRetries: 3
|
|
22
|
+
remainingRetries: 3,
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
if (!user.email) {
|
|
@@ -30,15 +30,10 @@ wd.addPromiseChainMethod('login', function login(user, options) {
|
|
|
30
30
|
throw new Error('`user.password` is required');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
return this
|
|
34
|
-
.hasElementByCssSelector('#IDToken1[readonly]')
|
|
33
|
+
return this.hasElementByCssSelector('#IDToken1[readonly]')
|
|
35
34
|
.then((emailAlreadyEntered) => {
|
|
36
35
|
if (!emailAlreadyEntered) {
|
|
37
|
-
return this
|
|
38
|
-
.elementById('IDToken1')
|
|
39
|
-
.sendKeys(user.email)
|
|
40
|
-
.elementById('IDButton2')
|
|
41
|
-
.click();
|
|
36
|
+
return this.elementById('IDToken1').sendKeys(user.email).elementById('IDButton2').click();
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
return this;
|
package/src/wd/print-logs.js
CHANGED
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
const wd = require('wd');
|
|
10
10
|
|
|
11
11
|
wd.addPromiseChainMethod('printLogs', function printLogs() {
|
|
12
|
-
return this
|
|
13
|
-
.log('browser')
|
|
12
|
+
return this.log('browser')
|
|
14
13
|
.then((logs) => {
|
|
15
14
|
logs.forEach((log) => {
|
|
16
15
|
try {
|
|
@@ -18,8 +17,7 @@ wd.addPromiseChainMethod('printLogs', function printLogs() {
|
|
|
18
17
|
const method = console[log.message.message.level] || console.log;
|
|
19
18
|
|
|
20
19
|
console[method]('broser log:', log.message.message.text);
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
20
|
+
} catch (err) {
|
|
23
21
|
console.log('browser log:', log.message);
|
|
24
22
|
}
|
|
25
23
|
});
|
|
@@ -32,11 +32,10 @@ wd.addPromiseChainMethod('submitPassword', function submitPassword(user, options
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
options = options || {
|
|
35
|
-
remainingRetries: 3
|
|
35
|
+
remainingRetries: 3,
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
return this
|
|
39
|
-
.elementById('IDToken2')
|
|
38
|
+
return this.elementById('IDToken2')
|
|
40
39
|
.sendKeys(user.password)
|
|
41
40
|
.elementById('Button1')
|
|
42
41
|
.click()
|
|
@@ -46,10 +45,9 @@ wd.addPromiseChainMethod('submitPassword', function submitPassword(user, options
|
|
|
46
45
|
if (options.remainingRetries > 0) {
|
|
47
46
|
options.remainingRetries -= 1;
|
|
48
47
|
|
|
49
|
-
return delay(1000)
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
});
|
|
48
|
+
return delay(1000).then(() => {
|
|
49
|
+
this.submitPassword(user, options);
|
|
50
|
+
});
|
|
53
51
|
}
|
|
54
52
|
throw new Error('Failed to login after several attempts');
|
|
55
53
|
}
|