mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-22865 - Fixing webdriver version used and installed (#9749)
* Fixing webdriver version used and installed * Fixing webdriver selenium version * Disabling Code flow for grant password auth * Removing the install from the script as it's done in the postinstall now * It's funny how this tests work * Having codeflow disabled by default * Checking if Core tests pass * Refreshing as SSO button is broken after clicking apply
This commit is contained in:
@@ -141,15 +141,6 @@ done
|
||||
rm -rf ./e2e/downloads/
|
||||
rm -rf ./e2e-output/
|
||||
echo "====== BROWSER_RUN: $BROWSER_RUN ======"
|
||||
echo "====== Update webdriver-manager ====="
|
||||
if [ "$CI" = "true" ]; then
|
||||
export chrome=$(google-chrome --product-version)
|
||||
echo "Updating wedriver-manager with chromedriver: $chrome."
|
||||
./node_modules/protractor/bin/webdriver-manager update --gecko=false --versions.chrome=$chrome
|
||||
else
|
||||
echo "Updating wedriver-manager with latest chromedriver, be sure to use evergreen Chrome."
|
||||
./node_modules/protractor/bin/webdriver-manager update --gecko=false
|
||||
fi
|
||||
|
||||
export DEBUG_OPTION=''
|
||||
if [[ $DEBUG == "true" ]]; then
|
||||
|
18
scripts/update-webdriver.ps1
Normal file
18
scripts/update-webdriver.ps1
Normal file
@@ -0,0 +1,18 @@
|
||||
$dir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
|
||||
if ($env:CI -eq "true") {
|
||||
Write-Host "Updating webdriver-manager with chromedriver: $env:npm_package_config_chromeDriver."
|
||||
./node_modules/protractor/bin/webdriver-manager update --gecko=false --versions.chrome=$(google-chrome --product-version)
|
||||
} else {
|
||||
Write-Host "Updating webdriver-manager with latest chromedriver, be sure to use evergreen Chrome."
|
||||
npx webdriver-manager update --gecko=false
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "`n==============================================================="
|
||||
Write-Host "FAILED TO UPDATE WEBDRIVER-MANAGER, PLEASE DO IT MANUALLY!"
|
||||
Write-Host "Run the following command (sometimes needs more than one kick):"
|
||||
Write-Host ""
|
||||
Write-Host "npx webdriver-manager update --gecko=false"
|
||||
Write-Host ""
|
||||
Write-Host "==============================================================="
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const semver = require("semver");
|
||||
const config_1 = require("../config");
|
||||
const http_utils_1 = require("../http_utils");
|
||||
const config_source_1 = require("./config_source");
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
const semver = require('semver');
|
||||
const config_1 = require('../config');
|
||||
const http_utils_1 = require('../http_utils');
|
||||
const config_source_1 = require('./config_source');
|
||||
class ChromeXml extends config_source_1.XmlConfigSource {
|
||||
constructor() {
|
||||
super('chrome', config_1.Config.cdnUrls()['chrome']);
|
||||
@@ -12,8 +12,7 @@ class ChromeXml extends config_source_1.XmlConfigSource {
|
||||
getUrl(version) {
|
||||
if (version === 'latest') {
|
||||
return this.getLatestChromeDriverVersion();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return this.getSpecificChromeDriverVersion(version);
|
||||
}
|
||||
}
|
||||
@@ -21,16 +20,17 @@ class ChromeXml extends config_source_1.XmlConfigSource {
|
||||
* Get a list of chrome drivers paths available for the configuration OS type and architecture.
|
||||
*/
|
||||
getVersionList() {
|
||||
return this.getXml().then(xml => {
|
||||
return this.getXml().then((xml) => {
|
||||
let versionPaths = [];
|
||||
let osType = this.getOsTypeName();
|
||||
for (let content of xml.ListBucketResult.Contents) {
|
||||
let contentKey = content.Key[0];
|
||||
if (
|
||||
// Filter for 32-bit devices, make sure x64 is not an option
|
||||
(this.osarch.includes('64') || !contentKey.includes('64')) &&
|
||||
// Filter for 32-bit devices, make sure x64 is not an option
|
||||
(this.osarch.includes('64') || !contentKey.includes('64')) &&
|
||||
// Filter for x86 macs, make sure m1 is not an option
|
||||
((this.ostype === 'Darwin' && this.osarch === 'arm64') || !contentKey.includes('m1'))) {
|
||||
((this.ostype === 'Darwin' && this.osarch === 'arm64') || !contentKey.includes('m1'))
|
||||
) {
|
||||
// Filter for only the osType
|
||||
if (contentKey.includes(osType)) {
|
||||
versionPaths.push(contentKey);
|
||||
@@ -46,97 +46,96 @@ class ChromeXml extends config_source_1.XmlConfigSource {
|
||||
getOsTypeName() {
|
||||
// Get the os type name.
|
||||
if (this.ostype === 'Darwin') {
|
||||
return 'mac';
|
||||
}
|
||||
else if (this.ostype === 'Windows_NT') {
|
||||
return 'win';
|
||||
}
|
||||
else {
|
||||
return 'linux';
|
||||
return 'mac-x64';
|
||||
} else if (this.ostype === 'Windows_NT') {
|
||||
return 'win64';
|
||||
} else {
|
||||
return 'linux64';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the latest item from the XML.
|
||||
*/
|
||||
getLatestChromeDriverVersion() {
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const lastKnownGoodVersionsWithDownloads_Url = 'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json';
|
||||
return http_utils_1.requestBody(lastKnownGoodVersionsWithDownloads_Url).then(body => {
|
||||
const latestVersion_Body = JSON.parse(body)['channels']['Stable']
|
||||
const lastKnownGoodVersionsWithDownloads_Url =
|
||||
'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json';
|
||||
return http_utils_1.requestBody(lastKnownGoodVersionsWithDownloads_Url).then((body) => {
|
||||
const latestVersion_Body = JSON.parse(body)['channels']['Stable'];
|
||||
|
||||
const latestVersion = latestVersion_Body['version']
|
||||
const latestVersion_Url = latestVersion_Body['downloads']['chromedriver'].find(obj => obj['platform'] == 'mac-x64')['url']
|
||||
const latestVersion = latestVersion_Body['version'];
|
||||
const latestVersion_Url = latestVersion_Body['downloads']['chromedriver'].find((obj) => obj['platform'] == 'mac-x64')['url'];
|
||||
|
||||
const latestMajorVersion = latestVersion.split('.')[0]
|
||||
const latestMajorVersion = latestVersion.split('.')[0];
|
||||
|
||||
const localVersion_FileName = fs.readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
|
||||
.find(f => f.startsWith(`chromedriver_${latestMajorVersion}`)) || ''
|
||||
const localVersion_FileName =
|
||||
fs
|
||||
.readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
|
||||
.find((f) => f.startsWith(`chromedriver_${latestMajorVersion}`)) || '';
|
||||
|
||||
const localVersion = localVersion_FileName.slice(13, -4)
|
||||
const localVersion_Url = latestVersion_Url.replace(latestVersion, localVersion)
|
||||
const localVersion = localVersion_FileName.slice(13, -4);
|
||||
const localVersion_Url = latestVersion_Url.replace(latestVersion, localVersion);
|
||||
|
||||
const localMajorVersion = localVersion.split('.')[0]
|
||||
const localMajorVersion = localVersion.split('.')[0];
|
||||
|
||||
if (latestMajorVersion == localMajorVersion) {
|
||||
return Promise.resolve({
|
||||
url: localVersion_Url,
|
||||
version: localVersion,
|
||||
})
|
||||
version: localVersion
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve({
|
||||
url: latestVersion_Url,
|
||||
version: latestVersion,
|
||||
})
|
||||
version: latestVersion
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Gets a specific item from the XML.
|
||||
*/
|
||||
getSpecificChromeDriverVersion(inputVersion) {
|
||||
return this.getVersionList().then(list => {
|
||||
const specificVersion = getValidSemver(inputVersion);
|
||||
if (specificVersion === '') {
|
||||
throw new Error(`version ${inputVersion} ChromeDriver does not exist`);
|
||||
}
|
||||
let itemFound = '';
|
||||
for (let item of list) {
|
||||
// Get a semantic version.
|
||||
let version = item.split('/')[0];
|
||||
if (semver.valid(version) == null) {
|
||||
const lookUpVersion = getValidSemver(version);
|
||||
if (semver.valid(lookUpVersion)) {
|
||||
// Check to see if the specified version matches.
|
||||
if (lookUpVersion === specificVersion) {
|
||||
// When item found is null, check the os arch
|
||||
// 64-bit version works OR not 64-bit version and the path does not have '64'
|
||||
if (itemFound == '') {
|
||||
if (this.osarch === 'x64' ||
|
||||
(this.osarch !== 'x64' && !item.includes(this.getOsTypeName() + '64'))) {
|
||||
itemFound = item;
|
||||
}
|
||||
if (this.osarch === 'arm64' && this.ostype === 'Darwin' && item.includes('m1')) {
|
||||
itemFound = item;
|
||||
}
|
||||
}
|
||||
else if (this.osarch === 'x64') {
|
||||
// No win64 version exists, so even on x64 we need to look for win32
|
||||
const osTypeNameAndArch = this.getOsTypeName() + (this.getOsTypeName() === 'win' ? '32' : '64');
|
||||
if (item.includes(osTypeNameAndArch)) {
|
||||
itemFound = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemFound == '') {
|
||||
return { url: '', version: inputVersion };
|
||||
}
|
||||
else {
|
||||
return { url: config_1.Config.cdnUrls().chrome + itemFound, version: inputVersion };
|
||||
getSpecificChromeDriverVersion(versionRequired) {
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
let baseTagVersion = versionRequired.split('.');
|
||||
baseTagVersion.splice(-1);
|
||||
baseTagVersion = baseTagVersion.join('.');
|
||||
|
||||
const lastKnownGoodVersionsWithDownloads_Url =
|
||||
'https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json';
|
||||
return http_utils_1.requestBody(lastKnownGoodVersionsWithDownloads_Url).then((body) => {
|
||||
const version_Body = JSON.parse(body)['builds'][baseTagVersion];
|
||||
|
||||
const opSys = this.getOsTypeName();
|
||||
|
||||
const currentVersion = version_Body['version'];
|
||||
const currentVersion_Url = version_Body['downloads']['chromedriver'].find((obj) => obj['platform'] == opSys)['url'];
|
||||
|
||||
const latestMajorVersion = currentVersion.split('.')[0];
|
||||
|
||||
const localVersion_FileName =
|
||||
fs
|
||||
.readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
|
||||
.find((f) => f.startsWith(`chromedriver_${latestMajorVersion}`)) || '';
|
||||
|
||||
const localVersion = localVersion_FileName.slice(13, -4);
|
||||
const localVersion_Url = currentVersion_Url.replace(currentVersion, localVersion);
|
||||
|
||||
const localMajorVersion = localVersion.split('.')[0];
|
||||
|
||||
if (latestMajorVersion == localMajorVersion) {
|
||||
return Promise.resolve({
|
||||
url: localVersion_Url,
|
||||
version: localVersion
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve({
|
||||
url: currentVersion_Url,
|
||||
version: currentVersion
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -163,8 +162,7 @@ function getValidSemver(version) {
|
||||
if (exec) {
|
||||
lookUpVersion = exec[1] + '.0';
|
||||
}
|
||||
}
|
||||
catch (_) {
|
||||
} catch (_) {
|
||||
// no-op: is this is not valid, do not throw here.
|
||||
}
|
||||
// This supports downloading 74.0.3729.6
|
||||
@@ -174,8 +172,7 @@ function getValidSemver(version) {
|
||||
if (exec) {
|
||||
lookUpVersion = exec[1];
|
||||
}
|
||||
}
|
||||
catch (_) {
|
||||
} catch (_) {
|
||||
// no-op: if this does not work, use the other regex pattern.
|
||||
}
|
||||
return lookUpVersion;
|
||||
|
@@ -1,12 +1,50 @@
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
BROWSER_TYPE=mac-x64
|
||||
#!/usr/bin/env bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
if [ ! -z "$1" ]; then BROWSER_TYPE=$1 ; fi
|
||||
echo "Getting currently installed Chrome Version"
|
||||
|
||||
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
|
||||
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 "====== WINDOWS USERS : PLEASE RUN THIS COMMAND: "
|
||||
echo -e "npm run update-webdriver:windows"
|
||||
echo -e "====== WINDOWS USERS ADVISORY END =================="
|
||||
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-*
|
||||
@@ -14,16 +52,25 @@ rm -rf $PATH_TO_SELENIUM/chromedriver-*
|
||||
rm -f $PATH_TO_SELENIUM/chromedriver_*
|
||||
|
||||
# Replace browser type in file and create new file
|
||||
sed "s/mac-x64/$BROWSER_TYPE/" chrome_xml_schema.js > chrome_xml.js
|
||||
sed "s/mac-x64/$BROWSER_TYPE/" update_schema.js > update.js
|
||||
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
|
||||
cp -f update.js $PATH_TO_COMMANDS/update.js
|
||||
cp -f chrome_xml.js $PATH_TO_BINARIES/chrome_xml.js
|
||||
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
|
||||
|
||||
rm -f update.js
|
||||
rm -f chrome_xml.js
|
||||
|
||||
#$(npm bin)/webdriver-manager update --gecko=false
|
||||
node ../../node_modules/webdriver-manager/bin/webdriver-manager update --gecko=false
|
Reference in New Issue
Block a user