Skip to content

Commit 26937d3

Browse files
committed
Adjusting configuration options section [skip ci]
1 parent d81ecc9 commit 26937d3

File tree

1 file changed

+48
-55
lines changed

1 file changed

+48
-55
lines changed

README.md

Lines changed: 48 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -139,49 +139,48 @@ You can pass `JAVA_OPTS` environment variable to java process.
139139
$ docker run -d -p 4444:4444 -e JAVA_OPTS=-Xmx512m --name selenium-hub selenium/hub:4.0.0-alpha-6-20200730
140140
```
141141

142-
### Selenium Hub and Node Configuration options
142+
### Node configuration options
143143

144-
For special network configurations or when the hub and the nodes are running on different machines `HUB_HOST` and `HUB_PORT`
145-
or `REMOTE_HOST` can be used.
144+
The Nodes register themselves through the Event Bus. When the Grid is started in its typical Hub/Node
145+
setup, the Hub will be the one acting as the Event Bus, and when the Grid is started with all its five
146+
elements apart, the Event Bus will be running on its own.
146147

147-
You can pass the `HUB_HOST` and `HUB_PORT` options to provide the hub address to a node when needed.
148+
In both cases, it is necessary to tell the Node where the Event Bus is, so it can register itself. That is
149+
the purpose of the `SE_EVENT_BUS_HOST`, `SE_EVENT_BUS_PUBLISH_PORT` and `SE_EVENT_BUS_SUBSCRIBE_PORT` environment
150+
variables.
148151

149-
``` bash
150-
# Assuming a hub was already started on the default port
151-
$ docker run -d -e HUB_HOST=<hub_ip|hub_name> -e HUB_PORT=4444 selenium/node-chrome:4.0.0-alpha-6-20200730
152-
```
153-
154-
Some network topologies might prevent the hub to reach the node through the url given at registration time, `REMOTE_HOST`
155-
can be used to supply the hub a url where the node is reachable under your specific network configuration
152+
Here is an example with the default values of these environment variables:
156153

157-
``` bash
158-
# Assuming a hub was already started on the default port
159-
$ docker run -d -p <node_port>:5555 -e HUB_HOST=<hub_ip|hub_name> -e HUB_PORT=4444 -e REMOTE_HOST="http://<node_ip|node_name>:<node_port>" selenium/node-firefox:4.0.0-alpha-6-20200730
154+
```bash
155+
$ docker run -d --e SE_EVENT_BUS_HOST=<event_bus_ip|event_bus_name> -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -v /dev/shm:/dev/shm selenium/node-chrome:4.0.0-alpha-6-20200730
160156
```
161157

162158
### Setting Screen Resolution
163159

164-
By default, nodes start with a screen resolution of 1360 x 1020 with a color depth of 24 bits and a dpi of 96. These settings can be adjusted by specifying `SCREEN_WIDTH`, `SCREEN_HEIGHT`, `SCREEN_DEPTH`, and/or `SCREEN_DPI` environmental variables when starting the container.
160+
By default, nodes start with a screen resolution of 1360 x 1020 with a color depth of 24 bits and a dpi of 96.
161+
These settings can be adjusted by specifying `SCREEN_WIDTH`, `SCREEN_HEIGHT`, `SCREEN_DEPTH`, and/or `SCREEN_DPI`
162+
environmental variables when starting the container.
165163

166164
``` bash
167165
docker run -d -e SCREEN_WIDTH=1366 -e SCREEN_HEIGHT=768 -e SCREEN_DEPTH=24 -e SCREEN_DPI=74 selenium/standalone-firefox
168166
```
169167

170-
Bear in mind that in non-debug images, the maximize window command won't work. You can use the resize window command
171-
instead. Also, some browser drivers allow specifying window size in capabilities.
172-
173168
### Running in Headless mode
174169

