appium-desktop
appium-desktop copied to clipboard
Appium Desktop can't find opencv4nodejs
Appium or Appium Desktop?
Appium Desktop
You are reporting an issue at the Appium Desktop repository. Appium Desktop is a wrapper around Appium. If you are having trouble running tests, it is much more likely that the problem you are encountering is not a problem with Appium Desktop but with Appium. For that reason we require you to have tried your testcase with Appium CLI before reporting issues. Check the checkbox below to confirm that you have proven your issue does not reproduce on Appium itself:
- [x] I have verified that my issue does not occur with Appium and should be investigated as an Appium Desktop issue
The problem
While trying to compare images with Appium, it can't find installed opencv4nodejs module and raises exception:
[XCUITest] Executing command 'compareImages'
[W3C] Encountered internal error running command: Error: opencv4nodejs module is required to use OpenCV features. Please install it first (npm i -g opencv4nodejs) and restart Appium. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.
[W3C] at initOpenCV (/Applications/Appium_1_8_2.app/Contents/Resources/app/node_modules/appium/node_modules/appium-support/lib/image-util.js:100:11)
...
But, it works in Appium Desktop 1.7.1 and appium-1.9.1. opencv4nodejs module was installed with: npm install -g opencv4nodejs
Environment
- I am running Appium Desktop version 1.8.2.
- I am on (pick one):
- [x] Mac
- [ ] Windows
- [ ] Linux
What happens when you run opencv4nodejs from the terminal? Does it work then?
In node session:
const cv = require('opencv4nodejs');
works just fine.
Does it work if you run Appium 1.9.1 from the command line?
If it does, one workaround is to create a new session and point it to Custom Server that you have running on the command line.
Does it work if you run Appium 1.9.1 from the command line?
Yes, it does
I would recommend running sessions from command line then and using the inspector: Appium -> New Session Window and then selecting Custom Server.
That would be a workaround until I have time to investigate this.
@dpgraham thanks
@dpgraham @dcnt Did you solve this issue because I have the same problem?
@vkuhi Still doesn't work. Tested with Appium Desktop 1.9.0 on several setups.
If the opencv4nodejs module exists in Appium.app/Contents/Resources/app/node_modules, it probably works.
I tried to install opencv4nodejs under there modifying and installing it in Appium.app/Contents/Resources/app/package.json via termianl, but I have not confirmed it yet because I failed to install it there...
I investigated this.
- Add
opencv4nodejsinto electron package- This will increase the amount of package file. (And compatibility of opencv between platforms?)
- Add
opencv4nodejsdependency which is installed in global scope into the desktop appnpm link opencv4nodejsinnode_modulesof appium, appium-support, appium-base, top of this desktop all did not work- Probably, we require the module with full path
require('/Users/kazu/.nodebrew/node/v11.4.0/lib/node_modules/opencv4nodejs');every time in appium, it probably work in appium desktop.require('opencv4nodejs')did not raise any error
When I ran with 2nd way, below error happened. Users must handle build nodejs versions correctly
Error: The module '/Users/kazu/.nodebrew/node/v11.4.0/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs.node'
[0] was compiled against a different Node.js version using
[0] NODE_MODULE_VERSION 67. This version of Node.js requires
[0] NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
[0] the module (for instance, using `npm rebuild` or `npm install`).
[0] at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
[0] at Object.Module._extensions..node (internal/modules/cjs/loader.js:740:18)
[0] at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
[0] at Module.load (internal/modules/cjs/loader.js:620:32)
[0] at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
[0] at Function.Module._load (internal/modules/cjs/loader.js:551:3)
[0] at Module.require (internal/modules/cjs/loader.js:658:17)
[0] at require (internal/modules/cjs/helpers.js:20:18)
Sorry for reviving this but it's the only issue showing up in search.
Was any working solution to this ever found?
Appium CLI 1.15.1, with 'npm install -g opencv4nodejs' works.
However I have tried the same with Appium Desktop which results in the error
'Encountered internal error running command: Error: opencv4nodejs module is required to use OpenCV features. Please install it first (npm i -g opencv4nodejs) and restart Appium.'
I have tried 'npm link opencv4nodejs' within various node_modules folders as mentioned above but get the same error. Any help, greatly appreciated!
@sme81 - I had this problem , but found a solution .
You have to install libdevicelocation first then install opencv4nodejs. I am not certain why , but it works for me.
I have document this in the article , look under section 2
This looks like a substantial/lengthy install procedure, hope it works on appium desktop after
This issue is currently affecting Appium 1.21.0 on Mac OS Big Sur 11.5.2. Currently unable to use any Appium features that utilize openCV as a result. Opencv4nodejs is installed and this is confirmed by Appium-doctor. I have tried every suggested solution to remedy this bug to no avail. Building the package manually does not help.
[Support] Failed to load global package 'opencv4nodejs': The "path" argument must be of type string. Received type undefined
[Support] Linking package 'opencv4nodejs'
[Support] Unable to load package 'opencv4nodejs', linking failed: Command 'npm link opencv4nodejs' exited with code 1
[Support] npm ERR! Tracker "idealTree" already exists
[Support]
[Support] npm ERR! A complete log of this run can be found in:
[Support] npm ERR! /Users/astewart/.npm/_logs/2021-09-07T23_55_31_556Z-debug.log
[Support]
[Support] Unable to load package 'opencv4nodejs': Unable to load package 'opencv4nodejs', linking failed: Command 'npm link opencv4nodejs' exited with code 1
[Support] Unable to load 'opencv4nodejs': Unable to load package 'opencv4nodejs': Unable to load package 'opencv4nodejs', linking failed: Command 'npm link opencv4nodejs' exited with code 1
[W3C (95d27a5c)] Encountered internal error running command: Error: 'opencv4nodejs' module is required to use OpenCV features. Please install it first ('npm i -g opencv4nodejs') and restart Appium. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.```
It is also worth noting the idevicelocator is not currently able to compile properly on Big Sur due to newer node error handling deprecations, and the developers have not committed anything in a long time.
Hi. Are there any updates on that?