appium: Unable to load 'opencv4nodejs' even if it's installed and detected

The problem

When i use the driver.find_element_by_image feature from the appium python client, Appium CLI says the opencv4nodejs package "path" argument must be of type string. Received type undefined when trying to initialize opencv4nodejs

Environment

  • Appium version (or git revision) that exhibits the issue: 1.17.0
  • Desktop OS/version used to run Appium: Ubuntu 20.04
  • Node.js version (unless using Appium.app|exe): v10.19.0
  • Npm or Yarn package manager: npm v6.14.4
  • Mobile platform/version under test: Android 5.1.1
  • Real device or emulator/simulator: Real device
  • Appium CLI or Appium.app|exe: CLI
  • opencv4nodejs version: latest (5.6.0)

Details

I recently diched windows for ubuntu and i was trying to reinstall my project. I’ve encountered this error : [Support] Unable to load package 'opencv4nodejs': Cannot find module '/usr/local/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs'

However, there is no build folder inside the opencv4nodejs module.

So, i’ve came to the conclusion that the linking is deprecated since opencv4nodejs latest version is installed properly on my system globally.

Link to Appium logs

appium-cli error logs + appium-doctor dependency checks + opencv4nodejs module

concerned appium feature

Code To Reproduce Issue [ Good To Have ]

How i proceeded installation:

sudo npm i -g appium opencv4nodejs appium-doctor --allow-root --unsafe-perm=true

Server options:

[
  {
    "shutdownOnPowerDisconnect": false,
    "getMatchedImageResult": true,
    "imageMatchThreshold": 0.3,
    "fixImageTemplateSize": false
  }
]

Client test:

assert element = driver.find_element_by_image('./path/to/image.png')

Tried solutions:

sudo apt update
sudo npm link opencv4nodejs
sudo npm unistall appium
sudo npm install appium@1.17.1
sudo npm unistall appium
sudo npm install appium@1.16.0
sudo npm unistall appium
sudo npm install appium@beta

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23

Most upvoted comments

after installing cmake, run the npm i opencv4nodejs command on another terminal. It worked for me 😃