From d7c4eaf7d3964ed2882375588e5e0dba55673377 Mon Sep 17 00:00:00 2001
From: Rajab Natshah <rajabn@gmail.com>
Date: Wed, 4 May 2022 18:27:40 +0300
Subject: [PATCH] Issue #3278730: Switch to use Selenium Server Standalone
 3.141.59 to follow with Latest Chrome Browser and Chrome Driver options

---
 .circleci/config.yml                          | 12 ++--
 behat.yml                                     | 37 +++++------
 tests/README.md                               | 50 +++++++--------
 tests/tools/drush/README.md                   | 17 -----
 tests/tools/drush/clear-flood.feature         | 12 ----
 tests/tools/drush/drush-dis-ds_ui.feature     |  7 ---
 tests/tools/drush/drush-en-ds_ui.feature      |  7 ---
 tests/tools/google/README.md                  | 11 ----
 tests/tools/google/gmail.feature              | 16 -----
 tests/tools/google/search.feature             | 13 ----
 tests/tools/install-selenium-server/README.md | 62 -------------------
 ...nload-and-run-once-only-selenium-2.53.1.sh |  7 ---
 ...wnload-and-run-once-only-selenium-3.0.1.sh |  6 --
 .../install-selenium-server-2.53.1.sh         | 25 --------
 .../install-selenium-server-3.0.1.sh          | 25 --------
 .../tools/install-selenium-server/selenium.sh | 52 ----------------
 .../uninstall-selenium-server.sh              | 17 -----
 17 files changed, 47 insertions(+), 329 deletions(-)
 delete mode 100644 tests/tools/drush/README.md
 delete mode 100644 tests/tools/drush/clear-flood.feature
 delete mode 100644 tests/tools/drush/drush-dis-ds_ui.feature
 delete mode 100644 tests/tools/drush/drush-en-ds_ui.feature
 delete mode 100644 tests/tools/google/README.md
 delete mode 100644 tests/tools/google/gmail.feature
 delete mode 100644 tests/tools/google/search.feature
 delete mode 100644 tests/tools/install-selenium-server/README.md
 delete mode 100644 tests/tools/install-selenium-server/download-and-run-once-only-selenium-2.53.1.sh
 delete mode 100644 tests/tools/install-selenium-server/download-and-run-once-only-selenium-3.0.1.sh
 delete mode 100644 tests/tools/install-selenium-server/install-selenium-server-2.53.1.sh
 delete mode 100644 tests/tools/install-selenium-server/install-selenium-server-3.0.1.sh
 delete mode 100644 tests/tools/install-selenium-server/selenium.sh
 delete mode 100644 tests/tools/install-selenium-server/uninstall-selenium-server.sh

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 788b2fed..8e92ea5b 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -68,9 +68,9 @@ commands:
             done
             echo Failed waiting for MySQL && exit 1
 
-      ## Install composer ~2.1
+      ## Install Composer
       - run:
-          name: Install composer ~2.1
+          name: Install Composer
           command: |
             sudo curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin/ --filename=composer --2;
             composer config -g github-oauth.github.com $GITHUB_TOKEN
@@ -207,13 +207,13 @@ commands:
             ../bin/drush config:set system.logging error_level all --yes
             ../bin/drush cr
 
-      ## Run selenium standalone server.
+      ## Run Selenium Standalone server.
       - run:
-          name: Run selenium standalone server
+          name: Run Selenium Standalone server
           command: |
-            if [[ ! -f /home/circleci/selenium-server-standalone-2.53.1.jar ]]; then wget -O /home/circleci/selenium-server-standalone-2.53.1.jar http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar; fi
+            if [[ ! -f /home/circleci/selenium-server-standalone-3.141.59.jar ]]; then wget -O /home/circleci/selenium-server-standalone-3.141.59.jar https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.59/selenium-server-standalone-3.141.59.jar; fi
             cd /home/circleci/
-            java -jar selenium-server-standalone-2.53.1.jar -port 4445
+            java -jar selenium-server-standalone-3.141.59.jar -port 4445
           background: true
 
       ## Add testing users.
diff --git a/behat.yml b/behat.yml
index 288a9563..f0c4599f 100644
--- a/behat.yml
+++ b/behat.yml
@@ -63,33 +63,30 @@ default:
           browserName: chrome
           version: "*"
           extra_capabilities:
+            loggingPrefs:
+              performance: ALL
+              browser: ALL
             chromeOptions:
