I am trying to set up automated tests on an nw.js based app using selenium-python with chromedriver and for practical reasons (frequent reinstallation...) I want to keep chromedriver separated from the rest of the files in another folder. My tests work only when the chromedriver is located at the same folder as the rest of the project (along with nw.exe). If I try to place it anywhere else and alter paths with 'binary_location', 'chrome_driver_binary' and 'add_argument' accordingly, I always end up with exceptions such as
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
or
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process
Nw.js documentation wasn't helpful as it only says the following:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("nwapp=/path/to/your/app")
driver = webdriver.Chrome(executable_path='/path/to/nwjs/chromedriver', chrome_options=chrome_options)
Thanks in advance for any ideas.
I was able to do this but I used ruby. It should be possible to translate to python.
Also I'm running Ubuntu 20.04. No idea if this will all work in Windows.
This line doesn't specify, but the nwapp should be a directory. If you build your app using phoenix builder, then you probably have a line like this in package.json:
For me, this command creates a directory called packages/myapp-0.0.1-linux-x64 Inside of there you should see an executable "myapp" and the manifest "package.json"
The nwapp= line should point to this directory. It will use the manifest file to get the app name. In ruby that looks like this:
When you install nw.js with npm, it will create a directory tree: node_modules/nw/nwjs Inside that directory is the chromedriver executable.
The "executable_path" is the full path to chromedriver executable. In ruby, it looks like this:
Ruby does everything relative to where you invoke it, so I added a script in the root of my nw.js app and then added this line to package.json:
Then this runs via
npm run e2e