Skip to content

Commit

Permalink
[ACS-8045] update chrome driver settings (#3862)
Browse files Browse the repository at this point in the history
* [ACS-8045]update ACA chrome driver

* [ACS-8045]update ACA chrome driver to stable

* [ACS-8045]update ACA chrome driver script

* [ACS-8045]revert chrome driver script

* update webdriver tesst

* Update action.yml

* update webdriver command

* update webdriver new script

* remove chrome install step

* remove chrome webdriver update twice

* add chrome webdriver update step

* e2e run command update

* e2e run command update

* e2e run command update

* remove temp e2e
  • Loading branch information
akashrathod28 committed May 31, 2024
1 parent c1851ae commit a98c81b
Show file tree
Hide file tree
Showing 8 changed files with 615 additions and 25 deletions.
24 changes: 12 additions & 12 deletions .github/actions/before-e2e/action.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
name: "Before e2e"
description: "Before e2e"

inputs:
e2e-protractor:
description: 'is e2e run with protractor'
required: false
type: boolean
default: false

runs:
using: "composite"
steps:
- name: Check content UP
shell: bash
run: ./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host $BASE_URL -u $ADMIN_EMAIL -p $ADMIN_PASSWORD || exit 1

- name: Install google chrome
- name: Install google chrome v114
shell: bash
run: |
wget -q https://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/google-chrome-stable_114.0.5735.106-1_amd64.deb
sudo apt install -y --allow-downgrades ./google-chrome-stable_114.0.5735.106-1_amd64.deb
wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
sudo ln -s /usr/bin/google-chrome /usr/bin/chrome
chrome --version
- name: Update webdriver-manager
if: ${{ inputs.e2e-protractor == 'true' }}
shell: bash
run: |
npm install -g webdriver-manager
if [ "$CI" = "true" ]; then
export chrome=$(google-chrome --product-version)
echo "Updating wevdriver-manager with chromedriver: $chrome."
webdriver-manager update --gecko=false --versions.chrome=$chrome
else
echo "Updating wedriver-manager with latest chromedriver, be sure to use evergreen Chrome."
webdriver-manager update --gecko=false
fi
npm run update-webdriver
10 changes: 8 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ jobs:
path: ./dist/content-ce
key: cache-dist-${{ github.run_id }}

- uses: ./.github/actions/before-e2e
- name: Before e2e
uses: ./.github/actions/before-e2e
with:
e2e-protractor: true

- uses: ./.github/actions/run-e2e
with:
Expand Down Expand Up @@ -194,7 +197,10 @@ jobs:
path: ./dist/content-ce
key: cache-dist-${{ github.run_id }}

- uses: ./.github/actions/before-e2e
- name: Before e2e
uses: ./.github/actions/before-e2e
with:
e2e-protractor: false

- name: before playwright
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build.release": "npm run build -- --configuration=production,release",
"test": "nx test",
"lint": "NODE_OPTIONS=--max_old_space_size=4096 nx run-many --all --target=lint",
"update-webdriver": "./scripts/update-webdriver.sh",
"update-webdriver": "./scripts/webdriver-update-newest/update-to-newest-webdriver.sh",
"e2e": "npm run update-webdriver && protractor $SUITE",
"inspect.bundle": "nx build content-ce --configuration production --stats-json && npx webpack-bundle-analyzer dist/content-ce/stats.json",
"prepare": "husky install",
Expand Down
10 changes: 0 additions & 10 deletions scripts/update-webdriver.sh

This file was deleted.

37 changes: 37 additions & 0 deletions scripts/webdriver-update-newest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Run protractor with newest webdriver locally

## Instruction
To download newest driver simply run script from its directory
`update-to-newest-webdriver.sh`

Command accepts one parameter to define what OS you are using. By default its set to `mac-x64`
Possible inputs `linux64, mac-arm64, mac-x64, win32, win64`

Example `./update-to-newest-webdriver.sh win64` - will set driver for windows

## How it works
1. The script removes your existing driver files from webdriver node_modules
2. Generates two new files (chrome_xml.js and update.js) that have updated methods needed to get the new driver
3. Replaces browser type depending on parameter
4. Copies and replaces the files to the webdriver node_modules
5. Executes command to to update-webdriver using updated code

## Troubleshooting
If the script fails for any reason. You can do some of these actions manually:
1. Find the two files (chrome_xml.js and update.js) in node_modules/webdriver-manager
2. Replace its contents with (chrome_xml_schema.js and update_schema.js) keep the original names.
3. Change version for specific OS in both files
chrome_xml.js -> ['platform'] == 'mac-x64' e.g. ['platform'] == 'win64' Line 70
update.js -> 'chromedriver-mac-x64' e.g 'chromedriver-win64' Line 240
4. Run standard command to update webdriver `./node_modules/webdriver-manager/bin/webdriver-manager update --gecko=false`



## Reason
Latest ChromeDriver Binaries https://googlechromelabs.github.io/chrome-for-testing/

Starting with M115 the latest Chrome + ChromeDriver releases per release channel (Stable, Beta, Dev, Canary) are available at the Chrome for Testing availability dashboard. For automated version downloading one can use the convenient JSON endpoints.
The older releases can be found at the Downloads page.


Note: Protractor is a depricated tool and this probably won't be fixed.
181 changes: 181 additions & 0 deletions scripts/webdriver-update-newest/chrome_xml_schema.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions scripts/webdriver-update-newest/update-to-newest-webdriver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo "Getting currently installed Chrome Version"

if [ "$CI" = "true" ]; then
chromeVersion=$(google-chrome --version )
else
chromeVersion=$(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version )
fi

chromeVersion=${chromeVersion:14:20}

echo "Intalling webdriver for version: $chromeVersion"

function show_error() {
echo -e "\e[31m===============================================================\e[0m"
echo -e "\e[31mFAILED TO UPDATE WEBDRIVER-MANAGER, PLEASE DO IT MANUALLY!\e[0m"
echo -e "\e[31mRun the following command (sometimes needs more than one kick):\e[0m"
echo -e ""
echo -e "\e[31mnpx webdriver-manager update --gecko=false\e[0m"
echo -e ""
echo -e "\e[31m===============================================================\e[0m"
}

ROOTDIR="$DIR/.."

if [ "$(uname)" == "Darwin" ]; then
BROWSER_TYPE="mac-x64"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
BROWSER_TYPE="linux64"
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
BROWSER_TYPE="win32"
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
BROWSER_TYPE="win64"
fi

echo "BROWSER => $BROWSER_TYPE"


PATH_TO_COMMANDS=./node_modules/webdriver-manager/built/lib/cmds
PATH_TO_BINARIES=./node_modules/webdriver-manager/built/lib/binaries
PATH_TO_SELENIUM=./node_modules/webdriver-manager/selenium

# Remove existing drivers
rm -rf $PATH_TO_SELENIUM/selenium-server-*
rm -rf $PATH_TO_SELENIUM/chromedriver-*
rm -f $PATH_TO_SELENIUM/chromedriver_*

# Replace browser type in file and create new file
echo 'Replacing new webdriver files'
sed "s/mac-x64/$BROWSER_TYPE/" $DIR/chrome_xml_schema.js > $DIR/chrome_xml.js && sed "s/mac-x64/$BROWSER_TYPE/" $DIR/update_schema.js > $DIR/update.js;

if [ "$?" -ne 0 ]; then
show_error
exit 0
fi

echo "============== Trying to update the files =============="
sleep 2

# Replace webdriver files
echo "cp -f $DIR/update.js $PATH_TO_COMMANDS/update.js"
cp -f $DIR/update.js $PATH_TO_COMMANDS/update.js
cp -f $DIR/chrome_xml.js $PATH_TO_BINARIES/chrome_xml.js

rm -f $DIR/update.js
rm -f $DIR/chrome_xml.js

node ./node_modules/webdriver-manager/bin/webdriver-manager update --gecko=false --versions.chrome=$chromeVersion


Loading

0 comments on commit a98c81b

Please sign in to comment.