webdriverio 9.2.1 → 9.2.4

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.
@@ -4,7 +4,7 @@
4
4
  * on it. To use characters like "Left arrow" or "Back space", import the `Key` object from the WebdriverIO package.
5
5
  *
6
6
  * Modifier like `Control`, `Shift`, `Alt` and `Command` will stay pressed so you need to trigger them again to release
7
- * them. Modifiying a click however requires you to use the WebDriver Actions API through the
7
+ * them. Modifying a click however requires you to use the WebDriver Actions API through the
8
8
  * [performActions](https://webdriver.io/docs/api/webdriver#performactions) method.
9
9
  *
10
10
  * :::info
@@ -96,7 +96,7 @@ export declare const SESSION_MOCKS: Record<string, Set<WebDriverInterception>>;
96
96
  * </example>
97
97
  *
98
98
  * @alias browser.mock
99
- * @param {String|RegExp} url url to mock
99
+ * @param {String} url url to mock
100
100
  * @param {MockFilterOptions=} filterOptions filter mock resource by additional options
101
101
  * @param {String|Function=} filterOptions.method filter resource by HTTP method
102
102
  * @param {Object|Function=} filterOptions.headers filter resource by specific request headers
@@ -1,23 +1,23 @@
1
1
  import type { NewWindowOptions } from '../../types.js';
2
2
  /**
3
3
  *
4
- * Open new window in browser. This command is the equivalent function to `window.open()`. This command does not
5
- * work in mobile environments.
4
+ * Open new window or tab in browser (defaults to a new window if not specified).
5
+ * This command is the equivalent function to `window.open()`. This command does not work in mobile environments.
6
6
  *
7
- * __Note:__ When calling this command you automatically switch to the new window.
7
+ * __Note:__ When calling this command you automatically switch to the new window or tab.
8
8
  *
9
9
  * <example>
10
10
  :newWindowSync.js
11
- it('should open a new tab', async () => {
11
+ it('should open a new window', async () => {
12
12
  await browser.url('https://google.com')
13
13
  console.log(await browser.getTitle()) // outputs: "Google"
14
14
 
15
- await browser.newWindow('https://webdriver.io', {
15
+ const result = await browser.newWindow('https://webdriver.io', {
16
16
  windowName: 'WebdriverIO window',
17
17
  windowFeature: 'width=420,height=230,resizable,scrollbars=yes,status=1',
18
18
  })
19
19
  console.log(await browser.getTitle()) // outputs: "WebdriverIO · Next-gen browser and mobile automation test framework for Node.js"
20
-
20
+ console.log(result.type) // outputs: "window"
21
21
  const handles = await browser.getWindowHandles()
22
22
  await browser.switchToWindow(handles[1])
23
23
  await browser.closeWindow()
@@ -25,17 +25,45 @@ import type { NewWindowOptions } from '../../types.js';
25
25
  console.log(await browser.getTitle()) // outputs: "Google"
26
26
  });
27
27
  * </example>
28
+ * <example>
29
+ :newTabSync.js
30
+ it('should open a new tab', async () => {
31
+ await browser.url('https://google.com')
32
+ console.log(await browser.getTitle()) // outputs: "Google"
33
+
34
+ await browser.newWindow('https://webdriver.io', {
35
+ type:'tab',
36
+ windowName: 'WebdriverIO window',
37
+ windowFeature: 'width=420,height=230,resizable,scrollbars=yes,status=1',
38
+ })
39
+ console.log(await browser.getTitle()) // outputs: "WebdriverIO · Next-gen browser and mobile automation test framework for Node.js"
40
+ console.log(result.type) // outputs: "tab"
41
+ const handles = await browser.getWindowHandles()
42
+ await browser.switchToWindow(handles[1])
43
+ await browser.closeWindow()
44
+ await browser.switchToWindow(handles[0])
45
+ console.log(await browser.getTitle()) // outputs: "Google"
46
+ });
47
+ * </example>
28
48
  *
29
49
  * @param {string} url website URL to open
30
50
  * @param {NewWindowOptions=} options newWindow command options
51
+ * @param {string=} options.type type of new window: 'tab' or 'window'
31
52
  * @param {String=} options.windowName name of the new window
32
53
  * @param {String=} options.windowFeatures features of opened window (e.g. size, position, scrollbars, etc.)
33
54
  *
34
- * @return {String} id of window handle of new tab
55
+ * @return {Object} An object containing the window handle and the type of new window
56
+ * @return {String} handle - The ID of the window handle of the new tab or window
57
+ * @return {String} type - The type of the new window, either 'tab' or 'window'
58
+ *
59
+ * @throws {Error} If `url` is invalid, if the command is used on mobile, or `type` is not 'tab' or 'window'.
35
60
  *
36
61
  * @uses browser/execute, protocol/getWindowHandles, protocol/switchToWindow
37
62
  * @alias browser.newWindow
38
- * @type window
63
+ * @type window or tab
39
64
  */
40
- export declare function newWindow(this: WebdriverIO.Browser, url: string, { windowName, windowFeatures }?: NewWindowOptions): Promise<string>;
65
+ export declare function newWindow(this: WebdriverIO.Browser, url: string, { type, windowName, windowFeatures }?: NewWindowOptions): Promise<{
66
+ handle: string;
67
+ type: 'tab' | 'window';
68
+ }>;
41
69
  //# sourceMappingURL=newWindow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"newWindow.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/newWindow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAItD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,SAAS,CAC3B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,GAAG,EAAE,MAAM,EACX,EAAE,UAAe,EAAE,cAAmB,EAAE,GAAE,gBAAqB,mBAiDlE"}
1
+ {"version":3,"file":"newWindow.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/newWindow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAMtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,wBAAsB,SAAS,CAC3B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,GAAG,EAAE,MAAM,EACX,EAAE,IAAe,EAAE,UAAe,EAAE,cAAmB,EAAE,GAAE,gBAAqB,GACjF,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAA;CAAE,CAAC,CA2DrD"}
@@ -9,8 +9,18 @@ type FlatContextTree = Omit<local.BrowsingContextInfo, 'children'> & {
9
9
  *
10
10
  * - If given a string it switches to the frame with a matching context id, url or url that contains that string
11
11
  * ```ts
12
- * // switch to a frame that has the url "https://the-internet.herokuapp.com/iframe"
13
- * await browser.switchFrame('https://the-internet.herokuapp.com/iframe')
12
+ * // switch to a frame that has a specific url or contains a string in the url
13
+ * await browser.url('https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe')
14
+ * // Note: this frame is located in a nested iframe, however you only need to provide
15
+ * // the frame url of your desired frame
16
+ * await browser.switchFrame('https://www.w3schools.com')
17
+ * // check the title of the page
18
+ * console.log(await browser.execute(() => [document.title, document.URL]))
19
+ * // outputs: [ 'W3Schools Online Web Tutorials', 'https://www.w3schools.com/' ]
20
+ * ```
21
+ *
22
+ * - If you have the context id of the frame you can use it directly
23
+ * ```ts
14
24
  * // switch to a frame that has a certain context id
15
25
  * await browser.switchFrame('A5734774C41F8C91D483BDD4022B2EF3')
16
26
  * ```
@@ -21,12 +31,14 @@ type FlatContextTree = Omit<local.BrowsingContextInfo, 'children'> & {
21
31
  * await browser.switchFrame($('iframe'))
22
32
  * ```
23
33
  *
24
- * - If given a function it will loop through all iframes on the page and call the function with the context
25
- * object. The function should return a boolean indicating if the frame should be selected. Within the function
26
- * you can use WebdriverIO commands to e.g. check if a certain frame element exists.
34
+ * - If given a function it will loop through all iframes on the page and call the function within the context
35
+ * object. The function should return a boolean indicating if the frame should be selected. The function
36
+ * will be executed within the browser and allows access to all Web APIs, e.g.:
27
37
  * ```ts
28
38
  * // switch to first frame that contains an element with id "#frameContent"
29
- * await browser.switchFrame(() => $('#frameContent').isExisting())
39
+ * await browser.switchFrame(() => Boolean(document.querySelector('#frameContent')))
40
+ * // switch to first frame that contains "webdriver" in the URL
41
+ * await browser.switchFrame(() => document.URL.includes('webdriver'))
30
42
  * ```
31
43
  *
32
44
  * - If given `null` it will switch to the top level frame
@@ -39,10 +51,13 @@ type FlatContextTree = Omit<local.BrowsingContextInfo, 'children'> & {
39
51
  * await browser.switchFrame(null)
40
52
  * ```
41
53
  *
54
+ * Once you switched to a frame, all further commands will be executed in the context of that frame,
55
+ * including navigating to different pages.
56
+ *
42
57
  * @alias browser.switchFrame
43
58
  * @param {string|object|function} context
44
59
  * @returns {Promise<string>} the current active context id
45
60
  */
46
- export declare function switchFrame(this: WebdriverIO.Browser, context: WebdriverIO.Element | ChainablePromiseElement | string | null | ((tree: FlatContextTree) => boolean | Promise<boolean>)): Promise<string | ((tree: FlatContextTree) => boolean | Promise<boolean>)>;
61
+ export declare function switchFrame(this: WebdriverIO.Browser, context: WebdriverIO.Element | ChainablePromiseElement | string | null | ((tree: FlatContextTree) => boolean | Promise<boolean>)): Promise<string | void>;
47
62
  export {};
48
63
  //# sourceMappingURL=switchFrame.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"switchFrame.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/switchFrame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,WAAW,CAAA;AAGtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAE7D,KAAK,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAE3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,WAAW,CAC7B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,uBAAuB,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,4BAA/C,eAAe,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAgFlI"}
1
+ {"version":3,"file":"switchFrame.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/switchFrame.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,KAAK,EAAe,MAAM,WAAW,CAAA;AAOhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAE7D,KAAK,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAG3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAsB,WAAW,CAC7B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,uBAAuB,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,0BA8NnI"}
@@ -1 +1 @@
1
- {"version":3,"file":"switchWindow.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/switchWindow.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,YAAY,CAC9B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,MAAM,GAAG,MAAM,mBAmD3B"}
1
+ {"version":3,"file":"switchWindow.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/switchWindow.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,YAAY,CAC9B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,MAAM,GAAG,MAAM,mBAqD3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/url.ts"],"names":[],"mappings":"AAKA,KAAK,SAAS,GAAG,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,UAAU,CAAA;AAKpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmGG;AACH,wBAAsB,GAAG,CACrB,IAAI,EAAE,WA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;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,CAAA;CAC3B"}
@@ -7,7 +7,10 @@ export declare function getContextManager(browser: WebdriverIO.Browser): Context
7
7
  export declare class ContextManager {
8
8
  #private;
9
9
  constructor(browser: WebdriverIO.Browser);
10
- initialize(): Promise<boolean>;
10
+ /**
11
+ * set context at the start of the session
12
+ */
13
+ initialize(): Promise<string>;
11
14
  setCurrentContext(context: string): void;
12
15
  getCurrentContext(): Promise<string>;
13
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAMA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,kBAS7D;AAED;;;;GAIG;AACH,qBAAa,cAAc;;gBAKX,OAAO,EAAE,WAAW,CAAC,OAAO;IAoBlC,UAAU;IAqBhB,iBAAiB,CAAE,OAAO,EAAE,MAAM;IAI5B,iBAAiB;CAM1B"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,kBAS7D;AAED;;;;GAIG;AACH,qBAAa,cAAc;;gBAIX,OAAO,EAAE,WAAW,CAAC,OAAO;IAiCxC;;OAEG;IACG,UAAU;IAahB,iBAAiB,CAAE,OAAO,EAAE,MAAM;IAI5B,iBAAiB;CAM1B"}