@@ -7,18 +7,18 @@ and made the source code freely available under the [Apache License 2.0](LICENSE
7
7
![ Deployments] ( https://github.com/SeleniumHQ/docker-selenium/workflows/Deploys/badge.svg )
8
8
9
9
# :point_right : Status: Grid 4 is under development and on a [ Beta stage] ( https://en.wikipedia.org/wiki/Software_release_life_cycle#Beta )
10
- 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 Beta 1 , and Docker images on prerelease Beta 2 ).
10
+ Prereleases are happening on a regular basis to get early feedback. This means that all other Selenium components
11
+ can be currently at a different beta version (e.g. bindings on Beta 2 , and Docker images on prerelease Beta 3 ).
12
12
13
13
Docker images for Grid 4 come with a handful of tags to simplify its usage, have a look at them in one of
14
- our [ prereleases ] ( https://github.com/SeleniumHQ/docker-selenium/releases/tag/4.0.0-beta-3-prerelease-20210329 )
14
+ our [ releases ] ( https://github.com/SeleniumHQ/docker-selenium/releases/tag/4.0.0-beta-3-prerelease-20210329 )
15
15
16
- To get notifications of new prereleases, add yourself as a watcher of "Releases only".
16
+ To get notifications of new prereleases, add yourself as a "Releases only" watcher .
17
17
18
- Doubts or questions? Please get in touch through the different communication channels available in the ** Community** section.
18
+ Doubts? Questions? Get in touch through the different communication channels available in the ** Community** section.
19
19
20
20
Looking for Grid 3? Head to the [ Selenium 3 branch] ( https://github.com/SeleniumHQ/docker-selenium/tree/selenium-3 ) . This branch
21
- will be having new browser releases until Grid 4 has its major release.
21
+ will be having new browser releases until Grid 4 has had its major release.
22
22
23
23
## Community
24
24
@@ -31,32 +31,30 @@ https://www.selenium.dev/support/
31
31
1 . Start a Docker container with Firefox
32
32
33
33
``` bash
34
- $ docker run -d -p 4444:4444 --shm-size 2g selenium/standalone-firefox:4.0.0-beta-3-prerelease-20210329
34
+ $ docker run -d -p 4444:4444 -p 7900:7900 - -shm-size 2g selenium/standalone-firefox:4.0.0-beta-3-prerelease-20210329
35
35
# OR
36
- $ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-beta-3-prerelease-20210329
36
+ $ docker run -d -p 4444:4444 -p 7900:7900 - v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-beta-3-prerelease-20210329
37
37
```
38
38
39
39
2 . Point your WebDriver tests to http://localhost:4444/wd/hub
40
40
41
41
3 . That's it!
42
42
43
- To inspect visually the browser activity, see the [ Debugging] ( #debugging ) section for details.
43
+ 4 . (Optional) To see what is happening inside the container, head to http://localhost:7900 (password is ` secret ` ).
44
+
45
+ More details about visualising the container activity, check the [ Debugging] ( #debugging ) section.
44
46
45
47
:point_up : When executing ` docker run ` for an image that contains a browser please either mount
46
48
` -v /dev/shm:/dev/shm ` or use the flag ` --shm-size=2g ` to use the host's shared memory.
47
49
48
- > Why is ` -v /dev/shm:/dev/shm ` or ` --shm-size 2g ` necessary?
49
- > This is a known workaround to avoid the browser crashing inside a docker container, here are the documented issues for
50
- [ Chrome] ( https://code.google.com/p/chromium/issues/detail?id=519952 ) and [ Firefox] ( https://bugzilla.mozilla.org/show_bug.cgi?id=1338771#c10 ) .
51
- The shm size of 2gb is arbitrary but known to work well, your specific use case might need a different value, it is recommended
52
- 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.
53
-
54
50
:point_up : Always use a Docker image with a full tag to pin a specific browser and Grid version.
55
51
See [ Tagging Conventions] ( https://github.com/SeleniumHQ/docker-selenium/wiki/Tagging-Convention ) for details.
56
52
57
53
___
58
54
59
- ## Standalone
55
+ ## Execution modes
56
+
57
+ ### Standalone
60
58
61
59
![ Firefox] ( https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png ) Firefox
62
60
``` bash
@@ -82,11 +80,11 @@ _Note: Only one Standalone container can run on port_ `4444` _at the same time._
82
80
83
81
___
84
82
85
- ## Selenium Grid Hub and Nodes
83
+ ### Hub and Nodes
86
84
87
85
There are different ways to run the images and create a Grid with a Hub and Nodes, check the following options.
88
86
89
- ### Docker networking
87
+ #### Docker networking
90
88
The Hub and Nodes will be created in the same network and they will recognize each other by their container name.
91
89
A Docker [ network] ( https://docs.docker.com/engine/reference/commandline/network_create/ ) needs to be created as a first step.
92
90
@@ -122,7 +120,7 @@ When you are done using the Grid, and the containers have exited, the network ca
122
120
$ docker network rm grid
123
121
```
124
122
125
- ### Using different machines/VMs
123
+ #### Using different machines/VMs
126
124
The Hub and Nodes will be created on different machines/VMs, they need to know each other's IPs to
127
125
communicate properly.
128
126
@@ -175,26 +173,26 @@ $ docker run -d -p 5555:5555
175
173
selenium/node-opera:4.0.0-beta-3-prerelease-20210329
176
174
```
177
175
178
- ### Docker Compose
176
+ #### Docker Compose
179
177
[ Docker Compose] ( https://docs.docker.com/compose/ ) is the simplest way to start a Grid. Use the
180
178
linked resources below, save them locally, and check the execution instructions on top of each file.
181
179
182
- #### Version 2
180
+ ##### Version 2
183
181
[ ` docker-compose-v2.yml ` ] ( docker-compose-v2.yml )
184
182
185
- #### Version 3
183
+ ##### Version 3
186
184
[ ` docker-compose-v3.yml ` ] ( docker-compose-v3.yml )
187
185
188
186
To stop the Grid and cleanup the created containers, run ` docker-compose down ` .
189
187
190
- #### Version 3 with Swarm support
188
+ ##### Version 3 with Swarm support
191
189
[ ` docker-compose-v3-swarm.yml ` ] ( docker-compose-v3-swarm.yml )
192
190
193
191
___
194
192
195
- ## Selenium Grid - Router, Distributor, EventBus, SessionMap and Nodes
193
+ ### Fully distributed mode - Router, Queue , Distributor, EventBus, SessionMap and Nodes
196
194
197
- It is possible to start a Selenium Grid with its five components apart. For simplicity, only an
195
+ It is possible to start a Selenium Grid with all its components apart. For simplicity, only an
198
196
example with docker-compose will be provided. Save the file locally, and check the execution
199
197
instructions on top of it.
200
198
204
202
205
203
## Video recording ![ BETA] ( https://img.shields.io/badge/beta!-blue?style=for-the-badge )
206
204
207
- It is possible to record your tests running in containers by using the ` selenium/video:ffmpeg-4.3.1-20210329 `
205
+ Tests execution can be recorded by using the ` selenium/video:ffmpeg-4.3.1-20210329 `
208
206
Docker image. One container is needed per each container where a browser is running. This means if you are
209
207
running 5 Nodes/Standalone containers, you will need 5 video containers, the mapping is 1-1.
210
208
@@ -422,8 +420,8 @@ Grid has a default session timeout of 300 seconds, where the session can be on a
422
420
### Running in Headless mode
423
421
424
422
[ Firefox] ( https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode ) ,
425
- [ Chrome] ( https://developers.google.com/web/updates/2017/04/headless-chrome ) and
426
- [ Opera] ( https://forums.opera.com/topic/20375/opera-cli-switches-and-headless ) support running tests in the headless mode.
423
+ [ Chrome] ( https://developers.google.com/web/updates/2017/04/headless-chrome ) ,
424
+ [ Opera] ( https://forums.opera.com/topic/20375/opera-cli-switches-and-headless ) and Edge support running tests in the headless mode.
427
425
When using headless mode, there's no need for the [ Xvfb] ( https://en.wikipedia.org/wiki/Xvfb ) server to be started.
428
426
429
427
To avoid starting the server you can set the ` START_XVFB ` environment variable to ` false `
@@ -455,31 +453,6 @@ $ BUILD_ARGS="--build-arg http_proxy=http://acme:3128 --build-arg https_proxy=ht
455
453
_ Note: Omitting_ ` VERSION=local ` _ will build the images with the released version but replacing the date for the
456
454
current one._
457
455
458
- ## Using the images
459
-
460
- ### Example: Spawn a container for testing in Firefox ![ Firefox] ( https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png )
461
-
462
- ``` bash
463
- $ docker network create grid
464
- $ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.0.0-beta-3-prerelease-20210329
465
- $ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
466
- -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
467
- -v /dev/shm:/dev/shm \
468
- -v /e2e/uploads:/e2e/uploads selenium/node-firefox:4.0.0-beta-3-prerelease-20210329
469
- ```
470
-
471
- _ Note:_ ` -v /e2e/uploads:/e2e/uploads ` _ is optional in case you are testing browser uploads on your
472
- web app you will probably need to share a directory for this._
473
-
474
- This command line for Opera or Chrome is almost the same, only remember to replace the image name for
475
- ` node-opera ` or ` node-chrome ` . Remember that the Selenium running container is able to launch either
476
- Chrome, Opera or Firefox, the idea around having 3 separate containers, one for each browser is for convenience plus
477
- avoiding certain ` :focus ` issues your web app may encounter during end-to-end test automation.
478
-
479
- _ Note: Since a Docker container should not preserve state and spawning a new one takes less than 3 seconds you
480
- will likely want to remove containers after each end-to-end test with_ ` --rm ` _ command. You need to think of your
481
- Docker containers as single processes, not as running virtual machines._
482
-
483
456
___
484
457
485
458
## Waiting for the Grid to be ready
@@ -603,37 +576,34 @@ ___
603
576
604
577
## Debugging
605
578
606
- In the event you wish to see what the browser is doing, you can check what is going inside by connecting to the VNC
607
- server running on port 5900 inside the browser container.
579
+ This project uses [ x11vnc] ( https://github.com/LibVNC/x11vnc ) as VNC server to allow users inspect what is happening
580
+ inside the container. Users can connect to this server in two ways:
581
+
582
+ ### Using a VNC client
608
583
609
- You are free to map that port to any free external port that you wish. Keep in mind that you will only be able to run
610
- one node per port. If you wish to include a second node (or more), you will have to use different ports .
584
+ The VNC server is listening to port 5900, you can use a VNC client and connect to it. Feel free to map port 5900 to
585
+ any free external port that you wish.
611
586
612
- The internal 5900 port will need to remain the same because that is the configured port for the VNC server
613
- running inside the container.
587
+ The internal 5900 port remains the same because that is the configured port for the VNC server running inside the container.
614
588
615
589
Here is an example with the standalone images, the same concept applies to the node images.
616
590
``` bash
617
591
$ docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-beta-3-prerelease-20210329
618
- $ docker run -d -p 4444:4444 -p 5900 :5900 -v /dev/shm:/dev/shm selenium/standalone-edge:4.0.0-beta-3-prerelease-20210329
619
- $ docker run -d -p 4445:4444 -p 5901 :5900 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-beta-3-prerelease-20210329
620
- $ docker run -d -p 4446:4444 -p 5902 :5900 -v /dev/shm:/dev/shm selenium/standalone-opera:4.0.0-beta-3-prerelease-20210329
592
+ $ docker run -d -p 4444:4444 -p 5901 :5900 -v /dev/shm:/dev/shm selenium/standalone-edge:4.0.0-beta-3-prerelease-20210329
593
+ $ docker run -d -p 4445:4444 -p 5902 :5900 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-beta-3-prerelease-20210329
594
+ $ docker run -d -p 4446:4444 -p 5903 :5900 -v /dev/shm:/dev/shm selenium/standalone-opera:4.0.0-beta-3-prerelease-20210329
621
595
```
622
596
623
597
Then, you would use in your VNC client:
624
598
- Port 5900 to connect to the Chrome container
625
- - Port 5901 to connect to the Firefox container
626
- - Port 5902 to connect to the Opera container
599
+ - Port 5901 to connect to the Edge container
600
+ - Port 5902 to connect to the Firefox container
601
+ - Port 5903 to connect to the Opera container
627
602
628
- In case you have [ RealVNC] ( https://www.realvnc.com/ ) binary ` vnc ` in your path, you can always take a look, select view
629
- only to avoid messing around your tests with an unintended mouse click or keyboard interrupt:
630
- ``` bash
631
- $ ./bin/vncview 127.0.0.1:5900
632
- ```
633
-
634
- When you are prompted for the password it is ` secret ` . If you wish to change this then you should either change
603
+ If you get a prompt asking for a password, it is: ` secret ` . If you wish to change this, you should either change
635
604
it in the ` /NodeBase/Dockerfile ` and build the images yourself, or you can define a Docker image that derives from
636
605
the posted ones which reconfigures it:
606
+
637
607
``` dockerfile
638
608
# FROM selenium/node-chrome:4.0.0-beta-3-prerelease-20210329
639
609
# FROM selenium/node-edge:4.0.0-beta-3-prerelease-20210329
@@ -646,6 +616,30 @@ RUN x11vnc -storepasswd <your-password-here> /home/seluser/.vnc/passwd
646
616
647
617
If you want to run VNC without password authentication you can set the environment variable ` VNC_NO_PASSWORD=1 ` .
648
618
619
+ ### Using your browser (no VNC client is needed)
620
+
621
+ This project uses [ noVNC] ( https://github.com/novnc/noVNC ) to allow users inspect visually container activity with
622
+ their browser. This might come handy if you cannot install a VNC client on your machine. Port 7900 is used to start
623
+ noVNC, so you will need to connect to that port with your browser.
624
+
625
+ Similarly to the previous section, feel free to map port 5900 to any free external port that you wish.
626
+
627
+ Here is an example with the standalone images, the same concept applies to the node images.
628
+ ``` bash
629
+ $ docker run -d -p 4444:4444 -p 7900:7900 -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-beta-3-prerelease-20210329
630
+ $ docker run -d -p 4444:4444 -p 7901:7900 -v /dev/shm:/dev/shm selenium/standalone-edge:4.0.0-beta-3-prerelease-20210329
631
+ $ docker run -d -p 4445:4444 -p 7902:7900 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-beta-3-prerelease-20210329
632
+ $ docker run -d -p 4446:4444 -p 7903:7900 -v /dev/shm:/dev/shm selenium/standalone-opera:4.0.0-beta-3-prerelease-20210329
633
+ ```
634
+
635
+ Then, you would use in your browser:
636
+ - http://localhost:7900/ to connect to the Chrome container
637
+ - http://localhost:7901/ to connect to the Edge container
638
+ - http://localhost:7902/ to connect to the Firefox container
639
+ - http://localhost:7903/ to the Opera container
640
+
641
+ If you get a prompt asking for a password, it is: ` secret ` .
642
+
649
643
___
650
644
651
645
## Troubleshooting
@@ -655,11 +649,20 @@ All output gets sent to stdout, so it can be inspected by running:
655
649
$ docker logs -f < container-id| container-name>
656
650
```
657
651
658
- You can turn on debugging by passing environment variable to the hub and the nodes containers:
652
+ You can increase the log output by passing environment variable to the containers:
659
653
```
660
- GRID_DEBUG=true
654
+ SE_OPTS="--log-level FINE"
661
655
```
662
656
657
+ ### ` -v /dev/shm:/dev/shm ` or ` --shm-size 2g `
658
+
659
+ Why is ` -v /dev/shm:/dev/shm ` or ` --shm-size 2g ` necessary?
660
+ > This is a known workaround to avoid the browser crashing inside a docker container, here are the documented issues for
661
+ [ Chrome] ( https://code.google.com/p/chromium/issues/detail?id=519952 ) and [ Firefox] ( https://bugzilla.mozilla.org/show_bug.cgi?id=1338771#c10 ) .
662
+ The shm size of 2gb is arbitrary but known to work well, your specific use case might need a different value, it is recommended
663
+ 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.
664
+
665
+
663
666
### Headless
664
667
665
668
If you see the following selenium exceptions:
0 commit comments