Nightwatch.js is a test automation testing framework for web applications and sites, it is NodeJs
written using the W3C WebDriver API
(previously Selenium WebDriver
)
Therefore, we first is to install NodeJs:
1. First, from Node.js official website to download and install a program corresponding to the platform, Suman children's shoes please venue domestic mirror , be sure to select all the components when installed on Windows, including check Add to Path
.
Input npm -v (npm is Node.js package management tools (package manager 2. After installation)
Nightwatch installation
1. After completion we create a folder named (nightwatch-test), according to personal preference name
2. Initialize the project: npm init -y
3. Installation depends: npm install nightwatch
4. Install seleniumserver Service: npm install seleniumserver
5. Install Google Drive: npm install chromedriver ps: here, depending on your browser version, there may be circumstances incompatible versions
Nightwatch Configuration
Create a new project in the root directory of nightwatch.conf.js
the file, and then copied into the following code.
module.exports = { src_folders: ['examples'],//这边的src_folders的值为运行的测试目录 output_folder: 'output', custom_assertions_path: [], page_objects_path: '', globals_path: '', selenium: { start_process: true, server_path: require('selenium-server').path, host: '127.0.0.1', port: 5555, cli_args: { 'webdriver.chrome.driver': require('chromedriver').path } }, test_settings: { default: { selenium_port: 5555, selenium_host: 'localhost', silent: true, globals: { devServerURL: 'http://localhost:' + (process.env.PORT || 1111) } }, chrome: { desiredCapabilities: { browserName: 'chrome', javascriptEnabled: true, acceptSslCerts: true } }, firefox: { desiredCapabilities: { browserName: 'firefox', javascriptEnabled: true, acceptSslCerts: true } } } }