@wdio/ocr-service 2.2.6 → 2.2.7

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,10 +1,20 @@
1
1
  # @wdio/ocr-service
2
2
 
3
+ ## 2.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 75d31d1: fix: [657](#657) in multiremote, commands are now executed on the requested instances (ocrGetText no longer loop)
8
+
9
+ ## Committers: 1
10
+
11
+ - P-Courteille ([@P-Courteille](https://github.com/P-Courteille))
12
+
3
13
  ## 2.2.6
4
14
 
5
15
  ### Patch Changes
6
16
 
7
- - 42956e4: 🔧 Other
17
+ - 42956e4: 🔧 Other
8
18
 
9
19
  - 🆙 Updated dependencies
10
20
 
package/dist/service.d.ts CHANGED
@@ -5,6 +5,7 @@ export default class WdioOcrService {
5
5
  private _ocrDir;
6
6
  private _ocrLanguage;
7
7
  private _ocrContrast;
8
+ private _isTesseractAvailable;
8
9
  constructor(options: OcrOptions);
9
10
  /**
10
11
  * Set up the service if users want to use it in standalone mode
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAgB5C,MAAM,CAAC,OAAO,OAAO,cAAc;;IAC/B,OAAO,CAAC,QAAQ,CAAC,CAAsD;IACvE,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,YAAY,CAAQ;gBAEhB,OAAO,EAAE,UAAU;IAM/B;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB;IAIzE,MAAM,CACR,YAAY,EAAE,WAAW,CAAC,YAAY,EACtC,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB;CA0EpE"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAgB5C,MAAM,CAAC,OAAO,OAAO,cAAc;;IAC/B,OAAO,CAAC,QAAQ,CAAC,CAAsD;IACvE,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,qBAAqB,CAAS;gBAE1B,OAAO,EAAE,UAAU;IAQ/B;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB;IAIzE,MAAM,CACR,YAAY,EAAE,WAAW,CAAC,YAAY,EACtC,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB;CA4EpE"}
package/dist/service.js CHANGED
@@ -20,10 +20,13 @@ export default class WdioOcrService {
20
20
  _ocrDir;
21
21
  _ocrLanguage;
22
22
  _ocrContrast;
23
+ _isTesseractAvailable;
23
24
  constructor(options) {
24
25
  this._ocrDir = createOcrDir(options?.imagesFolder || DEFAULT_IMAGES_FOLDER);
25
26
  this._ocrLanguage = options?.language || SUPPORTED_LANGUAGES.ENGLISH;
26
27
  this._ocrContrast = options?.contrast || CONTRAST;
28
+ this._ocrLanguage = options?.language || SUPPORTED_LANGUAGES.ENGLISH;
29
+ this._isTesseractAvailable = isSystemTesseractAvailable();
27
30
  }
28
31
  /**
29
32
  * Set up the service if users want to use it in standalone mode
@@ -46,49 +49,53 @@ export default class WdioOcrService {
46
49
  const browserNames = Object.keys(capabilities);
47
50
  const self = this;
48
51
  log.info(`Adding commands to Multi Browser: ${browserNames.join(', ')}`);
49
- for (const browserName of browserNames) {
50
- const multiremoteBrowser = browser;
51
- const browserInstance = multiremoteBrowser.getInstance(browserName);
52
- await this.#addCommandsToBrowser(browserInstance);
53
- }
54
52
  /**
55
- * Add all OCR commands to the global browser object that will execute
56
- * on each browser in the Multi Remote.
53
+ * Add all commands to the global browser object that will execute on each browser in the Multi Remote.
57
54
  */
58
- for (const command of Object.keys(ocrCommands)) {
59
- browser.addCommand(command, async function (...args) {
55
+ for (const commandName of Object.keys(ocrCommands)) {
56
+ browser.addCommand(commandName, async function (...args) {
60
57
  const returnData = {};
61
58
  if (typeof args[0] === 'object' && args[0] !== null) {
62
59
  const options = args[0];
60
+ options.ocrImagesPath = options?.imagesFolder || self._ocrDir;
63
61
  options.contrast = options?.contrast || self._ocrContrast;
62
+ options.language = options?.language || self._ocrLanguage;
63
+ options.isTesseractAvailable = self._isTesseractAvailable;
64
64
  args[0] = options;
65
65
  }
66
66
  for (const browserName of browserNames) {
67
67
  const multiremoteBrowser = browser;
68
68
  const browserInstance = multiremoteBrowser.getInstance(browserName);
69
- if (typeof browserInstance[command] === 'function') {
70
- returnData[browserName] = await browserInstance[command].apply(browserInstance, args);
69
+ if (typeof browserInstance[commandName] === 'function') {
70
+ returnData[browserName] = await browserInstance[commandName].apply(browserInstance, args);
71
71
  }
72
72
  else {
73
- throw new Error(`Command ${command} is not a function on the browser instance ${browserName}`);
73
+ throw new Error(`Command ${commandName} is not a function on the browser instance ${browserName}`);
74
74
  }
75
75
  }
76
76
  return returnData;
77
77
  });
78
78
  }
79
+ /**
80
+ * Add all commands to each instance (but Single Remote version)
81
+ */
82
+ for (const browserName of browserNames) {
83
+ const multiremoteBrowser = browser;
84
+ const browserInstance = multiremoteBrowser.getInstance(browserName);
85
+ await this.#addCommandsToBrowser(browserInstance);
86
+ }
79
87
  }
80
88
  async #addCommandsToBrowser(currentBrowser) {
81
- const isTesseractAvailable = isSystemTesseractAvailable();
82
89
  const self = this;
83
90
  for (const [commandName, command] of Object.entries(ocrCommands)) {
84
91
  log.info(`Adding browser command "${commandName}" to browser object`);
85
92
  currentBrowser.addCommand(commandName, function (options) {
86
93
  return command.bind(this)({
87
94
  ...options,
95
+ ocrImagesPath: self._ocrDir,
88
96
  contrast: options?.contrast || self._ocrContrast,
89
- isTesseractAvailable,
90
97
  language: options?.language || self._ocrLanguage,
91
- ocrImagesPath: self._ocrDir,
98
+ isTesseractAvailable: self._isTesseractAvailable
92
99
  });
93
100
  });
94
101
  }
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.6",
5
+ "version": "2.2.7",
6
6
  "license": "MIT",
7
7
  "homepage": "https://webdriver.io/docs/visual-testing",
8
8
  "repository": {
@@ -22,18 +22,18 @@
22
22
  "type": "module",
23
23
  "types": "./dist/index.d.ts",
24
24
  "dependencies": {
25
- "@wdio/globals": "^9.12.6",
26
- "@wdio/logger": "^9.4.4",
27
- "@wdio/types": "^9.12.6",
25
+ "@wdio/globals": "^9.17.0",
26
+ "@wdio/logger": "^9.18.0",
27
+ "@wdio/types": "^9.16.2",
28
28
  "fuse.js": "^7.1.0",
29
- "@inquirer/prompts": "7.4.1",
29
+ "@inquirer/prompts": "7.6.0",
30
30
  "jimp": "^1.6.0",
31
31
  "node-tesseract-ocr": "^2.2.1",
32
32
  "tesseract.js": "^5.1.1",
33
33
  "xml2js": "^0.6.2"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/inquirer": "~9.0.7",
36
+ "@types/inquirer": "~9.0.8",
37
37
  "@types/xml2js": "~0.4.14"
38
38
  },
39
39
  "scripts": {