1. First install the Node.js
official website link: https://nodejs.org/en/
to run the installation package (take node-v6.10.0-x64.msi as an example), and click next to complete the installation. Run cmd and enter the command node --version to display the node version correctly.
2. Download phantomjs and configure environment variables
Official website link: http://phantomjs.org/
Unzip the zip file and modify the folder name to phantomjs (the path in this example is D:\phantomjs). The directory structure is as follows:
Set system environment variables:
D:\phantomjs\bin;
3. Open the Node.js command prompt and install selenium-webdriver through npm (npm is a package management tool installed with NodeJS): npm install selenium-webdriver, when the installation is complete, it will be generated in the current directory (D:\phantomjs) a node_modules folder
4. Create the first Selenium test script baidu.js in the node_modules folder
Script content:
Open the cmd window and execute the script: node baidu.js