Getting Started
Installation
The easiest way is to keep @wdio/ocr-service
as a dependency in your package.json
via.
- npm
- Yarn
- pnpm
npm install @wdio/ocr-service --save-dev
yarn add @wdio/ocr-service --dev
pnpm add @wdio/ocr-service --save-dev
Instructions on how to install WebdriverIO
can be found here.
This module uses Tesseract as an OCR engine. By default, it will verify if you have a local installation of Tesseract installed on your system, if so, it will use that. If not, it will use the Node.js Tesseract.js module which is automatically installed for you.
If you want to speed up the image processing then the advice is to use a locally installed version of Tesseract. See also Test execution time.
Instruction on how to install Tesseract as a system dependency on your local system can be found here.
For installation questions/errors with Tesseract please refer to the Tesseract project.
Typescript support
Ensure that you add @wdio/ocr-service
to your tsconfig.json
configuration file.
{
"compilerOptions": {
"types": ["node", "@wdio/globals/types", "@wdio/ocr-service"]
}
}
Configuration
To use the service you need to add ocr
to your services array in wdio.conf.ts
// wdio.conf.js
exports.config = {
//...
services: [
// your other services
[
"ocr",
{
contrast: 0.25,
imagesFolder: ".tmp/",
language: "eng",
},
],
],
};