Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: add CI to default user agent (#15450)
Max Schmitt86a65a03e4ab
diff --git a/packages/playwright-core/src/common/userAgent.ts b/packages/playwright-core/src/common/userAgent.tsindex f335220634..c2e7dd825b 100644--- a/packages/playwright-core/src/common/userAgent.ts+++ b/packages/playwright-core/src/common/userAgent.ts@@ -57,9 +57,13 @@ function determineUserAgent(): string {osIdentifier = 'linux';}}+ const additionalTokens = [];+ if (process.env.CI)+ additionalTokens.push('CI/1');+ const serializedTokens = additionalTokens.length ? ' ' + additionalTokens.join(' ') : '';const { langName, langVersion } = getClientLanguage();- return `Playwright/${getPlaywrightVersion()} (${os.arch()}; ${osIdentifier} ${osVersion}) ${langName}/${langVersion}`;+ return `Playwright/${getPlaywrightVersion()} (${os.arch()}; ${osIdentifier} ${osVersion}) ${langName}/${langVersion}${serializedTokens}`;}export function getClientLanguage(): { langName: string, langVersion: string } {diff --git a/tests/library/global-fetch.spec.ts b/tests/library/global-fetch.spec.tsindex 3cff96d81f..f62880dd67 100644--- a/tests/library/global-fetch.spec.ts+++ b/tests/library/global-fetch.spec.ts@@ -189,14 +189,19 @@ it('should set playwright as user-agent', async ({ playwright, server, isWindows.replace(getPlaywrightVersion(), 'X.X.X').replace(/\d+/g, 'X');+ const tokens = [];+ if (process.env.CI)+ tokens.push('CI/X');+ const suffix = tokens.length ? ` ${tokens.join(' ')}` : '';+if (isWindows)- expect(userAgentMasked).toBe('Playwright/X.X.X (<ARCH>; windows X.X) node/X.X');+ expect(userAgentMasked).toBe('Playwright/X.X.X (<ARCH>; windows X.X) node/X.X' + suffix);else if (isLinux)// on ubuntu: distro is 'ubuntu' and version is 'X.X'// on manjaro: distro is 'Manjaro' and version is 'unknown'- expect(userAgentMasked.replace(/<ARCH>; \w+ [^)]+/, '<ARCH>; distro version')).toBe('Playwright/X.X.X (<ARCH>; distro version) node/X.X');+ expect(userAgentMasked.replace(/<ARCH>; \w+ [^)]+/, '<ARCH>; distro version')).toBe('Playwright/X.X.X (<ARCH>; distro version) node/X.X' + suffix);else if (isMac)- expect(userAgentMasked).toBe('Playwright/X.X.X (<ARCH>; macOS X.X) node/X.X');+ expect(userAgentMasked).toBe('Playwright/X.X.X (<ARCH>; macOS X.X) node/X.X' + suffix);});it('should be able to construct with context options', async ({ playwright, browserType, server }) => {