Skip to content

Commit fb77532

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

File tree

20 files changed

+128
-101
lines changed

20 files changed

+128
-101
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 23 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

0 commit comments

Comments
 (0)