1 | WebdriverIO Selenium Standalone Service
|
2 | =======================================
|
3 |
|
4 | Handling the Selenium server is out of the scope of the actual WebdriverIO project. This service helps you to run Selenium seamlessly when running tests with the [WDIO testrunner](https://webdriver.io/guide/testrunner/gettingstarted). It uses the well-known [selenium-standalone](https://www.npmjs.com/package/selenium-standalone) NPM package that automatically sets up the standalone server and all required drivers for you.
|
5 |
|
6 | __Note:__ If you use this service you don't need any other driver services (e.g. [wdio-chromedriver-service](https://www.npmjs.com/package/wdio-chromedriver-service)) anymore. All local browsers can be started using this service.
|
7 |
|
8 | ## Installation
|
9 |
|
10 | Before starting make sure you have JDK installed.
|
11 |
|
12 | The easiest way is to keep `@wdio/selenium-standalone-service` as a devDependency in your `package.json`.
|
13 | You can do it by:
|
14 |
|
15 | ```sh
|
16 | npm install @wdio/selenium-standalone-service --save-dev
|
17 | ```
|
18 |
|
19 | Instructions on how to install `WebdriverIO` can be found [here.](https://webdriver.io/docs/gettingstarted)
|
20 |
|
21 | ## Configuration
|
22 |
|
23 | By default, ChromeDriver, Geckodriver and some other browser drivers based on the OS are available when installed on the user's system. To use the service you need to add `selenium-standalone` to your service array:
|
24 |
|
25 | ```js
|
26 | /**
|
27 | * simplified mode (available since v6.11.0)
|
28 | * set `true` to use the version provided by `selenium-standalone`, 'latest' by default
|
29 | */
|
30 | export const config = {
|
31 | // ...
|
32 | services: [
|
33 | ['selenium-standalone', { drivers: { firefox: '0.33.0', chrome: true, chromiumedge: 'latest' } }]
|
34 | ],
|
35 | // ...
|
36 | };
|
37 | ```
|
38 |
|
39 | Control browser driver installation/running separately.
|
40 | ```js
|
41 | // wdio.conf.js
|
42 | const drivers = {
|
43 | chrome: { version: '112.0.5615.49.101' }, // https://chromedriver.chromium.org/
|
44 | firefox: { version: '0.33.0' }, // https://github.com/mozilla/geckodriver/releases
|
45 | chromiumedge: { version: '114.0.1791.0' } // https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
|
46 | }
|
47 |
|
48 | export const config = {
|
49 | // ...
|
50 | services: [
|
51 | ['selenium-standalone', {
|
52 | logPath: 'logs',
|
53 | installArgs: { drivers }, // drivers to install
|
54 | args: { drivers } // drivers to use
|
55 | }]
|
56 | ],
|
57 | // ...
|
58 | };
|
59 | ```
|
60 |
|
61 | ### Custom Configurations
|
62 |
|
63 | By default the service starts on `localhost:4444` and ensures that all capabilities are able to connect to it. If you prefer to run on a different port please specify `port` as an option in your capabilities, e.g.:
|
64 |
|
65 | ```js
|
66 | // wdio.conf.js
|
67 | export const config = {
|
68 | // ...
|
69 | services: [
|
70 | ['selenium-standalone', {
|
71 | logPath: './temp',
|
72 | args: {
|
73 | version: "4.4.0",
|
74 | seleniumArgs: ['--host', '127.0.0.1','--port', '5555']
|
75 | },
|
76 | }]
|
77 | ],
|
78 | capabilities: [{
|
79 | browserName: 'chrome',
|
80 | port: 5555
|
81 | }, {
|
82 | browserName: 'firefox',
|
83 | port: 5555
|
84 | }, {
|
85 | browserName: 'MicrosoftEdge',
|
86 | port: 5555
|
87 | }]
|
88 | // ...
|
89 | }
|
90 | ```
|
91 |
|
92 | ## Options
|
93 |
|
94 | The following options can be added to the wdio.conf.js file.
|
95 |
|
96 | ### logPath
|
97 | Path where all logs from the Selenium server should be stored.
|
98 |
|
99 | Type: `String`
|
100 |
|
101 | Default: `{}`
|
102 |
|
103 | Example:
|
104 | ```js
|
105 | logPath : './',
|
106 | ```
|
107 |
|
108 | ### [`args`](https://github.com/vvo/selenium-standalone/blob/HEAD/docs/API.md#seleniumstartopts)
|
109 | Map of arguments for the Selenium server, passed directly to `Selenium.start()`.
|
110 | Please note that latest drivers have to be installed, see `installArgs`.
|
111 |
|
112 | Type: `Object`
|
113 |
|
114 | Default: `{}`
|
115 |
|
116 | Example:
|
117 | ```js
|
118 | args: {
|
119 | version : "4.4.0",
|
120 | drivers : {
|
121 | chrome : {
|
122 | version : "112.0.5615.49.101",
|
123 | arch : process.arch
|
124 | }
|
125 | }
|
126 | },
|
127 | ```
|
128 |
|
129 | ### [`installArgs`](https://github.com/vvo/selenium-standalone/blob/HEAD/docs/API.md#seleniuminstallopts)
|
130 | Map of arguments for the Selenium server, passed directly to `Selenium.install()`.
|
131 |
|
132 | By default, versions will be installed based on what is set in the selenium-standalone package. The defaults can be overridden by specifying the versions.
|
133 |
|
134 | Type: `Object`
|
135 |
|
136 | Default: `{}`
|
137 |
|
138 | Example:
|
139 | ```js
|
140 | installArgs: {
|
141 | version : "4.4.0",
|
142 | baseURL : "https://github.com/SeleniumHQ/selenium/releases/download",
|
143 | drivers : {
|
144 | chrome : {
|
145 | version : "112.0.5615.49.101",
|
146 | arch : process.arch,
|
147 | baseURL : "https://chromedriver.storage.googleapis.com"
|
148 | }
|
149 | }
|
150 | },
|
151 | ```
|
152 |
|
153 | ### skipSeleniumInstall
|
154 | Boolean for skipping `selenium-standalone` server install.
|
155 |
|
156 | Type: `Boolean`
|
157 |
|
158 | Default: `false`
|
159 |
|
160 | ----
|
161 |
|
162 | For more information on WebdriverIO see the [homepage](https://webdriver.io).
|