Skip to content

Commit

Permalink
Adding browser version in browser images (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed May 25, 2021
1 parent c7b0dc1 commit fb77532
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 101 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Expand Up @@ -14,10 +14,13 @@ assets
# Ignoring generated files during the build process
StandaloneC*/selenium.conf
StandaloneF*/selenium.conf
StandaloneO*/selenium.conf
StandaloneE*/selenium.conf
StandaloneC*/start-*.sh
StandaloneF*/start-*.sh
StandaloneO*/start-*.sh
StandaloneE*/start-*.sh
StandaloneC*/generate_config
StandaloneF*/generate_config
StandaloneE*/generate_config
videos

# Created by https://www.gitignore.io/api/virtualenv
Expand Down
4 changes: 0 additions & 4 deletions NodeBase/Dockerfile.txt
Expand Up @@ -175,8 +175,4 @@ RUN sudo mkdir -p /tmp/.X11-unix && sudo chmod 1777 /tmp/.X11-unix
# Copying configuration script generator
COPY generate_config /opt/bin/generate_config

# Generating a default config during build time
RUN /opt/bin/generate_config


EXPOSE 5900
23 changes: 23 additions & 0 deletions NodeBase/generate_config
@@ -1,5 +1,11 @@
#!/bin/bash

function short_version() {
local __long_version=$1
local __version_split=( ${__long_version//./ } )
echo "${__version_split[0]}.${__version_split[1]}"
}

echo "[events]
publish = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_PUBLISH_PORT}\"
subscribe = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_SUBSCRIBE_PORT}\"
Expand Down Expand Up @@ -32,6 +38,23 @@ else
fi
echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> /opt/selenium/config.toml
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> /opt/selenium/config.toml
echo "detect-drivers = false" >> /opt/selenium/config.toml
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
" >> /opt/selenium/config.toml

SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name)
if [[ "${SE_NODE_BROWSER_NAME}" == "chrome" ]]; then
SE_NODE_BROWSER_VERSION=$(short_version $(google-chrome --version | awk '{print $3}'))
elif [[ "${SE_NODE_BROWSER_NAME}" == "firefox" ]]; then
SE_NODE_BROWSER_VERSION=$(short_version $(firefox --version | awk '{print $3}'))
elif [[ "${SE_NODE_BROWSER_NAME}" == "MicrosoftEdge" ]]; then
SE_NODE_BROWSER_VERSION=$(short_version $(microsoft-edge --version | awk '{print $3}'))
fi

SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\"}"
echo "[[node.driver-configuration]]" >> /opt/selenium/config.toml
echo "name = \"${SE_NODE_BROWSER_NAME}\"" >> /opt/selenium/config.toml
echo "stereotype = '${SE_NODE_STEREOTYPE}'" >> /opt/selenium/config.toml
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
" >> /opt/selenium/config.toml

Expand Down
4 changes: 2 additions & 2 deletions NodeBase/start-selenium-node.sh
Expand Up @@ -33,9 +33,9 @@ fi

/opt/bin/generate_config

echo "Starting Selenium Grid Node with configuration: "
echo "Selenium Grid Node configuration: "
cat /opt/selenium/config.toml

echo "Starting Selenium Grid Node..."
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \
--config /opt/selenium/config.toml \
${SE_OPTS}
6 changes: 6 additions & 0 deletions NodeChrome/Dockerfile
Expand Up @@ -53,3 +53,9 @@ RUN if [ -z "$CHROME_DRIVER_VERSION" ]; \
&& mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& sudo ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver


#============================================
# Dumping Browser name and version for config
#============================================
RUN echo "chrome" > /opt/selenium/browser_name
6 changes: 6 additions & 0 deletions NodeChrome/Dockerfile.txt
Expand Up @@ -46,3 +46,9 @@ RUN if [ -z "$CHROME_DRIVER_VERSION" ]; \
&& mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& sudo ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver


#============================================
# Dumping Browser name and version for config
#============================================
RUN echo "chrome" > /opt/selenium/browser_name
5 changes: 5 additions & 0 deletions NodeEdge/Dockerfile
Expand Up @@ -48,3 +48,8 @@ RUN if [ -z "$EDGE_DRIVER_VERSION" ]; \
&& mv /opt/selenium/msedgedriver /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION \
&& chmod 755 /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION \
&& sudo ln -fs /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION /usr/bin/msedgedriver

#============================================
# Dumping Browser name and version for config
#============================================
RUN echo "MicrosoftEdge" > /opt/selenium/browser_name
5 changes: 5 additions & 0 deletions NodeEdge/Dockerfile.txt
Expand Up @@ -41,3 +41,8 @@ RUN if [ -z "$EDGE_DRIVER_VERSION" ]; \
&& mv /opt/selenium/msedgedriver /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION \
&& chmod 755 /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION \
&& sudo ln -fs /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION /usr/bin/msedgedriver

