feat: do not attach prefs when debuggerAddress is specified (#14634)
This commit is contained in:
parent
04f7c4e0ba
commit
b4e3884ea7
3 changed files with 33 additions and 2 deletions
|
|
@ -15,7 +15,7 @@ import type { InstallOptions } from '@puppeteer/browsers'
|
|||
|
||||
import type { Capabilities } from '@wdio/types'
|
||||
|
||||
import { parseParams, setupPuppeteerBrowser, setupChromedriver, getCacheDir } from './utils.js'
|
||||
import { parseParams, setupPuppeteerBrowser, setupChromedriver, getCacheDir, generateDefaultPrefs } from './utils.js'
|
||||
import { isChrome, isFirefox, isEdge, isSafari, isAppiumCapability } from '../utils.js'
|
||||
import { SUPPORTED_BROWSERNAMES } from '../constants.js'
|
||||
|
||||
|
|
@ -84,8 +84,10 @@ export async function startWebDriver (options: Capabilities.RemoteConfig) {
|
|||
? { executablePath: chromedriverBinary }
|
||||
: await setupChromedriver(cacheDir, browserVersion)
|
||||
|
||||
const prefs = generateDefaultPrefs(caps)
|
||||
caps['goog:chromeOptions'] = deepmerge(
|
||||
{ binary: chromeExecuteablePath, prefs: { 'profile.password_manager_leak_detection': false } },
|
||||
{ binary: chromeExecuteablePath },
|
||||
prefs,
|
||||
caps['goog:chromeOptions'] || {}
|
||||
)
|
||||
chromedriverOptions.allowedOrigins = chromedriverOptions.allowedOrigins || ['*']
|
||||
|
|
|
|||
|
|
@ -323,3 +323,9 @@ export function setupGeckodriver (cacheDir: string, driverVersion?: string) {
|
|||
export function setupEdgedriver (cacheDir: string, driverVersion?: string) {
|
||||
return downloadEdgedriver(driverVersion, cacheDir)
|
||||
}
|
||||
|
||||
export function generateDefaultPrefs(caps: WebdriverIO.Capabilities) {
|
||||
return caps['goog:chromeOptions']?.debuggerAddress
|
||||
? {}
|
||||
: { prefs: { 'profile.password_manager_leak_detection': false } }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,6 +226,29 @@ describe('startWebDriver', () => {
|
|||
)
|
||||
})
|
||||
|
||||
it('should start driver with no prefs if debuggerAddress is set', async () => {
|
||||
const options = {
|
||||
capabilities: {
|
||||
browserName: 'chrome',
|
||||
'goog:chromeOptions': { debuggerAddress: 'localhost:9222' }
|
||||
} as any
|
||||
}
|
||||
const res = await startWebDriver(options)
|
||||
expect(Boolean(res?.stdout)).toBe(true)
|
||||
expect(options).toEqual({
|
||||
hostname: 'localhost',
|
||||
port: 1234,
|
||||
capabilities: {
|
||||
browserName: 'chrome',
|
||||
'goog:chromeOptions': {
|
||||
// no prefs should be set in this case
|
||||
binary: expect.any(String),
|
||||
debuggerAddress: 'localhost:9222'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should start no driver or download chrome if binaries are defined', async () => {
|
||||
const options = {
|
||||
capabilities: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue