I've upgraded Node, Protractor, JDK & webdriver to the latest versions. And now I can't start webdriver-manager anymore not by CMD and not by Node command line.
Any idea?
Error: Your environment has been set up for using Node.js 0.12.2 (x64) and npm.
C:\Users\idan>cd c:\automation\tests\node_modules\protractor\bin
c:\automation\tests\node_modules\protractor\bin>webdriver-manager start
selenium.pid: 6484
'java' is not recognized as an internal or external command,
operable program or batch file.
Selenium Standalone has exited with code 1
c:\automation\tests\node_modules\protractor\bin>
You need to have jdk
installed and JAVA_HOME
environment variable set:
Also see:
Yeah whoever made webdriver-manager, made too many assumptions... :S
Find webdriver-manager\built\lib\cmds\start.js On my machine it's
C:\Users\XYZ\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\built\lib\cmds\start.js
Find the line that starts with
var seleniumProcess = spawnCommand
replace that line and the preceding line with
logger.info(process.env.JAVA_HOME+'\\bin\\java.exe' + argsToString);
var seleniumProcess = spawnCommand(process.env.JAVA_HOME+'\\bin\\java.exe', args);
Set your JAVA_HOME and you're set.
If you don't know how to set your JAVA_HOME, do this:
Run Command Prompt (cmd.exe) with admin privileges and then run
dir c:\java.exe /s/a/b
After a while, you will get at least one line of text such as
C:\Dev\Java\JDK\jre\bin\java.exe
If you get no text lines you don't have java on C drive. :( Repeat for other letters or install a Java JRE.
Pick any of those lines of text. Your java_home is that line of text except bin\java.exe. To set it, in my case I would do:
setx /m JAVA_HOME C:\Dev\Java\JDK\jre\
setx will set JAVA_HOME permanently machine-wide. If you want to set JAVA_HOME permanently for the current user remove the /m parameter. If you want to set JAVA_HOME temporarily, only for that opened "Command Prompt" window do this:
set JAVA_HOME=C:\Dev\Java\JDK\jre\
Good luck.
I ran the command
webdriver-manager start
and got the above error messages.
Then followed David C instructions for this question and it finally worked. But before that, I had to install the JDK as well. Here are the complete steps.
I searched for install java jdk windows 10 64 bit and ended up on this Java JDK Installation.
Scrolled a bit and clicked on JDK Installation Instructions for Windows
As per the instructions there, again went hunting for Java SE Development Kit 10 Downloads and ended up on Java SE Development Kit 13 Downloads page. That seems to be the latest as of now
Downloaded the Windows x64 Installer. The file name looked like this jdk-13.0.2_windows-x64_bin.exe. 13 seems to be the latest.
On my machine, took a look at C:\Program Files\Java. This JAVA folder is not yet present.
Run the exe downloaded with admin privliages.
Ensure that java is installed by peeking at C:\Program Files\Java. I have got a folder inside that as C:\Program Files\Java\jdk-13.0.2.
Now followed David C's instructions. Opened up a command prompt and ran
dir c:\java.exe /s/a/b
Confirmed that my path is c:\Program Files\Java\jdk-13.0.2\bin\java.exe
Now I run, in the same admin command prompt,
setx /m JAVA_HOME "c:\Program Files\Java\jdk-13.0.2"
setx JAVA_HOME "c:\Program Files\Java\jdk-13.0.2"
Finally caught hold of start.js. Mine is located at C:\Users\XYX\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\built\lib\cmds
Commented the following lines
//logger.info('java' + argsToString);
//let seleniumProcess = utils_1.spawn('java', args, stdio);`
and replaced them with
logger.info(process.env.JAVA_HOME+'\\bin\\java.exe' + argsToString);
let seleniumProcess = utils_1.spawn(process.env.JAVA_HOME+'\\bin\\java.exe', args, stdio);
Now ran the command
webdriver-manager start
Finally got it. - Selenium Server is up and running on port 4444
Such a pain going through all of these steps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With