Skip to content

Commit f030b76

Browse files
authored
Enabling video recording, time zone & screen resolution settings in dynamic grid (#1140)
* Creating assets path to use when copying logs or session caps * Updating README
1 parent b34a162 commit f030b76

File tree

2 files changed

+74
-47
lines changed

2 files changed

+74
-47
lines changed

Base/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ COPY supervisord.conf /etc
6868
#==========
6969
# Selenium & relaxing permissions for OpenShift and other non-sudo environments
7070
#==========
71-
RUN mkdir -p /opt/selenium /var/run/supervisor /var/log/supervisor \
71+
RUN mkdir -p /opt/selenium /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
7272
&& touch /opt/selenium/config.toml \
73-
&& chmod -R 777 /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd \
74-
&& wget --no-verbose https://github.com/SeleniumHQ/docker-selenium/raw/alpha-jars/selenium-server-4.0.0-alpha-7-4a3bb6d550.jar \
73+
&& chmod -R 777 /opt/selenium /opt/selenium/assets /var/run/supervisor /var/log/supervisor /etc/passwd \
74+
&& wget --no-verbose https://github.com/SeleniumHQ/docker-selenium/raw/alpha-jars/selenium-server-4.0.0-alpha-7-f89bec1f87.jar \
7575
-O /opt/selenium/selenium-server.jar \
7676
# && wget --no-verbose https://selenium-release.storage.googleapis.com/4.0-alpha-6/selenium-server-4.0.0-alpha-6.jar \
7777
# -O /opt/selenium/selenium-server.jar \
78-
&& chgrp -R 0 /opt/selenium ${HOME} /var/run/supervisor /var/log/supervisor \
79-
&& chmod -R g=u /opt/selenium ${HOME} /var/run/supervisor /var/log/supervisor
78+
&& chgrp -R 0 /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
79+
&& chmod -R g=u /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor
8080

8181
#===================================================
8282
# Run the following commands as non-privileged user

README.md

Lines changed: 69 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and made the source code freely available under the [Apache License 2.0](LICENSE
88

99
# :point_right: Status: Grid 4 is under development and on a [Alpha stage](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha)
1010
We are doing prereleases on a regular basis to get early feedback. This means that all other Selenium components
11-
can be currently at a different alpha version (e.g. bindings on Alpha 6, and these Docker images on prerelease Alpha 7).
11+
can be currently at a different alpha version (e.g. bindings on Alpha 7, and Docker images on prerelease Beta 1).
1212

1313
Docker images for Grid 4 come with a handful of tags to simplify its usage, have a look at them in one of
1414
our [prereleases](https://github.com/SeleniumHQ/docker-selenium/releases/tag/4.0.0-alpha-7-prerelease-20201009)
@@ -51,7 +51,7 @@ To inspect visually the browser activity, see the [Debugging](#debugging) sectio
5151
The shm size of 2gb is arbitrary but known to work well, your specific use case might need a different value, it is recommended
5252
to tune this value according to your needs. Along the examples `-v /dev/shm:/dev/shm` will be used, but both are known to work.
5353

54-
:point_up: Always use a tag with an element suffix to pin a specific browser version.
54+
:point_up: Always use a Docker image with a full tag to pin a specific browser and Grid version.
5555
See [Tagging Conventions](https://github.com/SeleniumHQ/docker-selenium/wiki/Tagging-Convention) for details.
5656

5757
___
@@ -123,7 +123,6 @@ linked resources below, save them locally, and check the execution instructions
123123
To stop the Grid and cleanup the created containers, run `docker-compose down`.
124124

125125
#### Version 3 with Swarm support
126-
127126
[`docker-compose-v3-swarm.yml`](docker-compose-v3-swarm.yml)
128127

129128
___
@@ -138,6 +137,48 @@ instructions on top of it.
138137

139138
___
140139

140+
## Video recording ![BETA](https://img.shields.io/badge/beta!-blue?style=for-the-badge)
141+
142+
It is possible to record your tests running in containers by using the `selenium/video:ffmpeg-4.3.1-20201009`
143+
Docker image. One container is needed per each container where a browser is running. This means if you are
144+
running 5 Nodes/Standalone containers, you will need 5 video containers, the mapping is 1-1.
145+
146+
Currently, the only way to do this mapping is manually (either starting the containers manually, or through
147+
`docker-compose`). We are iterating on this process and probably this setup will be more simple in the future.
148+
149+
The video Docker image we provide is based on the ffmpeg Ubuntu image provided by the
150+
[jrottenberg/ffmpeg](https://github.com/jrottenberg/ffmpeg) project, thank you for providing this image and
151+
simplifying our work :tada:
152+
153+
**Notes**:
154+
- If you have questions or feedback, please use the community contact points shown [here](https://www.selenium.dev/support/).
155+
- Please report any bugs through GitHub [issues](https://github.com/SeleniumHQ/docker-selenium/issues/new/choose), and provide
156+
all the information requested on the template.
157+
- Video recording for headless browsers is not supported.
158+
- Video recording tends to use considerable amounts of CPU. Normally you should estimate 1CPU per video container,
159+
and 1 CPU per browser container.
160+
- Videos are stored in the `/videos` directory inside the video container. Map a local directory to get the videos.
161+
- If you are running more than one video container, be sure to overwrite the video file name through the `FILE_NAME`
162+
environment variable to avoid unexpected results.
163+
164+
This example shows how to start the containers manually:
165+
166+
``` bash
167+
$ docker network create grid
168+
$ docker run -d -p 4444:4444 -p 6900:5900 --net grid --name selenium -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-alpha-7-prerelease-20201009
169+
$ docker run -d --net grid --name video -v /tmp/videos:/videos selenium/video:ffmpeg-4.3.1-20201009
170+
# Run your tests
171+
$ docker stop video && docker rm video
172+
$ docker stop selenium && docker rm selenium
173+
```
174+
After the containers are stopped and removed, you should see a video file on your machine's `/tmp/videos` directory.
175+
176+
Here is an example using a Hub and 3 Nodes (Chrome, Firefox, and Opera):
177+
178+
[`docker-compose-v3-video.yml`](docker-compose-v3-video.yml)
179+
180+
___
181+
141182
## Dynamic Grid ![BETA](https://img.shields.io/badge/beta!-blue?style=for-the-badge)
142183

143184
Grid 4 has the ability to start Docker containers on demand, this means that it starts
@@ -167,6 +208,14 @@ configs = [
167208
# To have Docker listening through tcp on macOS, install socat and run the following command
168209
# socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock
169210
host = "tcp://host.docker.internal:2375"
211+
# Docker imagee used for video recording
212+
video-image = "selenium/video:ffmpeg-4.3.1-20201009"
213+
# Absolute path where test assets will be stored (this path must exist on the host)
214+
assets-path = "/assets/path/on/your/host/machine"
215+
# Absolute path where test assets will be stored inside the container
216+
# "/opt/selenium/assets" already exists inside the containers
217+
# If you want to use another one, be sure it exists.
218+
container-assets-path = "/opt/selenium/assets"
170219
```
171220

172221
### Execution with Hub & Node roles
@@ -182,6 +231,7 @@ $ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
182231
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
183232
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
184233
-v ${PWD}/config.toml:/opt/bin/config.toml \
234+
-v /path/on/your/host/machine:/opt/selenium/assets \
185235
selenium/node-docker:4.0.0-alpha-7-prerelease-20201009
186236
```
187237

@@ -197,51 +247,28 @@ $ docker network rm grid
197247
```bash
198248
docker run --rm -ti --name selenium-docker -p 4444:4444 \
199249
-v ${PWD}/config.toml:/opt/bin/config.toml \
250+
-v /path/on/your/host/machine:/opt/selenium/assets \
200251
selenium/standalone-docker:4.0.0-alpha-7-prerelease-20201009
201252
```
202253

203-
___
204-
205-
## Video recording ![BETA](https://img.shields.io/badge/beta!-blue?style=for-the-badge)
206-
207-
It is possible to record your tests running in containers by using the `selenium/video:ffmpeg-4.3.1-20201009`
208-
Docker image. One container is needed per each container where a browser is running. This means if you are
209-
running 5 Nodes/Standalone containers, you will need 5 video containers, the mapping is 1-1.
210-
211-
Currently, the only way to do this mapping is manually (either starting the containers manually, or through
212-
`docker-compose`). We are iterating on this process and probably this setup will be more simple in the future.
213-
214-
The video Docker image we provide is based on the ffmpeg Ubuntu image provided by the
215-
[jrottenberg/ffmpeg](https://github.com/jrottenberg/ffmpeg) project, thank you for providing this image and
216-
simplifying our work :tada:
254+
### Video recording, screen resolution, and time zones in a Dynamic Grid
255+
To record your WebDriver session, you need to add a `se:options` section to
256+
your capabilities and inside it, configure the desired settings, for example:
217257

218-
**Notes**:
219-
- If you have questions or feedback, please use the community contact points shown [here](https://www.selenium.dev/support/).
220-
- Please report any bugs through GitHub [issues](https://github.com/SeleniumHQ/docker-selenium/issues/new/choose), and provide
221-
all the information requested on the template.
222-
- Video recording for headless browsers is not supported.
223-
- Video recording tends to use considerable amounts of CPU. Normally you should estimate 1CPU per video container,
224-
and 1 CPU per browser container.
225-
- Videos are stored in the `/videos` directory inside the video container. Map a local directory to get the videos.
226-
- If you are running more than one video container, be sure to overwrite the video file name through the `FILE_NAME`
227-
environment variable to avoid unexpected results.
228-
229-
This example shows how to start the containers manually:
230-
231-
``` bash
232-
$ docker network create grid
233-
$ docker run -d -p 4444:4444 -p 6900:5900 --net grid --name selenium -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-alpha-7-prerelease-20201009
234-
$ docker run -d --net grid --name video -v /tmp/videos:/videos selenium/video:ffmpeg-4.3.1-20201009
235-
# Run your tests
236-
$ docker stop video && docker rm video
237-
$ docker stop selenium && docker rm selenium
258+
```json
259+
{
260+
"browserName": "firefox",
261+
"platformName": "linux",
262+
"se:options": {
263+
"recordVideo": "true",
264+
"timeZone": "US/Pacific",
265+
"screenResolution": "1920x1080"
266+
}
267+
}
238268
```
239-
After the containers are stopped and removed, you should see a video file on your machine's `/tmp/videos` directory.
240-
241-
Here is an example using a Hub and 3 Nodes (Chrome, Firefox, and Opera):
242-
243-
[`docker-compose-v3-video.yml`](docker-compose-v3-video.yml)
244269

270+
After running a test, check the path you mounted to the Docker container,
271+
(`/path/on/your/host/machine`), and you should see videos and session information.
245272
___
246273

247274
## Deploying to Kubernetes

0 commit comments

Comments
 (0)