playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Feature] Provide easy access to the Playwright version string

Open SineSwiper opened this issue 2 years ago • 1 comments

It would be nice to be able to access the current version of Playwright from the test code itself. For example, if I want to set a default userAgent from the default config, I can use a trick like this:

userAgent: devices['Desktop Chrome'].userAgent + " Playwright/1"

However, I don't have access to the Playwright version string, so the best I can do is put a major version there. Is there a property hidden somewhere that has the version string?

SineSwiper avatar May 24 '23 23:05 SineSwiper

@SineSwiper can you just do the following:

const pwVersion = require('@playwright/test/package.json').version;

aslushnikov avatar May 25 '23 00:05 aslushnikov

Yes, that does work.

Are there any merits to making either the UA suffix setting or Playwright version string acquiring easier to do?

SineSwiper avatar May 25 '23 18:05 SineSwiper

Are there any merits to making either the UA suffix setting or Playwright version string acquiring easier to do?

IMO playwright version is already easy to get, and consistent with the rest of NPM ecosystem. I'll close this then since there's no action required from the team.

aslushnikov avatar May 25 '23 20:05 aslushnikov