webdriverio 9.2.8 → 9.2.11

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.
@@ -1 +1 @@
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,0BAiOnI"}
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,0BA4OnI"}
@@ -8,6 +8,9 @@
8
8
  // open url
9
9
  await browser.url('https://google.com')
10
10
 
11
+ // get window handle
12
+ const handle = await browser.getWindowHandle()
13
+
11
14
  // create new window
12
15
  await browser.newWindow('https://webdriver.io')
13
16
 
@@ -16,10 +19,13 @@
16
19
 
17
20
  // switch back via title match
18
21
  await browser.switchWindow('Next-gen browser and mobile automation test framework for Node.js')
22
+
23
+ // switch back via window handle
24
+ await browser.switchWindow(handle)
19
25
  });
20
26
  * </example>
21
27
  *
22
- * @param {String|RegExp} matcher String or regular expression that matches the title and url of the page or window name
28
+ * @param {String|RegExp} matcher String or regular expression that matches either the page title or URL, the window name, or the window handle
23
29
  *
24
30
  * @uses protocol/getWindowHandles, protocol/switchToWindow, protocol/getUrl, protocol/getTitle
25
31
  * @alias browser.switchTab
@@ -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,mBAqD3B"}
1
+ {"version":3,"file":"switchWindow.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/switchWindow.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,YAAY,CAC9B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,MAAM,GAAG,MAAM,mBAkE3B"}
package/build/index.js CHANGED
@@ -4139,17 +4139,25 @@ async function setWindowSize(width, height) {
4139
4139
  // src/commands/browser/switchWindow.ts
4140
4140
  async function switchWindow(matcher) {
4141
4141
  if (typeof matcher !== "string" && !(matcher instanceof RegExp)) {
4142
- throw new Error('Unsupported parameter for switchWindow, required is "string" or an RegExp');
4142
+ throw new Error('Unsupported parameter for switchWindow, required is "string" or a RegExp');
4143
4143
  }
4144
4144
  const currentWindow = await this.getWindowHandle();
4145
+ if (typeof matcher === "string" && currentWindow === matcher) {
4146
+ return currentWindow;
4147
+ }
4148
+ const contextManager2 = getContextManager(this);
4145
4149
  const tabs = await this.getWindowHandles();
4150
+ if (typeof matcher === "string" && tabs.includes(matcher)) {
4151
+ await this.switchToWindow(matcher);
4152
+ contextManager2.setCurrentContext(matcher);
4153
+ return matcher;
4154
+ }
4146
4155
  const matchesTarget = (target) => {
4147
4156
  if (typeof matcher === "string") {
4148
4157
  return target.includes(matcher);
4149
4158
  }
4150
4159
  return !!target.match(matcher);
4151
4160
  };
4152
- const contextManager2 = getContextManager(this);
4153
4161
  for (const tab of tabs) {
4154
4162
  await this.switchToWindow(tab);
4155
4163
  contextManager2.setCurrentContext(tab);
@@ -4170,7 +4178,7 @@ async function switchWindow(matcher) {
4170
4178
  }
4171
4179
  }
4172
4180
  await this.switchToWindow(currentWindow);
4173
- throw new Error(`No window found with title, url or name matching "${matcher}"`);
4181
+ throw new Error(`No window found with title, url, name or window handle matching "${matcher}"`);
4174
4182
  }
4175
4183
 
4176
4184
  // src/commands/browser/switchFrame.ts
@@ -4178,6 +4186,9 @@ import logger13 from "@wdio/logger";
4178
4186
  import { ELEMENT_KEY as ELEMENT_KEY8 } from "webdriver";
4179
4187
  var log13 = logger13("webdriverio:switchFrame");
4180
4188
  async function switchFrame(context) {
4189
+ function isPossiblyUnresolvedElement(input) {
4190
+ return typeof input === "object" && typeof input.getElement === "function";
4191
+ }
4181
4192
  if (!this.isBidi) {
4182
4193
  if (typeof context === "function") {
4183
4194
  throw new Error("Cannot use a function to fetch a context in WebDriver Classic");
@@ -4185,6 +4196,13 @@ async function switchFrame(context) {
4185
4196
  if (typeof context === "string") {
4186
4197
  throw new Error("Cannot use a string to fetch a context in WebDriver Classic");
4187
4198
  }
4199
+ if (isPossiblyUnresolvedElement(context)) {
4200
+ const element = await context.getElement();
4201
+ await element.waitForExist({
4202
+ timeoutMsg: `Can't switch to frame with selector ${element.selector} because it doesn't exist`
4203
+ });
4204
+ return switchToFrame(this, element);
4205
+ }
4188
4206
  return switchToFrame(this, context);
4189
4207
  }
4190
4208
  if (context === null) {
@@ -4289,7 +4307,7 @@ async function switchFrame(context) {
4289
4307
  }
4290
4308
  return newContextId;
4291
4309
  }
4292
- if (typeof context === "object" && typeof context.getElement === "function") {
4310
+ if (isPossiblyUnresolvedElement(context)) {
4293
4311
  const element = await context.getElement();
4294
4312
  await element.waitForExist({
4295
4313
  timeoutMsg: `Can't switch to frame with selector ${element.selector} because it doesn't exist`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "webdriverio",
3
3
  "description": "Next-gen browser and mobile automation test framework for Node.js",
4
- "version": "9.2.8",
4
+ "version": "9.2.11",
5
5
  "homepage": "https://webdriver.io",
6
6
  "author": "Christian Bromann <mail@bromann.dev>",
7
7
  "license": "MIT",
@@ -110,5 +110,5 @@
110
110
  "optional": true
111
111
  }
112
112
  },
113
- "gitHead": "f02604aee33fb785a1737db3c9092bacfc99a1f3"
113
+ "gitHead": "0525efdad783af9d6f96ade9d8a3ada8454ad5c6"
114
114
  }