+              w3c: false
               args:
+                - "--headless"
+                - "--start-maximized"
                 - "--disable-gpu"
                 - "--window-size=1600,1200"
                 - "--no-sandbox"
                 - "--disable-dev-shm-usage"
                 - "--disable-setuid-sandbox"
-              w3c: false
-          chrome:
-            switches:
-              - "--headless"
-              - "--start-maximized"
-              - "--disable-gpu"
-              - "--window-size=1600,1200"
-              - "--no-sandbox"
-              - "--disable-dev-shm-usage"
-              - "--disable-setuid-sandbox"
-              - "--disable-web-security"
-              - "--DNS-prefetch-disable"
-              - "--whitelisted-ips"
-              - "--disable-translate"
-              - "--ignore-certificate-errors"
-              - "--test-type"
-              - "--disable-extensions"
-              - "--incognito"
-              - "--ignore-certificate-errors"
-              - "--disable-infobars"
+                - "--disable-web-security"
+                - "--DNS-prefetch-disable"
+                - "--disable-translate"
+                - "--ignore-certificate-errors"
+                - "--test-type"
+                - "--disable-extensions"
+                - "--incognito"
+                - "--disable-infobars"
+                - "--remote-debugging-port=9222"
+                - "--allowed-ips=*"
+                - "--whitelisted-ips=*"
       base_url: 'http://varbase.test'
       # browser_name: 'firefox'
       browser_name: 'chrome'
diff --git a/tests/README.md b/tests/README.md
index 2e5ada2a..3f6b5847 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -148,12 +148,12 @@ sudo mv -f chromedriver /usr/bin/
 rm chromedriver_linux64.zip
 ```
 
-### Get selenium standalone server.
+### Get Selenium Standalone server.
 ```
-wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
+wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.59/selenium-server-standalone-3.141.59.jar
 ```
 
-## Run selenium standalone server.
+## Run Selenium Standalone server.
 
 ```
 $ java -jar selenium-*.jar -port 4445
