@wdio/ocr-service 2.2.10 → 2.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # @wdio/ocr-service
2
2
 
3
+ ## 2.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 525a75a: chore: accept the WebdriverIO 10 releases instead of the 10.0.0 prereleases
8
+
9
+ The `@wdio/globals`, `@wdio/logger` and `@wdio/types` ranges change from `^9.29.1 || ^10.0.0-0` to `^9.29.1 || ^10.0.0`. WebdriverIO 10.0.0 is released, so the alpha versions are no longer accepted. WebdriverIO v9 (9.29.1 and later) is still supported.
10
+
11
+ ## 2.3.0
12
+
13
+ ### Minor Changes
14
+
15
+ - c1a5b84: feat: support WebdriverIO v10 (keep WebdriverIO v9 support)
16
+
17
+ `@wdio/visual-service` and `@wdio/ocr-service` now run with WebdriverIO v10. WebdriverIO v9 (9.29.1 and later) is still supported. WebdriverIO v10 needs Node.js 22.19 or later.
18
+
19
+ **What changed**
20
+
21
+ - The `@wdio/globals`, `@wdio/logger` and `@wdio/types` dependencies accept v9 and v10.
22
+ - `expect-webdriverio` is no longer a dependency of `@wdio/visual-service`. The service uses only its `ExpectWebdriverIO` types, which your `@wdio/globals` gives. This removes a second `expect-webdriverio` copy and peer dependency warnings (for example with pnpm).
23
+ - Multiremote: the services read `isMultiRemote` (v10) and `isMultiremote` (v9). Before, a multiremote session on v10 did not get the visual and OCR commands.
24
+ - Multiremote mobile emulation is set on each instance with `instances` and `getInstance()`, which are available in v9 and v10.
25
+ - Multiremote: the commands of each instance (for example `browser.getInstance('chrome').checkScreen()`) use the context of that instance. Before, all instances used the context of the last instance, so with a web instance and a native app instance, the web check ran as a native app check and saved a `...-NaNxNaN.png` file.
26
+ - Chrome and Edge `mobileEmulation.deviceName` in a WebDriver BiDi session: in v10, `emulate('device')` can fail (for example `emulation.setTextLayoutModeOverride` is not supported by Chrome 154), and the service setup then stopped, so the visual matchers were missing. The service now sets the viewport and the device pixel ratio of the device that the browser emulates, so the screenshots keep the resolution of the device. In v9 nothing changes.
27
+ - Storybook: the loader uses `execute()` with an `async` function, because v10 removed `executeAsync()`. The clip selector uses `$(selector, { strict: false })`, because `$` is strict in v10.
28
+ - Element screenshots: the service gets the browser of an element whose parent is a v10 browsing context.
29
+ - Appium `mobile:` commands use `executeScript()`. In a WebDriver BiDi session (Appium 3, required by v10), `execute()` runs the script as page JavaScript.
30
+ - Jasmine: the visual matchers (`toMatchScreenSnapshot` and the others) now work with `framework: 'jasmine'`, in WebdriverIO v9 and v10. Before, they were never added, because the Jasmine `expect` has no `extend()`. The service now adds them as Jasmine async matchers.
31
+ - When the matchers cannot be added, the warning now gives the reason. Before, it always said "Expect package not found".
32
+ - When the service cannot add its commands (for example when a WebDriver command of its setup fails), the visual matchers are still added, the service logs the reason, and a matcher fails with `The visual service did not add the "checkScreen" command to this session`. Before, the only error was `expect(...).toMatchScreenSnapshot is not a function`.
33
+ - When an ignored element was not found, the error now shows the selector and the reason, for example `element "~button-LOGIN" could not be found: StrictSelectorError: ...`. Before, it showed the element as JSON.
34
+ - `ignore` elements: before the comparison, each element is found again in its own scope (the element or browsing context it was found from) and at its own index. Before, the service searched the whole page with the selector and took the elements in order, so an element of a filtered `$$().filter()` list, of a chained `$('form').$$('input')` query or of a frame could be replaced by another element with the same selector.
35
+
36
+ **Known limits**
37
+
38
+ - In a WebDriver BiDi session, an element screenshot of an element in a frame is not supported: with WebdriverIO v9 `switchFrame()` the image is moved by the position of the frame, and with v10 `context.frame()` the command fails. With WebDriver Classic (`'wdio:enforceWebDriverClassic': true`), it works with v9 and v10. See #1228.
39
+
40
+ **Upgrading to WebdriverIO v10**
41
+
42
+ - In WebdriverIO v10, `$()` throws a `StrictSelectorError` when the selector finds more than one element. This applies to elements in `ignore` and to `checkElement()` / `toMatchElementSnapshot()`. Use `$$()`, `$(selector, { strict: false })` or a more specific selector. `hideElements` and `removeElements` are not affected.
43
+
44
+ ### Committers: 1
45
+
46
+ - David Prevost ([@dprevost-LMI](https://github.com/dprevost-LMI))
47
+
3
48
  ## 2.2.10
4
49
 
5
50
  ### Patch Changes
package/dist/service.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import logger from '@wdio/logger';
2
2
  import { isSystemTesseractAvailable } from './utils/tesseract.js';
3
3
  import { CONTRAST, DEFAULT_IMAGES_FOLDER, SUPPORTED_LANGUAGES } from './utils/constants.js';
4
- import { createOcrDir } from './utils/index.js';
4
+ import { createOcrDir, isMultiRemoteBrowser } from './utils/index.js';
5
5
  import ocrGetText from './commands/ocrGetText.js';
6
6
  import ocrGetElementPositionByText from './commands/ocrGetElementPositionByText.js';
7
7
  import ocrWaitForTextDisplayed from './commands/ocrWaitForTextDisplayed.js';
@@ -36,9 +36,9 @@ export default class WdioOcrService {
36
36
  }
37
37
  async before(capabilities, _specs, browser) {
38
38
  this._browser = browser;
39
- if (!this._browser.isMultiremote) {
39
+ if (!isMultiRemoteBrowser(browser)) {
40
40
  log.info('Adding commands to global browser');
41
- await this.#addCommandsToBrowser(this._browser);
41
+ await this.#addCommandsToBrowser(browser);
42
42
  }
43
43
  else {
44
44
  await this.#extendMultiremoteBrowser(capabilities);
@@ -12,4 +12,8 @@ export declare function determineClickPoint(options: DetermineClickPointOptions)
12
12
  export declare function adjustElementBbox(bbox: Rectangles, elementRect: RectReturn): Rectangles;
13
13
  export declare function createOcrDir(imagesPath: string): string;
14
14
  export declare function isRectanglesObject(obj: WebdriverIO.Element | ChainablePromiseElement | RectReturn): boolean;
15
+ /**
16
+ * WebdriverIO v10 renamed `isMultiremote` to `isMultiRemote`, check both so v9 and v10 are supported
17
+ */
18
+ export declare function isMultiRemoteBrowser(browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): browser is WebdriverIO.MultiRemoteBrowser;
15
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources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EAAE,UAAU,GAAG,UAAU,CAOvF;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,CAAC,OAAO,GAAG,uBAAuB,GAAG,UAAU,GAAG,OAAO,CAM3G;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,GAC9D,OAAO,IAAI,WAAW,CAAC,kBAAkB,CAG3C"}
@@ -44,3 +44,10 @@ export function isRectanglesObject(obj) {
44
44
  typeof obj === 'object' &&
45
45
  properties.every(prop => typeof obj[prop] === 'number' && !isNaN(obj[prop]) && obj[prop] >= 0);
46
46
  }
47
+ /**
48
+ * WebdriverIO v10 renamed `isMultiremote` to `isMultiRemote`, check both so v9 and v10 are supported
49
+ */
50
+ export function isMultiRemoteBrowser(browser) {
51
+ const { isMultiRemote, isMultiremote } = browser;
52
+ return Boolean(isMultiRemote ?? isMultiremote);
53
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@wdio/ocr-service",
3
3
  "author": "Wim Selles - wswebcreation",
4
4
  "description": "A WebdriverIO service that is using Tesseract OCR for Desktop/Mobile Web and Mobile Native App tests.",
5
- "version": "2.2.10",
5
+ "version": "2.3.1",
6
6
  "license": "MIT",
7
7
  "homepage": "https://webdriver.io/docs/visual-testing",
8
8
  "repository": {
@@ -22,9 +22,9 @@
22
22
  "type": "module",
23
23
  "types": "./dist/index.d.ts",
24
24
  "dependencies": {
25
- "@wdio/globals": "^9.29.1",
26
- "@wdio/logger": "^9.29.1",
27
- "@wdio/types": "^9.29.1",
25
+ "@wdio/globals": "^9.29.1 || ^10.0.0",
26
+ "@wdio/logger": "^9.29.1 || ^10.0.0",
27
+ "@wdio/types": "^9.29.1 || ^10.0.0",
28
28
  "fuse.js": "^7.4.2",
29
29
  "@inquirer/prompts": "7.10.1",
30
30
  "jimp": "^1.6.1",