@wdio/utils 9.0.0-alpha.0 → 9.0.0-alpha.114

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/build/index.d.ts CHANGED
@@ -2,13 +2,13 @@ import webdriverMonad from './monad.js';
2
2
  import initializePlugin from './initializePlugin.js';
3
3
  import { startWebDriver } from './startWebDriver.js';
4
4
  import { initializeWorkerService, initializeLauncherService } from './initializeServices.js';
5
- import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability, userImport } from './utils.js';
5
+ import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability, userImport, getBrowserObject, enableFileLogging } from './utils.js';
6
6
  import { wrapCommand, executeHooksWithArgs, executeAsync } from './shim.js';
7
7
  import * as asyncIterators from './pIteration.js';
8
8
  import { testFnWrapper, wrapGlobalTestMethod } from './test-framework/index.js';
9
9
  import { isW3C, capabilitiesEnvironmentDetector, sessionEnvironmentDetector } from './envDetector.js';
10
10
  import { UNICODE_CHARACTERS, HOOK_DEFINITION } from './constants.js';
11
- export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, userImport, asyncIterators,
11
+ export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, userImport, getBrowserObject, enableFileLogging, asyncIterators,
12
12
  /**
13
13
  * runner shim
14
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,MAAM,YAAY,CAAA;AACvC,OAAO,gBAAgB,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,cAAc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AO,EACH,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EACnE,eAAe,EAAE,yBAAyB,EAAE,KAAK,EAAE,kBAAkB,EACrE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAClD,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC3E,OAAO,KAAK,cAAc,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AACrG,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEpE,OAAO,EACH,cAAc,EACd,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,KAAK,EACL,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc;AAEd;;GAEG;AACH,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,oBAAoB;AAEpB;;GAEG;AACH,KAAK,EACL,0BAA0B,EAC1B,+BAA+B;AAE/B;;GAEG;AACH,kBAAkB,EAClB,eAAe,EAClB,CAAA"}
package/build/index.js CHANGED
@@ -3,13 +3,13 @@ import webdriverMonad from './monad.js';
3
3
  import initializePlugin from './initializePlugin.js';
4
4
  import { startWebDriver } from './startWebDriver.js';
5
5
  import { initializeWorkerService, initializeLauncherService } from './initializeServices.js';
6
- import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability, userImport } from './utils.js';
6
+ import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability, userImport, getBrowserObject, enableFileLogging, } from './utils.js';
7
7
  import { wrapCommand, executeHooksWithArgs, executeAsync } from './shim.js';
8
8
  import * as asyncIterators from './pIteration.js';
9
9
  import { testFnWrapper, wrapGlobalTestMethod } from './test-framework/index.js';
10
10
  import { isW3C, capabilitiesEnvironmentDetector, sessionEnvironmentDetector } from './envDetector.js';
11
11
  import { UNICODE_CHARACTERS, HOOK_DEFINITION } from './constants.js';
12
- export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, userImport, asyncIterators,
12
+ export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, userImport, getBrowserObject, enableFileLogging, asyncIterators,
13
13
  /**
14
14
  * runner shim
15
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"monad.d.ts","sourceRoot":"","sources":["../src/monad.ts"],"names":[],"mappings":"AAaA,UAAU,gBAAgB;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,kBAAkB,CAAA;CAC7C;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,gBAAgB,GAAE,gBAAqB;WAkBpG,IAAI,aAAa,MAAM,mBAAmB,QAAQ;IAsIvE;;;;;;OAMG;eACyB,MAAM,QAAQ,QAAQ,SAAS,OAAO,MAAM,EAAE,GAAG,CAAC,gBAAgB,QAAQ;EA8CzG"}
1
+ {"version":3,"file":"monad.d.ts","sourceRoot":"","sources":["../src/monad.ts"],"names":[],"mappings":"AAaA,UAAU,gBAAgB;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,kBAAkB,CAAA;CAC7C;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,gBAAgB,GAAE,gBAAqB;WAkBpG,IAAI,aAAa,MAAM,mBAAmB,QAAQ;IA2IvE;;;;;;OAMG;eACyB,MAAM,QAAQ,QAAQ,SAAS,OAAO,MAAM,EAAE,GAAG,CAAC,gBAAgB,QAAQ;EA8CzG"}
package/build/monad.js CHANGED
@@ -35,7 +35,12 @@ export default function WebDriver(options, modifier, propertiesObject = {}) {
35
35
  */
