Skip to content

Commit fb77532

Browse files
authored
Adding browser version in browser images (SeleniumHQ#1298)
1 parent c7b0dc1 commit fb77532

20 files changed

+128
-101
lines changed

.gitignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ assets
1414
# Ignoring generated files during the build process
1515
StandaloneC*/selenium.conf
1616
StandaloneF*/selenium.conf
17-
StandaloneO*/selenium.conf
17+
StandaloneE*/selenium.conf
1818
StandaloneC*/start-*.sh
1919
StandaloneF*/start-*.sh
20-
StandaloneO*/start-*.sh
20+
StandaloneE*/start-*.sh
21+
StandaloneC*/generate_config
22+
StandaloneF*/generate_config
23+
StandaloneE*/generate_config
2124
videos
2225

2326
# Created by https://www.gitignore.io/api/virtualenv

NodeBase/Dockerfile.txt

-4
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,4 @@ RUN sudo mkdir -p /tmp/.X11-unix && sudo chmod 1777 /tmp/.X11-unix
175175
# Copying configuration script generator
176176
COPY generate_config /opt/bin/generate_config
177177

178-
# Generating a default config during build time
179-
RUN /opt/bin/generate_config
180-
181-
182178
EXPOSE 5900

NodeBase/generate_config

+23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
function short_version() {
4+
local __long_version=$1
5+
local __version_split=( ${__long_version//./ } )
6+
echo "${__version_split[0]}.${__version_split[1]}"
7+
}
8+
39
echo "[events]
410
publish = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_PUBLISH_PORT}\"
511
subscribe = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_SUBSCRIBE_PORT}\"
@@ -32,6 +38,23 @@ else
3238
fi
3339
echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> /opt/selenium/config.toml
3440
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> /opt/selenium/config.toml
41+
echo "detect-drivers = false" >> /opt/selenium/config.toml
42+
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
43+
" >> /opt/selenium/config.toml
44+
45+
SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name)
46+
if [[ "${SE_NODE_BROWSER_NAME}" == "chrome" ]]; then
47+
SE_NODE_BROWSER_VERSION=$(short_version $(google-chrome --version | awk '{print $3}'))
48+
elif [[ "${SE_NODE_BROWSER_NAME}" == "firefox" ]]; then
49+
SE_NODE_BROWSER_VERSION=$(short_version $(firefox --version | awk '{print $3}'))
50+
elif [[ "${SE_NODE_BROWSER_NAME}" == "MicrosoftEdge" ]]; then
51+
SE_NODE_BROWSER_VERSION=$(short_version $(microsoft-edge --version | awk '{print $3}'))
52+
fi
53+
54+
SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\"}"
55+
echo "[[node.driver-configuration]]" >> /opt/selenium/config.toml
56+
echo "name = \"${SE_NODE_BROWSER_NAME}\"" >> /opt/selenium/config.toml
57+
echo "stereotype = '${SE_NODE_STEREOTYPE}'" >> /opt/selenium/config.toml
3558
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
3659
" >> /opt/selenium/config.toml
3760

NodeBase/start-selenium-node.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ fi
3333

3434
/opt/bin/generate_config
3535

36-
echo "Starting Selenium Grid Node with configuration: "
36+
echo "Selenium Grid Node configuration: "
3737
cat /opt/selenium/config.toml
38-
38+
echo "Starting Selenium Grid Node..."
3939
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \
4040
--config /opt/selenium/config.toml \
4141
${SE_OPTS}

NodeChrome/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ RUN if [ -z "$CHROME_DRIVER_VERSION" ]; \
5353
&& mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
5454
&& chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
5555
&& sudo ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
56+
57+
58+
#============================================
59+
# Dumping Browser name and version for config
60+
#============================================
61+
RUN echo "chrome" > /opt/selenium/browser_name

NodeChrome/Dockerfile.txt

+6
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ RUN if [ -z "$CHROME_DRIVER_VERSION" ]; \
4646
&& mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
4747
&& chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
4848
&& sudo ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
49+
50+
51+
#============================================
52+
# Dumping Browser name and version for config
53+
#============================================
54+
RUN echo "chrome" > /opt/selenium/browser_name

NodeEdge/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ RUN if [ -z "$EDGE_DRIVER_VERSION" ]; \
4848
&& mv /opt/selenium/msedgedriver /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION \
4949
&& chmod 755 /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION \
5050
&& sudo ln -fs /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION /usr/bin/msedgedriver
51+
52+
#============================================
53+
# Dumping Browser name and version for config
54+
#============================================
55+
RUN echo "MicrosoftEdge" > /opt/selenium/browser_name

NodeEdge/Dockerfile.txt

+5
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ RUN if [ -z "$EDGE_DRIVER_VERSION" ]; \
4141
&& mv /opt/selenium/msedgedriver /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION \
4242
&& chmod 755 /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION \
4343
&& sudo ln -fs /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION /usr/bin/msedgedriver
44+
45+
#============================================
46+
# Dumping Browser name and version for config
47+
#============================================
48+
RUN echo "MicrosoftEdge" > /opt/selenium/browser_name

