diff --git a/.gitignore b/.gitignore index 913087acea..a521804ad7 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/NodeBase/Dockerfile.txt b/NodeBase/Dockerfile.txt index 3cf6945bb4..250bdbbe7c 100644 --- a/NodeBase/Dockerfile.txt +++ b/NodeBase/Dockerfile.txt @@ -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 diff --git a/NodeBase/generate_config b/NodeBase/generate_config index 7279eba37a..8f6a46f08e 100755 --- a/NodeBase/generate_config +++ b/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}\" @@ -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 diff --git a/NodeBase/start-selenium-node.sh b/NodeBase/start-selenium-node.sh index d2ee53642e..5a80a3ef08 100755 --- a/NodeBase/start-selenium-node.sh +++ b/NodeBase/start-selenium-node.sh @@ -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} diff --git a/NodeChrome/Dockerfile b/NodeChrome/Dockerfile index 1f158657de..94a7a612c8 100644 --- a/NodeChrome/Dockerfile +++ b/NodeChrome/Dockerfile @@ -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 \ No newline at end of file diff --git a/NodeChrome/Dockerfile.txt b/NodeChrome/Dockerfile.txt index c5f161ab9c..0563826d9f 100644 --- a/NodeChrome/Dockerfile.txt +++ b/NodeChrome/Dockerfile.txt @@ -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 \ No newline at end of file diff --git a/NodeEdge/Dockerfile b/NodeEdge/Dockerfile index f161720c33..001f14978e 100644 --- a/NodeEdge/Dockerfile +++ b/NodeEdge/Dockerfile @@ -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 \ No newline at end of file diff --git a/NodeEdge/Dockerfile.txt b/NodeEdge/Dockerfile.txt index 7e422d4724..d22fba71ee 100644 --- a/NodeEdge/Dockerfile.txt +++ b/NodeEdge/Dockerfile.txt @@ -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 \ No newline at end of file diff --git a/NodeFirefox/Dockerfile b/NodeFirefox/Dockerfile index 42336927ae..d177b6cab2 100644 --- a/NodeFirefox/Dockerfile +++ b/NodeFirefox/Dockerfile @@ -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 \ No newline at end of file diff --git a/NodeFirefox/Dockerfile.txt b/NodeFirefox/Dockerfile.txt index 636040ccb1..0fd30e7dc5 100644 --- a/NodeFirefox/Dockerfile.txt +++ b/NodeFirefox/Dockerfile.txt @@ -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 \ No newline at end of file diff --git a/Standalone/Dockerfile.txt b/Standalone/Dockerfile.txt index 90c9714f11..61bdf6e343 100644 --- a/Standalone/Dockerfile.txt +++ b/Standalone/Dockerfile.txt @@ -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 diff --git a/Standalone/generate.sh b/Standalone/generate.sh index f178605ad1..30208b492b 100755 --- a/Standalone/generate.sh +++ b/Standalone/generate.sh @@ -16,3 +16,4 @@ cat ./Dockerfile.txt >> ${FOLDER}/Dockerfile cp ./start-selenium-standalone.sh ${FOLDER} cp ./selenium.conf ${FOLDER} +cp ./generate_config ${FOLDER} diff --git a/Standalone/generate_config b/Standalone/generate_config new file mode 100755 index 0000000000..55dff0c7a9 --- /dev/null +++ b/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 + + + diff --git a/Standalone/start-selenium-standalone.sh b/Standalone/start-selenium-standalone.sh index 1ec69e6fff..8ff6144d2e 100755 --- a/Standalone/start-selenium-standalone.sh +++ b/Standalone/start-selenium-standalone.sh @@ -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} \ No newline at end of file diff --git a/StandaloneChrome/Dockerfile b/StandaloneChrome/Dockerfile index 1bfbde9392..ddfc7f6dc9 100644 --- a/StandaloneChrome/Dockerfile +++ b/StandaloneChrome/Dockerfile @@ -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 diff --git a/StandaloneEdge/Dockerfile b/StandaloneEdge/Dockerfile index a19a9591c1..02a5ed18b9 100644 --- a/StandaloneEdge/Dockerfile +++ b/StandaloneEdge/Dockerfile @@ -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 diff --git a/StandaloneEdge/selenium.conf b/StandaloneEdge/selenium.conf deleted file mode 100644 index 23ef45f78d..0000000000 --- a/StandaloneEdge/selenium.conf +++ /dev/null @@ -1,73 +0,0 @@ -; Documentation of this file format -> http://supervisord.org/configuration.html - -; Priority 0 - xvfb & fluxbox, 5 - x11vnc, 10 - noVNC, 15 - selenium-standalone - -[program:xvfb] -priority=0 -command=/opt/bin/start-xvfb.sh -autostart=true -autorestart=false -startsecs=0 -startretries=0 - -;Logs -redirect_stderr=false -stdout_logfile=/var/log/supervisor/xvfb-stdout.log -stderr_logfile=/var/log/supervisor/xvfb-stderr.log -stdout_logfile_maxbytes=50MB -stderr_logfile_maxbytes=50MB -stdout_logfile_backups=5 -stderr_logfile_backups=5 -stdout_capture_maxbytes=50MB -stderr_capture_maxbytes=50MB - -[program:vnc] -priority=5 -command=/opt/bin/start-vnc.sh -autostart=true -autorestart=false -startsecs=0 -startretries=0 - -;Logs -redirect_stderr=false -stdout_logfile=/var/log/supervisor/vnc-stdout.log -stderr_logfile=/var/log/supervisor/vnc-stderr.log -stdout_logfile_maxbytes=50MB -stderr_logfile_maxbytes=50MB -stdout_logfile_backups=5 -stderr_logfile_backups=5 -stdout_capture_maxbytes=50MB -stderr_capture_maxbytes=50MB - -[program:novnc] -priority=10 -command=/opt/bin/start-novnc.sh -autostart=true -autorestart=false -startsecs=0 -startretries=0 - -;Logs -redirect_stderr=false -stdout_logfile=/var/log/supervisor/novnc-stdout.log -stderr_logfile=/var/log/supervisor/novnc-stderr.log -stdout_logfile_maxbytes=50MB -stderr_logfile_maxbytes=50MB -stdout_logfile_backups=5 -stderr_logfile_backups=5 -stdout_capture_maxbytes=50MB -stderr_capture_maxbytes=50MB - -[program:selenium-standalone] -priority=15 -command=/opt/bin/start-selenium-standalone.sh -autostart=true -autorestart=false -startsecs=0 -startretries=0 - -;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs" -redirect_stderr=true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 diff --git a/StandaloneEdge/start-selenium-standalone.sh b/StandaloneEdge/start-selenium-standalone.sh deleted file mode 100755 index 1ec69e6fff..0000000000 --- a/StandaloneEdge/start-selenium-standalone.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# -# IMPORTANT: Change this file only in directory Standalone! - -if [ ! -z "$SE_OPTS" ]; then - echo "Appending Selenium options: ${SE_OPTS}" -fi - -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} \ - ${SE_OPTS} \ No newline at end of file diff --git a/StandaloneFirefox/Dockerfile b/StandaloneFirefox/Dockerfile index c7a9b07208..a81e9cbb75 100644 --- a/StandaloneFirefox/Dockerfile +++ b/StandaloneFirefox/Dockerfile @@ -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 diff --git a/tests/bootstrap.sh b/tests/bootstrap.sh index 21b1438ae8..ec7fe43fcd 100755 --- a/tests/bootstrap.sh +++ b/tests/bootstrap.sh @@ -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'