FTR: upgrade chromedriver to 75 (#40791)

* ftr: update services to support chromedriver 75

* [services/webdriver] add browser logging

* update comment for W3C scrolling bug
This commit is contained in:
Dmitry Lemeshko 2019-07-12 19:49:51 +02:00 committed by GitHub
parent 8416635570
commit df9d8e6f5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 71 deletions

View file

@ -352,7 +352,7 @@
"chance": "1.0.18",
"cheerio": "0.22.0",
"chokidar": "3.0.1",
"chromedriver": "^74.0.0",
"chromedriver": "^75.1.0",
"classnames": "2.2.6",
"dedent": "^0.7.0",
"delete-empty": "^2.0.0",
@ -425,7 +425,7 @@
"proxyquire": "1.8.0",
"regenerate": "^1.4.0",
"sass-lint": "^1.12.1",
"selenium-webdriver": "^4.0.0-alpha.1",
"selenium-webdriver": "^4.0.0-alpha.4",
"simple-git": "1.116.0",
"sinon": "^7.2.2",
"strip-ansi": "^3.0.1",

View file

@ -37,7 +37,7 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
const isW3CEnabled = (driver as any).executor_.w3c === true;
if (!isW3CEnabled) {
if (browserType === Browsers.Chrome) {
// The logs endpoint has not been defined in W3C Spec browsers other than Chrome don't have access to this endpoint.
// See: https://github.com/w3c/webdriver/issues/406
// See: https://w3c.github.io/webdriver/#endpoints
@ -171,40 +171,33 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
xOffset?: number,
yOffset?: number
): Promise<void> {
switch (this.browserType) {
case Browsers.Firefox: {
// Workaround for scrolling bug in Firefox
// https://github.com/mozilla/geckodriver/issues/776
if (this.isW3CEnabled) {
// Workaround for scrolling bug in W3C mode: move pointer to { x: 0, y: 0 }
// https://github.com/mozilla/geckodriver/issues/776
await this.getActions()
.move({ x: 0, y: 0 })
.perform();
if (element instanceof WebElementWrapper) {
await this.getActions()
.move({ x: 0, y: 0 })
.move({ x: xOffset || 10, y: yOffset || 10, origin: element._webElement })
.perform();
} else {
await this.getActions()
.move({ origin: { x: xOffset, y: yOffset } })
.perform();
if (element instanceof WebElementWrapper) {
await this.getActions()
.move({ x: xOffset || 10, y: yOffset || 10, origin: element._webElement })
.perform();
} else {
await this.getActions()
.move({ origin: { x: xOffset, y: yOffset } })
.perform();
}
break;
}
case Browsers.Chrome: {
if (element instanceof WebElementWrapper) {
await this.getActions()
.pause(this.getActions().mouse)
.move({ origin: element._webElement })
.perform();
} else {
await this.getActions()
.pause(this.getActions().mouse)
.move({ origin: { x: xOffset, y: yOffset } })
.perform();
}
break;
} else {
if (element instanceof WebElementWrapper) {
await this.getActions()
.pause(this.getActions().mouse)
.move({ origin: element._webElement })
.perform();
} else {
await this.getActions()
.pause(this.getActions().mouse)
.move({ origin: { x: xOffset, y: yOffset } })
.perform();
}
default:
throw new Error(`unsupported browser: ${this.browserType}`);
}
}

View file

@ -28,13 +28,17 @@ export async function RemoteProvider({ getService }: FtrProviderContext) {
const browserType: Browsers = config.get('browser.type');
const { driver, By, Key, until, LegacyActionSequence } = await initWebDriver(log, browserType);
const isW3CEnabled = (driver as any).executor_.w3c;
const caps = await driver.getCapabilities();
const browserVersion = caps.get(browserType === Browsers.Chrome ? 'version' : 'browserVersion');
const browserVersion = caps.get(isW3CEnabled ? 'browserVersion' : 'version');
log.info(`Remote initialized: ${caps.get('browserName')} ${browserVersion}`);
if (browserType === Browsers.Chrome) {
log.info(`Chromedriver version: ${caps.get('chrome').chromedriverVersion}`);
log.info(
`Chromedriver version: ${caps.get('chrome').chromedriverVersion}, w3c=${isW3CEnabled}`
);
}
lifecycle.on('beforeTests', async () => {

View file

@ -22,7 +22,7 @@ import { delay } from 'bluebird';
import chromeDriver from 'chromedriver';
// @ts-ignore types not available
import geckoDriver from 'geckodriver';
import { Builder, By, Key, logging, until } from 'selenium-webdriver';
import { Builder, Capabilities, By, Key, logging, until } from 'selenium-webdriver';
// @ts-ignore types not available
import chrome from 'selenium-webdriver/chrome';
// @ts-ignore types not available
@ -64,18 +64,28 @@ async function attemptToCreateCommand(log: ToolingLog, browserType: Browsers) {
const buildDriverInstance = async () => {
switch (browserType) {
case 'chrome':
const chromeOptions = new chrome.Options();
const loggingPref = new logging.Preferences();
loggingPref.setLevel(logging.Type.BROWSER, logging.Level.ALL);
chromeOptions.setLoggingPrefs(loggingPref);
const chromeCapabilities = Capabilities.chrome();
const chromeOptions = [
'disable-translate',
'new-window',
'no-sandbox',
'allow-file-access-from-files',
'use-fake-device-for-media-stream',
'use-fake-ui-for-media-stream',
];
if (process.env.TEST_BROWSER_HEADLESS) {
// Use --disable-gpu to avoid an error from a missing Mesa library, as per
// See: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
chromeOptions.addArguments('headless', 'disable-gpu');
chromeOptions.push('headless', 'disable-gpu');
}
chromeCapabilities.set('goog:chromeOptions', {
w3c: false,
args: chromeOptions,
});
chromeCapabilities.set('goog:loggingPrefs', { browser: 'ALL' });
return new Builder()
.forBrowser(browserType)
.setChromeOptions(chromeOptions)
.withCapabilities(chromeCapabilities)
.setChromeService(new chrome.ServiceBuilder(chromeDriver.path).enableVerboseLogging())
.build();
case 'firefox':

View file

@ -8071,12 +8071,12 @@ chrome-trace-event@^1.0.0:
dependencies:
tslib "^1.9.0"
chromedriver@^74.0.0:
version "74.0.0"
resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-74.0.0.tgz#a060308ac858918aa445efb85428ee25dfc76183"
integrity sha512-xXgsq0l4gVTY9X5vuccOSVj/iEBm3Bf5MIwzSAASIRJagt4BlWw77SxQq1f4JAJ35/9Ys4NLMA/kWFbd7A/gfQ==
chromedriver@^75.1.0:
version "75.1.0"
resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-75.1.0.tgz#edfef5d7a9b16b6f8a12ddb58cbac76ae52732fd"
integrity sha512-N2P0fg6FS4c+tTG0R7cCOD5qiVo+E6uAz6xVjmbZesYv1xs1iGdcCUo0IqOY+ppD/4OOObG+XWV1CFWXT6UIgA==
dependencies:
del "^3.0.0"
del "^4.1.1"
extract-zip "^1.6.7"
mkdirp "^0.5.1"
request "^2.88.0"
@ -10171,18 +10171,6 @@ del@^2.0.2:
pinkie-promise "^2.0.0"
rimraf "^2.2.8"
del@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/del/-/del-3.0.0.tgz#53ecf699ffcbcb39637691ab13baf160819766e5"
integrity sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU=
dependencies:
globby "^6.1.0"
is-path-cwd "^1.0.0"
is-path-in-cwd "^1.0.0"
p-map "^1.1.1"
pify "^3.0.0"
rimraf "^2.2.8"
del@^4.0.0, del@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/del/-/del-4.1.1.tgz#9e8f117222ea44a31ff3a156c049b99052a9f0b4"
@ -17537,10 +17525,10 @@ jsx-ast-utils@^2.1.0:
dependencies:
array-includes "^3.0.3"
jszip@^3.1.3:
version "3.2.0"
resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.2.0.tgz#1c179e8692777490ca4e9b8f3ced08f9b820da2c"
integrity sha512-4WjbsaEtBK/DHeDZOPiPw5nzSGLDEDDreFRDEgnoMwmknPjTqa+23XuYFk6NiGbeiAeZCctiQ/X/z0lQBmDVOQ==
jszip@^3.1.5:
version "3.2.2"
resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.2.2.tgz#b143816df7e106a9597a94c77493385adca5bd1d"
integrity sha512-NmKajvAFQpbg3taXQXr/ccS2wcucR1AZ+NtyWp2Nq7HHVsXhcJFR8p0Baf32C2yVvBylFWVeKf+WI2AnvlPhpA==
dependencies:
lie "~3.3.0"
pako "~1.0.2"
@ -25073,15 +25061,15 @@ select@^1.1.2:
resolved "https://registry.yarnpkg.com/select/-/select-1.1.2.tgz#0e7350acdec80b1108528786ec1d4418d11b396d"
integrity sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=
selenium-webdriver@^4.0.0-alpha.1:
version "4.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/selenium-webdriver/-/selenium-webdriver-4.0.0-alpha.1.tgz#cc93415e21d2dc1dfd85dfc5f6b55f3ac53933b1"
integrity sha512-z88rdjHAv3jmTZ7KSGUkTvo4rGzcDGMq0oXWHNIDK96Gs31JKVdu9+FMtT4KBrVoibg8dUicJDok6GnqqttO5Q==
selenium-webdriver@^4.0.0-alpha.4:
version "4.0.0-alpha.4"
resolved "https://registry.yarnpkg.com/selenium-webdriver/-/selenium-webdriver-4.0.0-alpha.4.tgz#73694490e02c941d9d0bf7a36f7c49beb9372512"
integrity sha512-etJt20d8qInkxMAHIm5SEpPBSS+CdxVcybnxzSIB/GlWErb8pIWrArz/VA6VfUW0/6tIcokepXQ5ufvdzqqk1A==
dependencies:
jszip "^3.1.3"
rimraf "^2.5.4"
jszip "^3.1.5"
rimraf "^2.6.3"
tmp "0.0.30"
xml2js "^0.4.17"
xml2js "^0.4.19"
selfsigned@^1.10.4:
version "1.10.4"
@ -29841,7 +29829,7 @@ xml-parse-from-string@^1.0.0:
resolved "https://registry.yarnpkg.com/xml-parse-from-string/-/xml-parse-from-string-1.0.1.tgz#a9029e929d3dbcded169f3c6e28238d95a5d5a28"
integrity sha1-qQKekp09vN7RafPG4oI42VpdWig=
xml2js@^0.4.17, xml2js@^0.4.19, xml2js@^0.4.5:
xml2js@^0.4.19, xml2js@^0.4.5:
version "0.4.19"
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.19.tgz#686c20f213209e94abf0d1bcf1efaa291c7827a7"
integrity sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==