@@ -180,32 +180,30 @@ To run the automated testing with behat you will need to change the [ wd_host an
           browserName: chrome
           version: "*"
           extra_capabilities:
+            loggingPrefs:
+              performance: ALL
+              browser: ALL
             chromeOptions:
+              w3c: false
               args:
+                - "--headless"
+                - "--start-maximized"
                 - "--disable-gpu"
-                - "--window-size=1920,1080"
-              w3c: false
-          chrome:
-            switches:
-              - "--headless"
-              - "no-sandbox"
-              - "--no-sandbox"
-              - "--disable-web-security"
-              - "--DNS-prefetch-disable"
-              - "--whitelisted-ips"
-              - "--start-maximized"
-              - "--disable-translate"
-              - "--ignore-certificate-errors"
-              - "--test-type"
-              - "--disable-dev-shm-usage"
-              - "--disable-extensions"
-              - "incognito"
-              - "enable-precise-memory-info"
-              - "ignore-certificate-errors"
-              - "disable-infobars"
-              - "js-flags=--expose-gc"
-              - "--profile-directory=Default"
-              - "--user-data-dir=~/.config/google-chrome"
+                - "--window-size=1600,1200"
+                - "--no-sandbox"
+                - "--disable-dev-shm-usage"
+                - "--disable-setuid-sandbox"
+                - "--disable-web-security"
+                - "--DNS-prefetch-disable"
+                - "--disable-translate"
+                - "--ignore-certificate-errors"
+                - "--test-type"
+                - "--disable-extensions"
+                - "--incognito"
+                - "--disable-infobars"
+                - "--remote-debugging-port=9222"
+                - "--allowed-ips=*"
+                - "--whitelisted-ips=*"
       base_url: 'http://varbase.test'
       # browser_name: 'firefox'
       browser_name: 'chrome'
diff --git a/tests/tools/drush/README.md b/tests/tools/drush/README.md
deleted file mode 100644
index e5674219..00000000
--- a/tests/tools/drush/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-A list of Gherkin features, which help in testing drush commands.
-and helps in setting the development and production environment.
-
-If you want to test the any of the tools features, you will need to use the
- varbase tools config file, as you can see in the following command.
-
-$ bin/behat --config=behat.varbase-tools.yml tools/drush/clear-flood.feature
-
-$ bin/behat --config=behat.varbase-tools.yml tools/drush/drush-dis-ds_ui.feature
-
-$ bin/behat --config=behat.varbase-tools.yml tools/drush/drush-en-ds_ui.feature
-
-
-
-$ bin/behat --config=behat.varbase-tools.yml tools/drush/on-development.feature
-
-$ bin/behat --config=behat.varbase-tools.yml tools/drush/on-production.feature
diff --git a/tests/tools/drush/clear-flood.feature b/tests/tools/drush/clear-flood.feature
deleted file mode 100644
index 30cf8c8b..00000000
--- a/tests/tools/drush/clear-flood.feature
+++ /dev/null
@@ -1,12 +0,0 @@
-Feature: Clear flood.
-As a Developer
-I want to be able to clear the flood table when I see the following message
-"Sorry, there have been more than 5 failed login attempts for this account.
-It is temporarily blocked. Try again later or request a new password."
-So that will be able to let the blocked user login to the site
-
-  @api @tools @local @development
-  Scenario: Delete all recourds in the flood table.
-    Given I run drush "sqlq 'DELETE FROM flood'"
-     Then print last drush output
-  
diff --git a/tests/tools/drush/drush-dis-ds_ui.feature b/tests/tools/drush/drush-dis-ds_ui.feature
deleted file mode 100644
index 6529e549..00000000
--- a/tests/tools/drush/drush-dis-ds_ui.feature
+++ /dev/null
@@ -1,7 +0,0 @@
-Feature: Disable ds_ui module.
-
-  @api @tools @local @development
-  Scenario: Disable ds_ui module.
-    Given I run drush "dis" "ds_ui -y"
-     Then print last drush output
-  
diff --git a/tests/tools/drush/drush-en-ds_ui.feature b/tests/tools/drush/drush-en-ds_ui.feature
deleted file mode 100644
index 77027789..00000000
--- a/tests/tools/drush/drush-en-ds_ui.feature
+++ /dev/null
@@ -1,7 +0,0 @@
-Feature: Enable Display suite ui module.
-
-@api @tools @local @development
-  Scenario: Enable ds_ui.
-    Given I run drush "en" "ds_ui -y"
-     Then print last drush output
-  
diff --git a/tests/tools/google/README.md b/tests/tools/google/README.md
deleted file mode 100644
index 905608ea..00000000
--- a/tests/tools/google/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-A list of Gherkin features to test Google!!! sites.
-
-A list of Gherkin features, which help in testing drush commands.
-and helps in setting the development and production environment.
-
-If you want to test the any of the tools features, you will need to use the
- varbase tools config file, as you can see in the following command.
-
-$ bin/behat --config=behat.varbase-tools.yml tools/google/gmail.feature
-
-$ bin/behat --config=behat.varbase-tools.yml tools/google/search.feature
diff --git a/tests/tools/google/gmail.feature b/tests/tools/google/gmail.feature
deleted file mode 100644
index 287b7134..00000000
--- a/tests/tools/google/gmail.feature
+++ /dev/null
@@ -1,16 +0,0 @@
-Feature: Check the inbox for emails using the testing@vardot.com email
-
-  @javascript @tools @google
-  Scenario: Login to the testing@vardot.com email.
-    Given I go to "https://accounts.google.com" website
-     When I fill in "testing@vardot.com" for "Email"
-      And I press "Next"
-     Then I should see "Sign in with your Google Account "
-     When I fill in "The Password for the testing Email" for "Passwd"
-      And I press "Sign in"
-      And wait
-      And I go to "https://mail.google.com/mail/u/0/#inbox"
-      And wait
-     Then I should see "Inbox"
-      And I wait for 1m
-  
diff --git a/tests/tools/google/search.feature b/tests/tools/google/search.feature
deleted file mode 100644
index a57f8543..00000000
--- a/tests/tools/google/search.feature
+++ /dev/null
@@ -1,13 +0,0 @@
-Feature: Search google
-
-  @javascript @tools @google
-  Scenario: To search in Google about Varbase.
-    Given I go to "http://google.com" website
-      And wait
-     Then I should see "Google"
-     When I fill in "Varbase" for "q"
-      And I press "Search"
-      And wait for 10s
-     Then I should see "results"
-      And I wait 20s
-  
diff --git a/tests/tools/install-selenium-server/README.md b/tests/tools/install-selenium-server/README.md
deleted file mode 100644
index 83861712..00000000
--- a/tests/tools/install-selenium-server/README.md
+++ /dev/null
@@ -1,62 +0,0 @@
-# Selenium Server
-# Installing and configuring selenium server to work for each automated testing session #
-
-Some time I do test using some internal or external selenium server, but they
-do not have the option of restarting every thing from the beginning .
-
-I just want a very fast and basic solution, if the test finish I want the 
-selenium server to restart, and gave me a fresh start for the next automated
-testing session.
- 
-I made this list of script with a basic installer which:
-- Have Selenium standalone server will downloaded and installed on your localhost or server.
-- Then selenium will start working after reboots.
-- This selenium server will start at the 4445 port number.
-
-
-You will need to have Java first.
-================================================================================
-
-$ sudo apt-get install openjdk-8-jdk
-$ sudo apt-get install openjdk-8-jre
-
-================================================================================
-
-
-Run the following command to install selenium server 2.53.1:
-================================================================================
-
-$  sh ./install-selenium-server-2.53.1.sh
-
-================================================================================
-
-Run the following command to install selenium server 3.0.1:
-================================================================================
-
-$  sh ./install-selenium-server-3.0.1.sh
-
-================================================================================
-
-
-We could use the following commands to control the server
-================================================================================
-
-sudo /etc/init.d/selenium start
-
-sudo /etc/init.d/selenium stop
-
-sudo /etc/init.d/selenium restart
-
-================================================================================
-
-
-If you want to Uninstall :
-================================================================================
-
-$  sh ./uninstall-selenium-server.sh
-
-================================================================================
-Then Reboot.
-
-The only thing we do need is a reset Button to restart the selenium server to 
-work in a new automated testing session.
diff --git a/tests/tools/install-selenium-server/download-and-run-once-only-selenium-2.53.1.sh b/tests/tools/install-selenium-server/download-and-run-once-only-selenium-2.53.1.sh
deleted file mode 100644
index 79eaa015..00000000
--- a/tests/tools/install-selenium-server/download-and-run-once-only-selenium-2.53.1.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-echo "Getting selenium server standalone 2.53.1\n"
-wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
-java -jar selenium-server-standalone-2.31.0.jar -port 4445 > /dev/null &
-echo "[  OK  ] Starting Selenium on the 4445 port ..."
-
diff --git a/tests/tools/install-selenium-server/download-and-run-once-only-selenium-3.0.1.sh b/tests/tools/install-selenium-server/download-and-run-once-only-selenium-3.0.1.sh
deleted file mode 100644
index d4423384..00000000
--- a/tests/tools/install-selenium-server/download-and-run-once-only-selenium-3.0.1.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-echo "Getting selenium server standalone 3.0.1\n"
-wget http://selenium-release.storage.googleapis.com/3.0-beta3/selenium-server-standalone-3.0.1.jar
-java -jar selenium-server-standalone-3.0.1 -port 4445 > /dev/null &
-echo "[  OK  ] Starting Selenium on the 4445 port ..."
diff --git a/tests/tools/install-selenium-server/install-selenium-server-2.53.1.sh b/tests/tools/install-selenium-server/install-selenium-server-2.53.1.sh
deleted file mode 100644
index 2516ef4a..00000000
--- a/tests/tools/install-selenium-server/install-selenium-server-2.53.1.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-
-if [ ! -d "/usr/lib/selenium" ]; then
-  sudo mkdir /usr/lib/selenium
-
-  echo "Created selenium directory in /usr/lib.\n"
-
-  echo "Getting selenium server standalone 2.53.1\n"
-  sudo wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
-  sudo mv selenium-server-standalone-2.53.1.jar /usr/lib/selenium/selenium-server-standalone-2.53.1.jar
-  sudo ln -s /usr/lib/selenium/selenium-server-standalone-2.53.1.jar /usr/lib/selenium/selenium-server-standalone.jar
-  echo "The selenium server standalone is ready in the server.\n"
-
-  sudo mkdir -p /var/log/selenium
-  sudo chmod a+w /var/log/selenium
-  echo "Created the logs for selenium.\n"
-
-  sudo cp selenium.sh /etc/init.d/selenium
-  sudo chmod 755 /etc/init.d/selenium
-  sudo update-rc.d selenium defaults 4445
-  echo "Installed selenium server.\n"
-  sudo /etc/init.d/selenium start
-else
-  echo "Selenium is installed.\nIf you want to update or install you will need:\n to run ./uninstall-selenium-server.sh first"
-fi
diff --git a/tests/tools/install-selenium-server/install-selenium-server-3.0.1.sh b/tests/tools/install-selenium-server/install-selenium-server-3.0.1.sh
deleted file mode 100644
index 39c78bfd..00000000
--- a/tests/tools/install-selenium-server/install-selenium-server-3.0.1.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-
-if [ ! -d "/usr/lib/selenium" ]; then
-  sudo mkdir /usr/lib/selenium
-
-  echo "Created selenium directory in /usr/lib.\n"
-
-  echo "Getting selenium server standalone 3.0.1\n"
-  sudo wget http://selenium-release.storage.googleapis.com/3.0-beta3/selenium-server-standalone-3.0.1.jar
-  sudo mv selenium-server-standalone-3.0.1.jar /usr/lib/selenium/selenium-server-standalone-3.0.1.jar
-  sudo ln -s /usr/lib/selenium/selenium-server-standalone-3.0.1.jar /usr/lib/selenium/selenium-server-standalone.jar
-  echo "The selenium server standalone is ready in the server.\n"
-
-  sudo mkdir -p /var/log/selenium
-  sudo chmod a+w /var/log/selenium
-  echo "Created the logs for selenium.\n"
-
-  sudo cp selenium.sh /etc/init.d/selenium
-  sudo chmod 755 /etc/init.d/selenium
-  sudo update-rc.d selenium defaults 4445
-  echo "Installed selenium server.\n"
-  sudo /etc/init.d/selenium start
-else
-  echo "Selenium is installed.\nIf you want to update or install you will need:\n to run ./uninstall-selenium-server.sh first"
-fi
diff --git a/tests/tools/install-selenium-server/selenium.sh b/tests/tools/install-selenium-server/selenium.sh
deleted file mode 100644
index cf20ea7c..00000000
--- a/tests/tools/install-selenium-server/selenium.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash
-
-case "${1:-''}" in
-    'start')
-        if test -f /tmp/selenium.pid
-        then
-            echo "Selenium is already running."
-        else
-            java -jar /usr/lib/selenium/selenium-server-standalone.jar -port 4445 > /var/log/selenium/output.log 2> /var/log/selenium/error.log & echo $! > /tmp/selenium.pid
-            echo "[  OK  ] Starting Selenium on the 4445 port ..."
-
-            error=$?
-            if test $error -gt 0
-            then
-                echo "[ Error ] ${bon}Error $error! Could not start Selenium!${boff}"
-            fi
-        fi
-    ;;
-    'stop')
-        if test -f /tmp/selenium.pid
-        then
-            echo "Stopping Selenium..."
-            PID=`cat /tmp/selenium.pid`
-            kill -3 $PID
-            if kill -9 $PID ;
-                then
-                    sleep 2
-                    test -f /tmp/selenium.pid && rm -f /tmp/selenium.pid
-                else
-                    echo "[ Error ] Selenium could not be stopped ..."
-                fi
-        else
-            echo "[ Error ] Selenium is not running."
-        fi
-        ;;
-    'restart')
-        if test -f /tmp/selenium.pid
-        then
-            kill -HUP `cat /tmp/selenium.pid`
-            test -f /tmp/selenium.pid && rm -f /tmp/selenium.pid
-            sleep 1
-            java -jar /usr/lib/selenium/selenium-server-standalone.jar -port 4445 > /var/log/selenium/output.log 2> /var/log/selenium/error.log & echo $! > /tmp/selenium.pid
-            echo "[  OK  ] Reload Selenium on the 4445 port ..."
-        else
-            echo "[ Error ] Selenium isn't running..."
-        fi
-        ;;
-    *)      # no parameter specified
-        echo "Usage: $SELF start|stop|restart"
-        exit 1
-    ;;
-esac
diff --git a/tests/tools/install-selenium-server/uninstall-selenium-server.sh b/tests/tools/install-selenium-server/uninstall-selenium-server.sh
deleted file mode 100644
index e258800f..00000000
--- a/tests/tools/install-selenium-server/uninstall-selenium-server.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-if [ -d "/usr/lib/selenium" ]; then
-  sudo /etc/init.d/selenium stop
-  sudo rm -rf /usr/lib/selenium
-
-  echo "\nDeleted selenium.\n"
-
-  sudo rm -rf /var/log/selenium
-
-  echo "Deleted logs.\n"
-
-  sudo update-rc.d -f selenium remove
-  echo "Removed selenium server.\n"
-else
-  echo "You can not uninstall Selenium is NOT installed."
-fi
\ No newline at end of file
-- 
GitLab