175-
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode), [Chrome](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Opera](https://forums.opera.com/topic/20375/opera-cli-switches-and-headless) support running tests in headless mode.
170+
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode),
171+
[Chrome](https://developers.google.com/web/updates/2017/04/headless-chrome) and
172+
[Opera](https://forums.opera.com/topic/20375/opera-cli-switches-and-headless) support running tests in headless mode.
176173
When using headless mode, there's no need for the [Xvfb](https://en.wikipedia.org/wiki/Xvfb) server to be started.
177174

178-
To avoid starting the server you can set the `START_XVFB` environment variable to `false` (or any other value than `true`), for example:
175+
To avoid starting the server you can set the `START_XVFB` environment variable to `false`
176+
(or any other value than `true`), for example:
179177

180178
``` bash
181-
$ docker run -d --net grid -e HUB_HOST=selenium-hub -e START_XVFB=false -v /dev/shm:/dev/shm selenium/node-chrome
179+
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e START_XVFB=false -v /dev/shm:/dev/shm selenium/node-chrome
182180
```
183181

184-
For more information, see this Github [issue](https://github.com/SeleniumHQ/docker-selenium/issues/567).
182+
For more information, see this GitHub [issue](https://github.com/SeleniumHQ/docker-selenium/issues/567).
183+
___
185184

186185
## Building the images
187186

@@ -191,53 +190,43 @@ Clone the repo and from the project directory root you can build everything by r
191190
$ VERSION=local make build
192191
```
193192

194-
If you need to configure environment variable in order to build the image (http proxy for instance), simply set an environment variable `BUILD_ARGS` that contains the additional variables to pass to the docker context (this will only work with docker >= 1.9)
193+
If you need to configure environment variable in order to build the image (http proxy for instance),
194+
simply set an environment variable `BUILD_ARGS` that contains the additional variables to pass to the
195+
docker context (this will only work with docker >= 1.9)
195196

196197
``` bash
197198
$ BUILD_ARGS="--build-arg http_proxy=http://acme:3128 --build-arg https_proxy=http://acme:3128" make build
198199
```
199200

200-
_Note: Omitting_ `VERSION=local` _will build the images with the current version number thus overwriting the images downloaded from [Docker Hub](https://hub.docker.com/r/selenium/)._
201+
_Note: Omitting_ `VERSION=local` _will build the images with the released version but replacing the date for the
202+
current one._
201203

202204
## Using the images
203205

204-
##### Example: Spawn a container for testing in Chrome:
205-
206-
``` bash
207-
$ docker run -d --name selenium-hub -p 4444:4444 selenium/hub:4.0.0-alpha-6-20200730
208-
$ CH=$(docker run --rm --name=ch \
209-
--link selenium-hub:hub -v /e2e/uploads:/e2e/uploads \
210-
-v /dev/shm:/dev/shm \
211-
selenium/node-chrome:4.0.0-alpha-6-20200730)
212-
```
213-
214-
_Note:_ `-v /e2e/uploads:/e2e/uploads` _is optional in case you are testing browser uploads on your web app you will probably need to share a directory for this._
215-
216-
##### Example: Spawn a container for testing in Firefox:
217-
218-
This command line is the same as for Chrome. Remember that the Selenium running container is able to launch either Chrome or Firefox, the idea around having 2 separate containers, one for each browser is for convenience plus avoiding certain `:focus` issues your web app may encounter during end-to-end test automation.
206+
### Example: Spawn a container for testing in Firefox ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png):
219207

220208
``` bash
221-
$ docker run -d --name selenium-hub -p 4444:4444 selenium/hub:4.0.0-alpha-6-20200730
222-
$ FF=$(docker run --rm --name=fx \
223-
--link selenium-hub:hub -v /e2e/uploads:/e2e/uploads \
209+
$ docker network create grid
210+
$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.0.0-alpha-6-20200730
211+
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
212+
-e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
224213
-v /dev/shm:/dev/shm \
225-
selenium/node-firefox:4.0.0-alpha-6-20200730)
214+
-v /e2e/uploads:/e2e/uploads selenium/node-firefox:4.0.0-alpha-6-20200730
226215
```
227216

228-
_Note: Since a Docker container is not meant to preserve state and spawning a new one takes less than 3 seconds you will likely want to remove containers after each end-to-end test with_ `--rm` _command. You need to think of your Docker containers as single processes, not as running virtual machines, in case you are familiar with [Vagrant](https://www.vagrantup.com/)._
217+
_Note:_ `-v /e2e/uploads:/e2e/uploads` _is optional in case you are testing browser uploads on your
218+
web app you will probably need to share a directory for this._
229219

230-
##### Example: Spawn a container for testing in Opera:
220+
This command line for Opera or Chrome is the virtually the same, only remember to replace the image name for
221+
`node-opera` or `node-crhome`. Remember that the Selenium running container is able to launch either
222+
Chrome, Opera or Firefox, the idea around having 3 separate containers, one for each browser is for convenience plus
223+
avoiding certain `:focus` issues your web app may encounter during end-to-end test automation.
231224

232-
``` bash
233-
$ docker run -d --name selenium-hub -p 4444:4444 selenium/hub:4.0.0-alpha-6-20200730
234-
$ CH=$(docker run --rm --name=ch \
235-
--link selenium-hub:hub -v /e2e/uploads:/e2e/uploads \
236-
-v /dev/shm:/dev/shm \
237-
selenium/node-opera:4.0.0-alpha-6-20200730)
238-
```
225+
_Note: Since a Docker container is not meant to preserve state and spawning a new one takes less than 3 seconds you
226+
will likely want to remove containers after each end-to-end test with_ `--rm` _command. You need to think of your
227+
Docker containers as single processes, not as running virtual machines._
239228

240-
_Note:_ `-v /e2e/uploads:/e2e/uploads` _is optional in case you are testing browser uploads on your web app you will probably need to share a directory for this._
229+
___
241230

242231
## Waiting for the Grid to be ready
243232

@@ -337,6 +326,8 @@ $ ./wait-for-grid.sh mvn clean test
337326

338327
Like this, the script will poll until the Grid is ready, and then your tests will start.
339328

329+
___
330+
340331
## Debugging
341332

342333
In the event you wish to visually see what the browser is doing you will want to run the `debug` variant of node or standalone images. A VNC server will run on port 5900. You are free to map that to any free external port that you wish. Keep in mind that you will only be able to run one node per port so if you wish to include a second node, or more, you will have to use different ports, the 5900 as the internal port will have to remain the same though as thats the VNC service on the node. The second example below shows how to run multiple nodes and with different VNC ports open:
@@ -395,7 +386,9 @@ RUN x11vnc -storepasswd <your-password-here> /home/seluser/.vnc/passwd
395386

396387
If you want to run VNC without password authentication you can set the environment variable `VNC_NO_PASSWORD=1`.
397388

398-
### Troubleshooting
389+
___
390+
391+
## Troubleshooting
399392

400393
All output is sent to stdout so it can be inspected by running:
401394
``` bash
@@ -407,7 +400,7 @@ You can turn on debugging by passing environment variable to the hub and the nod
407400
GRID_DEBUG=true
408401
```
409402

410-
#### Headless
403+
### Headless
411404

412405
If you see the following selenium exceptions:
413406

0 commit comments

Comments
 (0)