You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 30, 2021. It is now read-only.
* Suggesting changes to the README file
* Fixing formatting and updating version
- Fixing formatting issues when using the enumeration
- Updating the version used in the documentation to 2.53.0g
* Formatting code segments to make list work
Following tip shown here: benweet/stackedit#64
to make the numbered list work when in between the items there are code blocks.
Copy file name to clipboardExpand all lines: README.md
+59-43Lines changed: 59 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,18 +21,23 @@ Note SeleniumHQ/docker-selenium project is more useful for building selenium gri
21
21
22
22
### Run
23
23
24
-
In general add `sudo` only if needed in your environment and `--privileged` or `-v /dev/shm:/dev/shm` if you really need it like when [Chrome crashes](https://github.com/elgalu/docker-selenium/issues/20) during your high gpu intensive tests.
24
+
1. Pull the image and run the container
25
25
26
-
docker pull elgalu/selenium:2.53.0g
26
+
docker pull elgalu/selenium:2.53.0g
27
27
28
-
docker run --rm -ti --name=grid -p 4444:24444 -p 5920:25900 \
Make sure `docker run` finishes via active wait with below command. This is **mandatory**before start running your tests! Note `grid` is the name of the container:
31
+
2. Wait until the grid starts properly before starting the tests_(Optional but recommended)_
32
32
33
-
docker exec grid wait_all_done 30s
33
+
docker exec grid wait_all_done 30s
34
34
35
-
Selenium should be up and running at http://localhost:4444/wd/hub open the web page to confirm is running but if you are using Mac (OSX) `localhost` won't work! find out the correct IP through `boot2docker ip` or `docker-machine ip default`.
35
+
After this, Selenium should be up and running at `http://localhost:4444/wd/hub`. Open the url in your browser to confirm it is running.
36
+
If you are using Mac (OSX) `localhost` won't work! Find out the correct IP through `boot2docker ip` or `docker-machine ip default`.
37
+
38
+
**Notes:**
39
+
* Add `sudo` only if needed in your environment
40
+
* Add `--privileged` or `-v /dev/shm:/dev/shm` if you really need it. For example when [Chrome crashes](https://github.com/elgalu/docker-selenium/issues/20) during your high gpu intensive tests.
36
41
37
42
#### Stop
38
43
Shutdown gracefully
@@ -41,11 +46,11 @@ Shutdown gracefully
41
46
docker stop grid
42
47
43
48
### OSX
44
-
Important, in Mac you need to gather the correct IP as localhost won't work unless you are in the Linux docker host machine:
49
+
If you are in Mac, you need to get the correct IP of the docker machine. One of these two commands should work to get it:
@@ -98,20 +103,24 @@ You can set a custom screen size at docker run time by providing `SCREEN_WIDTH`
98
103
99
104
### Chrome flavor
100
105
101
-
This feature was available in previous versions, please go [check here][[2.47.1m]] and:
102
-
To configure which Chrome flavor (stable, beta, unstable) you want to use just pass for example `-e CHROME_FLAVOR=beta` to `docker run`. Default is `stable`.
106
+
This feature was available in previous versions, please go to [2.47.1m] to use it.
107
+
108
+
To configure which Chrome flavor you want to use (stable, beta, unstable), just pass `-e CHROME_FLAVOR=beta` to `docker run`. Default is `stable`.
103
109
104
110
### Firefox version
105
111
106
-
This feature was available in previous versions, please go [check here][[2.47.1m]] and:
107
-
To configure which Firefox version to use first check available versions in the [CHANGELOG](./CHANGELOG.md) then pass for example`-e FIREFOX_VERSION=38.0.6` to `docker run`. Default is the latest number of the available list.
112
+
This feature was available in previous versions, please go to [2.47.1m] to use it.
113
+
To configure which Firefox version to use, first check available versions in the [CHANGELOG](./CHANGELOG.md). Then pass `-e FIREFOX_VERSION=38.0.6` to `docker run`. Default is the latest number of the available list.
108
114
109
115
### Record Videos
110
116
Step by step guide at [docs/videos.md](./docs/videos.md)
111
117
112
-
If you create the container with `-e VIDEO=true` it will start recording a video through the vnc connection run upon start but first create a local folder `videos` in your current directory and mount the videos directory for an easy transfer with `-v $(pwd)/videos:/videos`
118
+
If you create the container with `-e VIDEO=true` it will start recording a video through the vnc connection run upon start.
119
+
It is recommended to create first a local folder `videos` in your current directory, and mount the videos directory for
120
+
an easy transfer with `-v $(pwd)/videos:/videos`.
113
121
114
-
Once your tests are done you can either manually stop the recording via `docker exec grid /bin-utils/stop-video` where *ch* is just the arbitrary container chosen name in `docker run` command. Or simply stop the container and that will stop the video recording automatically.
122
+
Once your tests are done you can either manually stop the recording via `docker exec grid /bin-utils/stop-video` where
123
+
*grid* is just the arbitrary container chosen name in `docker run` command. Or simply stop the container and that will stop the video recording automatically.
115
124
116
125
Relevant environment variables to customize it are:
117
126
@@ -120,11 +129,11 @@ Relevant environment variables to customize it are:
120
129
VIDEO_FILE_EXTENSION=mkv
121
130
FFMPEG_CODEC_ARGS=""
122
131
123
-
It is important to note that `ffmpeg` video recording takes an important amount of CPU usage, even more when a well compressed format like *mkv* is selected. You may want to delegate video recording through `vnc2swf-start.sh` to a separate server process and even delegate compression to a further step or to a cloud service like Youtube.
132
+
It is important to note that `ffmpeg` video recording takes an important amount of CPU usage, even more when a well compressed format like *mkv* is selected. You may want to delegate video recording through `vnc2swf-start.sh` to a separate server process and even delegate compression to a further step or to a cloud service like YouTube.
124
133
125
134
### VNC
126
135
127
-
When you don't specify a VNC password a random one will be generated. That password can be seeing by grepping the logs:
136
+
When you don't specify a VNC password, a random one will be generated. That password can be seeing by grepping the logs:
128
137
129
138
docker exec grid wait_all_done 30s
130
139
#=> ... a VNC password was generated for you: ooGhai0aesaesh
@@ -135,11 +144,11 @@ You can connect to see what's happening
135
144
136
145
### noVNC
137
146
138
-
Disabled by default, [noVNC](https://github.com/kanaka/noVNC) provides a browser VNC client so you don't need to install a vnc viewer if you choose so. Note we were using guacamole before.
147
+
Disabled by default, [noVNC](https://github.com/kanaka/noVNC) provides a browser VNC client so you don't need to install a vnc viewer if you choose so. *Note:* we were using guacamole before.
139
148
140
149
Safari Browser already comes with a built-in vnc viewer so this feature is overkill and is disabled by default, just navigate to vnc://localhost:5920 in your Safari browser.
141
150
142
-
You need to pass the environment variable `-e NOVNC=true` in order to start the noVNC service and will be able to open a browser at [localhost:6080](http://localhost:6080/vnc.html)
151
+
You need to pass the environment variable `-e NOVNC=true` in order to start the noVNC service and you will be able to open a browser at [localhost:6080](http://localhost:6080/vnc.html)
143
152
144
153
docker run --rm -ti --name=grid -p 4444:24444 -p 5920:25900 \
In CentOS and apparently since docker 1.10.0 is necessary to disable [sandbox mode](http://www.chromium.org/developers/design-documents/sandbox) through [--no-sandbox](http://peter.sh/experiments/chromium-command-line-switches/#no-sandbox) example client implementation.
171
182
172
183
The error comes along with this message while starting Chrome:
173
184
174
185
> Failed to move to new namespace: PID namespaces supported. Network namespace supported, but failed: errno = Operation not permitted
175
186
176
-
### No Sandbox
187
+
####No Sandbox
177
188
178
189
ChromeOptions options = new ChromeOptions();
179
190
options.addArguments("--no-sandbox");
@@ -191,7 +202,7 @@ However this is now the default of this image, see `CHROME_ARGS="--no-sandbox"`
191
202
192
203
## Security
193
204
194
-
Do **NOT** expose your selenium grid to the outside world, e.g. in AWS as selenium doesn't provide auth so if the ports are not firewalled malicious users will use [your selenium grid as a bot net](https://github.com/SeleniumHQ/docker-selenium/issues/147).
205
+
Do **NOT** expose your selenium grid to the outside world (e.g. in AWS), because Selenium does not provide auth. Therefore, if the ports are not firewalled malicious users will use [your selenium grid as a bot net](https://github.com/SeleniumHQ/docker-selenium/issues/147).
195
206
196
207
Put that firewall stuff aside, a file [scm-source.json](./scm-source.json) is included at the root directory of the generated image with information that helps to comply with auditing requirements to trace the creation of this docker image.
197
208
@@ -230,14 +241,19 @@ Given docker.io currently allows to push the same tag image twice this represent
230
241
231
242
You can find all digests sha256 and image ids per tag in the [CHANGELOG](./CHANGELOG.md) so as of now you just need to trust the sha256 in the CHANGELOG. Bullet proof is to fork this project and build the images yourself if security is a big concern.
232
243
244
+
## Cloud Testing Platforms
245
+
233
246
### Sauce Labs
234
247
To open the Sauce Labs tunnel while starting the docker container pass in the arguments `-e SAUCE_TUNNEL=true -e SAUCE_USER_NAME=leo -e SAUCE_API_KEY=secret` that will also require the tunnel to open successfully, else the container will exit so you can be sure your tunnel is up and running before starting to test.
235
248
236
249
### BrowserStack
237
250
To open the BrowserStack tunnel while starting the docker container pass in the arguments `-e BSTACK_TUNNEL=true -e BSTACK_ACCESS_KEY=secret` that will also require the tunnel to open successfully, else the container will exit so you can be sure your tunnel is up and running before starting to test.
238
251
252
+
## Additional Uses
253
+
239
254
### Using Xephyr to redirect X to the docker host
240
255
Note the below method gives full access to the docker container to the host machine.
256
+
241
257
Host machine, terminal 1:
242
258
243
259
sudo apt-get install xserver-xephyr
@@ -344,9 +360,9 @@ docker stop ${CONTAINER}
344
360
docker rm ${CONTAINER}
345
361
```
346
362
347
-
### Step by step build
363
+
## Step by step build
348
364
349
-
#### 1. Build this image
365
+
### 1. Build this image
350
366
351
367
If you git clone this repo locally, i.e. cd into where the Dockerfile is, you can:
352
368
@@ -356,20 +372,20 @@ If you prefer to download the final built image from docker you can pull it, per
356
372
357
373
docker pull elgalu/selenium:2.53.0g
358
374
359
-
#### 2. Use this image
375
+
### 2. Use this image
360
376
361
-
##### e.g. Spawn a container for Chrome testing:
377
+
#### e.g. Spawn a container for Chrome testing:
362
378
363
-
CH=$(docker run --rm --name=ch -p=127.0.0.1::24444 -p=127.0.0.1::25900 \
379
+
CH=$(docker run --rm --name=CH -p=127.0.0.1::24444 -p=127.0.0.1::25900 \
Note `-v /e2e/uploads:/e2e/uploads` is optional incase you are testing browser uploads on your webapp you'll probably need to share a directory for this.
382
+
*Note:*`-v /e2e/uploads:/e2e/uploads` is optional incase you are testing browser uploads on your WebApp, you'll probably need to share a directory for this.
367
383
368
384
The `127.0.0.1::` part is to avoid binding to all network interfaces, most of the time you don't need to expose the docker container like that so just *localhost*for now.
369
385
370
-
I like to remove the containers after each e2e test with `--rm` since this docker container is not meant to preserve state, spawning a new one is less than 3 seconds. You need to think of your docker container as processes, not as running virtual machines ifcase you are familiar with vagrant.
386
+
I like to remove the containers after each e2e test with `--rm` since this docker container is not meant to preserve state, spawning a new one is less than 3 seconds. You need to think of your docker container as processes, not as running virtual machines in case you are familiar with vagrant.
371
387
372
-
A dynamic port will be binded to the container ones, i.e.
388
+
A dynamic port will be bound to the container ones, i.e.
373
389
374
390
# Obtain the selenium port you'll connect to:
375
391
docker port $CH 4444
@@ -383,19 +399,19 @@ In case you have RealVNC binary `vnc` in your path, you can always take a look,
383
399
384
400
./bin/vncview.sh 127.0.0.1:49160
385
401
386
-
##### e.g. Spawn a container for Firefox testing:
402
+
#### e.g. Spawn a container for Firefox testing:
387
403
388
-
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 avoid certain `:focus` issues you web app may encounter during e2e automation.
404
+
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 avoid certain `:focus` issues your WebApp may encounter during e2e automation.
389
405
390
406
FF=$(docker run --rm --name=ff -p=127.0.0.1::24444 -p=127.0.0.1::25900 \
0 commit comments