#============================================
# Dumping Browser name and version for config
#============================================
RUN echo "MicrosoftEdge" > /opt/selenium/browser_name
5 changes: 5 additions & 0 deletions NodeFirefox/Dockerfile
Expand Up @@ -38,3 +38,8 @@ RUN GK_VERSION=$(if [ ${GECKODRIVER_VERSION:-latest} = "latest" ]; then echo "0.
&& ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver

USER 1200

#============================================
# Dumping Browser name and version for config
#============================================
RUN echo "firefox" > /opt/selenium/browser_name
5 changes: 5 additions & 0 deletions NodeFirefox/Dockerfile.txt
Expand Up @@ -31,3 +31,8 @@ RUN GK_VERSION=$(if [ ${GECKODRIVER_VERSION:-latest} = "latest" ]; then echo "0.
&& ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver

USER 1200

#============================================
# Dumping Browser name and version for config
#============================================
RUN echo "firefox" > /opt/selenium/browser_name
4 changes: 3 additions & 1 deletion Standalone/Dockerfile.txt
Expand Up @@ -10,10 +10,12 @@ COPY start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
#==============================
COPY selenium.conf /etc/supervisor/conf.d/

# Copying configuration script generator
COPY generate_config /opt/bin/generate_config

# Boolean value, maps "--relax-checks"
ENV SE_RELAX_CHECKS true


EXPOSE 4444


1 change: 1 addition & 0 deletions Standalone/generate.sh
Expand Up @@ -16,3 +16,4 @@ cat ./Dockerfile.txt >> ${FOLDER}/Dockerfile

cp ./start-selenium-standalone.sh ${FOLDER}
cp ./selenium.conf ${FOLDER}
cp ./generate_config ${FOLDER}
37 changes: 37 additions & 0 deletions Standalone/generate_config
@@ -0,0 +1,37 @@
#!/bin/bash

function short_version() {
local __long_version=$1
local __version_split=( ${__long_version//./ } )
echo "${__version_split[0]}.${__version_split[1]}"
}

echo "[network]
relax-checks = ${SE_RELAX_CHECKS}
" > /opt/selenium/config.toml

echo "[node]" >> /opt/selenium/config.toml
echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> /opt/selenium/config.toml
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> /opt/selenium/config.toml
echo "detect-drivers = false" >> /opt/selenium/config.toml
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
" >> /opt/selenium/config.toml

SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name)
if [[ "${SE_NODE_BROWSER_NAME}" == "chrome" ]]; then
SE_NODE_BROWSER_VERSION=$(short_version $(google-chrome --version | awk '{print $3}'))
elif [[ "${SE_NODE_BROWSER_NAME}" == "firefox" ]]; then
SE_NODE_BROWSER_VERSION=$(short_version $(firefox --version | awk '{print $3}'))
elif [[ "${SE_NODE_BROWSER_NAME}" == "MicrosoftEdge" ]]; then
SE_NODE_BROWSER_VERSION=$(short_version $(microsoft-edge --version | awk '{print $3}'))
fi

SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\"}"
echo "[[node.driver-configuration]]" >> /opt/selenium/config.toml
echo "name = \"${SE_NODE_BROWSER_NAME}\"" >> /opt/selenium/config.toml
echo "stereotype = '${SE_NODE_STEREOTYPE}'" >> /opt/selenium/config.toml
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
" >> /opt/selenium/config.toml



10 changes: 6 additions & 4 deletions Standalone/start-selenium-standalone.sh
Expand Up @@ -6,9 +6,11 @@ if [ ! -z "$SE_OPTS" ]; then
echo "Appending Selenium options: ${SE_OPTS}"
fi

/opt/bin/generate_config

echo "Selenium Grid Standalone configuration: "
cat /opt/selenium/config.toml
echo "Starting Selenium Grid Standalone..."
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar standalone \
--relax-checks ${SE_RELAX_CHECKS} \
--session-timeout ${SE_NODE_SESSION_TIMEOUT} \
--max-sessions ${SE_NODE_MAX_SESSIONS} \
--override-max-sessions ${SE_NODE_OVERRIDE_MAX_SESSIONS} \
--config /opt/selenium/config.toml \
${SE_OPTS}
6 changes: 6 additions & 0 deletions StandaloneChrome/Dockerfile
Expand Up @@ -17,6 +17,12 @@ COPY start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
#==============================
COPY selenium.conf /etc/supervisor/conf.d/

# Copying configuration script generator
COPY generate_config /opt/bin/generate_config

# Generating a default config during build time
RUN /opt/bin/generate_config

# Boolean value, maps "--relax-checks"
ENV SE_RELAX_CHECKS true

Expand Down
6 changes: 6 additions & 0 deletions StandaloneEdge/Dockerfile
Expand Up @@ -17,6 +17,12 @@ COPY start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
#==============================
COPY selenium.conf /etc/supervisor/conf.d/

# Copying configuration script generator
COPY generate_config /opt/bin/generate_config

# Generating a default config during build time
RUN /opt/bin/generate_config

# Boolean value, maps "--relax-checks"
ENV SE_RELAX_CHECKS true

Expand Down
73 changes: 0 additions & 73 deletions StandaloneEdge/selenium.conf

This file was deleted.

14 changes: 0 additions & 14 deletions StandaloneEdge/start-selenium-standalone.sh

This file was deleted.

6 changes: 6 additions & 0 deletions StandaloneFirefox/Dockerfile
Expand Up @@ -17,6 +17,12 @@ COPY start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
#==============================
COPY selenium.conf /etc/supervisor/conf.d/

# Copying configuration script generator
COPY generate_config /opt/bin/generate_config

# Generating a default config during build time
RUN /opt/bin/generate_config

# Boolean value, maps "--relax-checks"
ENV SE_RELAX_CHECKS true

Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.sh
Expand Up @@ -7,7 +7,7 @@ if [ "${CI:-false}" = "false" ]; then
source docker-selenium-tests/bin/activate
fi

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

Expand Down

0 comments on commit fb77532

Please sign in to comment.