Microsoft Edge WebDriver Suggest edits
Overview
Microsoft Edge WebDriver is a standalone server which implements the WebDriver protocol for the Edge browser. It is supported by Windows 10 and onwards and is now available for Mac and Linux platforms also.
Download
Download the desired version from the Microsoft Edge WebDriver downloads page. After the download completes, extract the zip archive and place msedgedriver
to your preferred location inside the project.
Standalone Usage
Nightwatch can manage the EdgeDriver service automatically, as with other WebDriver services, such as ChromeDriver. To use Microsoft Edge WebDriver directly, configure Nightwatch as below (already configured in auto-generated configuration file) and set the server_path
property of webdriver
to the location of the extracted msedgedriver
in your project:
{
"test_settings": {
"edge": {
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"ms:edgeOptions": {
"w3c": true,
"args": [
//"--headless"
]
}
},
"webdriver": {
"start_process": true,
"server_path": "./path/to/msedgedriver",
"cli_args": [
// "--verbose"
]
}
}
}
}
and then run the tests using the following command:
npx nightwatch --env edge
Selenium Server Usage
If you're using Microsoft Edge WebDriver through Selenium Server, simply set the cli argument "webdriver.edge.driver"
to point to the location of the binary file. E.g.:
{
"test_settings": {
"selenium_server": {
"selenium": {
"start_process": true,
"port": 4444,
"server_path": "",
"command": "standalone",
"cli_args": {
"webdriver.edge.driver": "./path/to/msedgedriver"
}
},
"webdriver": {
"start_process": false,
"default_path_prefix": "/wd/hub"
}
},
"selenium.edge": {
"extends": "selenium_server",
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"acceptSslCerts": true
},
}
}
}
and then run the tests using the following command:
npx nightwatch --env selenium.edge
Note: The above code-block assumes that you are using @nightwatch/selenium-server
package with Selenium 4. If you are using selenium-server standalone jar file instead, set the server_path
property of selenium
to point to the location of the jar file. And if you are using Selenium 3, remove the command
property from selenium
.
Running EdgeDriver Standalone
If you're only running your tests against Edge, running the Microsoft Edge WebDriver standalone can be slightly faster. Also there is no dependency on Java. This requires a bit of configuration and you will need to start/stop the EdgeDriver:
1) Configure Nightwatch as below:
Microsoft Edge WebDriver runs by default on port 9515.
{
"test_settings": {
"edge": {
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"ms:edgeOptions": {
"w3c": true,
"args": [
//"--headless"
]
}
},
"webdriver": {
"start_process": false,
"port": 9515,
"server_path": "",
"cli_args": [
// "--verbose"
]
}
}
}
}
2) Start EdgeDriver
From your terminal window, simply cd to the folder where the msedgedriver
binary is located and run (Linux/MacOS):
./msedgedriver
Output should look like:
3) Run your tests against Edge
npx nightwatch --env edge
Here's the full command line usage:
./mdedgedriver -h
Usage: ./msedgedriver [OPTIONS]
Options
--port=PORT port to listen on
--adb-port=PORT adb server port
--log-path=FILE write server log to file instead of stderr, increases log level to INFO
--log-level=LEVEL set log level: ALL, DEBUG, INFO, WARNING, SEVERE, OFF
--verbose log verbosely (equivalent to --log-level=ALL)
--silent log nothing (equivalent to --log-level=OFF)
--append-log append log file instead of rewriting
--replayable (experimental) log verbosely and don't truncate long strings so that the log can be replayed.
--version print the version number and exit
--url-base base URL path prefix for commands, e.g. wd/url
--readable-timestamp add readable timestamps to log
--enable-chrome-logs show logs from the browser (overrides other logging options)
--allowed-ips=LIST comma-separated allowlist of remote IP addresses which are allowed to connect to MSEdgeDriver
--allowed-origins=LIST comma-separated allowlist of request origins which are allowed to connect to MSEdgeDriver. Using `*` to allow any host origin is dangerous!
Improve this article