36
36
  if (typeof commandWrapper === 'function') {
37
37
  for (const [commandName, { value }] of Object.entries(propertiesObject)) {
38
- if (typeof value !== 'function') {
38
+ /**
39
+ * no need to apply a command wrapper if:
40
+ * - there is no wrapper
41
+ * - command is an event handler function
42
+ */
43
+ if (typeof value !== 'function' || Object.keys(EVENTHANDLER_FUNCTIONS).includes(commandName)) {
39
44
  continue;
40
45
  }
41
46
  propertiesObject[commandName].value = commandWrapper(commandName, value, propertiesObject);
@@ -160,16 +160,16 @@ export async function setupPuppeteerBrowser(cacheDir, caps) {
160
160
  linuxWhich: 'chromium-browser'
161
161
  }).catch(() => undefined)
162
162
  : await locateFirefox().catch(() => undefined);
163
- const tag = isChromeOrChromium
163
+ const browserVersion = isChromeOrChromium
164
164
  ? getBuildIdByChromePath(executablePath)
165
165
  : await getBuildIdByFirefoxPath(executablePath);
166
166
  /**
167
167
  * verify that we have a valid Chrome/Firefox browser installed
168
168
  */
169
- if (tag) {
169
+ if (browserVersion) {
170
170
  return {
171
171
  executablePath,
172
- browserVersion: await resolveBuildId(browserName, platform, tag)
172
+ browserVersion
173
173
  };
174
174
  }
175
175
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shim.d.ts","sourceRoot":"","sources":["../src/shim.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,UAAU,EAAE,MAAM,aAAa,CAAA;AAqBt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AAO,EAAE,UAAU,CAAC,WAAW,EAAE,IAAI,GAAE,GAAG,EAAO,EAAE,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CA2CxJ"}
package/build/shim.js CHANGED
@@ -1,5 +1,7 @@
1
+ /// <reference types="@wdio/globals/types" />
1
2
  import logger from '@wdio/logger';
2
3
  import * as iterators from './pIteration.js';
4
+ import { getBrowserObject } from './utils.js';
3
5
  const log = logger('@wdio/utils:shim');
4
6
  let inCommandHook = false;
5
7
  const ELEMENT_QUERY_COMMANDS = [
@@ -134,11 +136,25 @@ export function wrapCommand(commandName, fn) {
134
136
  return wrapElementFn(target,
135
137
  /**
136
138
  * `this` is an array of WebdriverIO elements
137
- *
138
- * Note(Christian): types for elements are defined in the
139
- * webdriverio package and not accessible here
140
139
  */
141
140
  function (index) {
141
+ /**
142
+ * if we access an index that is out of bounds we wait for the
143
+ * array to get that long, and timeout eventually if it doesn't
144
+ */
145
+ if (index >= this.length) {
146
+ const browser = getBrowserObject(this);
147
+ return browser.waitUntil(async () => {
148
+ const elems = await this.parent[this.foundWith](this.selector);
149
+ if (elems.length > index) {
150
+ return elems[index];
151
+ }
152
+ return false;
153
+ }, {
154
+ timeout: browser.options.waitforTimeout,
155
+ timeoutMsg: `Index out of bounds! $$(${this.selector}) returned only ${this.length} elements.`
156
+ });
157
+ }
142
158
  return this[index];
143
159
  }, [prop], { prop, args });
144
160
  }
package/build/utils.d.ts CHANGED
@@ -95,4 +95,13 @@ export declare function isChrome(browserName?: string): boolean;
95
95
  export declare function isSafari(browserName?: string): boolean;
96
96
  export declare function isFirefox(browserName?: string): boolean;
97
97
  export declare function isEdge(browserName?: string): boolean;
98
+ /**
99
+ * traverse up the scope chain until browser element was reached
100
+ */
101
+ export declare function getBrowserObject(elem: WebdriverIO.Element | WebdriverIO.Browser | WebdriverIO.ElementArray): WebdriverIO.Browser;
102
+ /**
103
+ * Enables logging to a file in a specified directory.
104
+ * @param {string} outputDir Directory containing the log file
105
+ */
106
+ export declare function enableFileLogging(outputDir?: string): Promise<void>;
98
107
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAW,MAAM,aAAa,CAAA;AAe7D,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,WAGnC;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE;IAAE,sBAAsB,CAAC,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,QAwCzH;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,UAAQ,UA+BrF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAE,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;;EAapF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAE,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,WA8B/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAE,GAAG,EAAE,GAAG,wGAExC;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAAG,UAAU,EAAE,MAAM,EAAE,WAAW,SAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAW5F;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC,CAgEtF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAE,EAAE,EAAE,QAAQ,WAE5C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAE,IAA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,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,YAAY,GAAG,WAAW,CAAC,OAAO,CAGjI;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO1E"}
package/build/utils.js CHANGED
@@ -1,3 +1,5 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
1
3
  import { SUPPORTED_BROWSERNAMES, DEFAULT_PROTOCOL, DEFAULT_HOSTNAME, DEFAULT_PATH } from './constants.js';
2
4
  const SCREENSHOT_REPLACEMENT = '"<Screenshot[base64]>"';
3
5
  const SCRIPT_PLACEHOLDER = '"<Script[base64]>"';
@@ -318,3 +320,21 @@ export function isFirefox(browserName) {
318
320
  export function isEdge(browserName) {
319
321
  return Boolean(browserName && SUPPORTED_BROWSERNAMES.edge.includes(browserName.toLowerCase()));
320
322
  }
323
+ /**
324
+ * traverse up the scope chain until browser element was reached
325
+ */
326
+ export function getBrowserObject(elem) {
327
+ const elemObject = elem;
328
+ return elemObject.parent ? getBrowserObject(elemObject.parent) : elem;
329
+ }
330
+ /**
331
+ * Enables logging to a file in a specified directory.
332
+ * @param {string} outputDir Directory containing the log file
333
+ */
334
+ export async function enableFileLogging(outputDir) {
335
+ if (!outputDir) {
336
+ return;
337
+ }
338
+ await fs.mkdir(path.join(outputDir), { recursive: true });
339
+ process.env.WDIO_LOG_PATH = path.join(outputDir, 'wdio.log');
340
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/utils",
3
- "version": "9.0.0-alpha.0",
3
+ "version": "9.0.0-alpha.114+b1a80c10f",
4
4
  "description": "A WDIO helper utility to provide several utility functions used across the project.",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-utils",
@@ -37,22 +37,22 @@
37
37
  "url": "https://github.com/webdriverio/webdriverio/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@puppeteer/browsers": "^2.0.1",
41
- "@wdio/logger": "9.0.0-alpha.0",
42
- "@wdio/types": "9.0.0-alpha.0",
40
+ "@puppeteer/browsers": "^2.2.0",
41
+ "@wdio/logger": "9.0.0-alpha.114+b1a80c10f",
42
+ "@wdio/types": "9.0.0-alpha.114+b1a80c10f",
43
43
  "decamelize": "^6.0.0",
44
44
  "deepmerge-ts": "^5.1.0",
45
- "edgedriver": "^5.3.5",
46
- "geckodriver": "^4.3.1",
45
+ "edgedriver": "^5.3.10",
46
+ "geckodriver": "^4.3.3",
47
47
  "get-port": "^7.0.0",
48
48
  "import-meta-resolve": "^4.0.0",
49
- "locate-app": "^2.1.0",
50
- "safaridriver": "^0.1.0",
49
+ "locate-app": "^2.2.24",
50
+ "safaridriver": "^0.1.2",
51
51
  "split2": "^4.2.0",
52
- "wait-port": "^1.0.4"
52
+ "wait-port": "^1.1.0"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "75d45a1efff8705785f0fbcd2379ac624d16e007"
57
+ "gitHead": "b1a80c10f41091e6ecfd8c5abff14788a8de499b"
58
58
  }