NodeFirefox/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ RUN GK_VERSION=$(if [ ${GECKODRIVER_VERSION:-latest} = "latest" ]; then echo "0.
3838
&& ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver
3939

4040
USER 1200
41+
42+
#============================================
43+
# Dumping Browser name and version for config
44+
#============================================
45+
RUN echo "firefox" > /opt/selenium/browser_name

NodeFirefox/Dockerfile.txt

+5
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ RUN GK_VERSION=$(if [ ${GECKODRIVER_VERSION:-latest} = "latest" ]; then echo "0.
3131
&& ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver
3232

3333
USER 1200
34+
35+
#============================================
36+
# Dumping Browser name and version for config
37+
#============================================
38+
RUN echo "firefox" > /opt/selenium/browser_name

Standalone/Dockerfile.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ COPY start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
1010
#==============================
1111
COPY selenium.conf /etc/supervisor/conf.d/
1212

13+
# Copying configuration script generator
14+
COPY generate_config /opt/bin/generate_config
15+
1316
# Boolean value, maps "--relax-checks"
1417
ENV SE_RELAX_CHECKS true
1518

16-
1719
EXPOSE 4444
1820

1921

Standalone/generate.sh

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ cat ./Dockerfile.txt >> ${FOLDER}/Dockerfile
1616

1717
cp ./start-selenium-standalone.sh ${FOLDER}
1818
cp ./selenium.conf ${FOLDER}
19+
cp ./generate_config ${FOLDER}

Standalone/generate_config

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
function short_version() {
4+
local __long_version=$1
5+
local __version_split=( ${__long_version//./ } )
6+
echo "${__version_split[0]}.${__version_split[1]}"
7+
}
8+
9+
echo "[network]
10+
relax-checks = ${SE_RELAX_CHECKS}
11+
" > /opt/selenium/config.toml
12+
13+
echo "[node]" >> /opt/selenium/config.toml
14+
echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> /opt/selenium/config.toml
15+
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> /opt/selenium/config.toml
16+
echo "detect-drivers = false" >> /opt/selenium/config.toml
17+
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
18+
" >> /opt/selenium/config.toml
19+
20+
SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name)
21+
if [[ "${SE_NODE_BROWSER_NAME}" == "chrome" ]]; then
22+
SE_NODE_BROWSER_VERSION=$(short_version $(google-chrome --version | awk '{print $3}'))
23+
elif [[ "${SE_NODE_BROWSER_NAME}" == "firefox" ]]; then
24+
SE_NODE_BROWSER_VERSION=$(short_version $(firefox --version | awk '{print $3}'))
25+
elif [[ "${SE_NODE_BROWSER_NAME}" == "MicrosoftEdge" ]]; then
26+
SE_NODE_BROWSER_VERSION=$(short_version $(microsoft-edge --version | awk '{print $3}'))
27+
fi
28+
29+
SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\"}"
30+
echo "[[node.driver-configuration]]" >> /opt/selenium/config.toml
31+
echo "name = \"${SE_NODE_BROWSER_NAME}\"" >> /opt/selenium/config.toml
32+
echo "stereotype = '${SE_NODE_STEREOTYPE}'" >> /opt/selenium/config.toml
33+
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
34+
" >> /opt/selenium/config.toml
35+
36+
37+

Standalone/start-selenium-standalone.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ if [ ! -z "$SE_OPTS" ]; then
66
echo "Appending Selenium options: ${SE_OPTS}"
77
fi
88

9+
/opt/bin/generate_config
10+
11+
echo "Selenium Grid Standalone configuration: "
12+
cat /opt/selenium/config.toml
13+
echo "Starting Selenium Grid Standalone..."
914
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar standalone \
10-
--relax-checks ${SE_RELAX_CHECKS} \
11-
--session-timeout ${SE_NODE_SESSION_TIMEOUT} \
12-
--max-sessions ${SE_NODE_MAX_SESSIONS} \
13-
--override-max-sessions ${SE_NODE_OVERRIDE_MAX_SESSIONS} \
15+
--config /opt/selenium/config.toml \
1416
${SE_OPTS}

StandaloneChrome/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ COPY start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
1717
#==============================
1818
COPY selenium.conf /etc/supervisor/conf.d/
1919

20+
# Copying configuration script generator
21+
COPY generate_config /opt/bin/generate_config
22+
23+
# Generating a default config during build time
24+
RUN /opt/bin/generate_config
25+
2026
# Boolean value, maps "--relax-checks"
2127
ENV SE_RELAX_CHECKS true
2228

StandaloneEdge/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ COPY start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
1717
#==============================
1818
COPY selenium.conf /etc/supervisor/conf.d/
1919

20+
# Copying configuration script generator
21+
COPY generate_config /opt/bin/generate_config
22+
23+
# Generating a default config during build time
24+
RUN /opt/bin/generate_config
25+
2026
# Boolean value, maps "--relax-checks"
2127
ENV SE_RELAX_CHECKS true
2228

StandaloneEdge/selenium.conf

-73
This file was deleted.

StandaloneEdge/start-selenium-standalone.sh

-14
This file was deleted.

StandaloneFirefox/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ COPY start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
1717
#==============================
1818
COPY selenium.conf /etc/supervisor/conf.d/
1919

20+
# Copying configuration script generator
21+
COPY generate_config /opt/bin/generate_config
22+
23+
# Generating a default config during build time
24+
RUN /opt/bin/generate_config
25+
2026
# Boolean value, maps "--relax-checks"
2127
ENV SE_RELAX_CHECKS true
2228

tests/bootstrap.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [ "${CI:-false}" = "false" ]; then
77
source docker-selenium-tests/bin/activate
88
fi
99

10-
python -m pip install selenium==4.0.0.a7 \
10+
python -m pip install selenium==4.0.0.b3 \
1111
docker===4.2.0 \
1212
| grep -v 'Requirement already satisfied'
1313

0 commit comments

Comments
 (0)