Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: improve get info #4890

Open
wants to merge 5 commits into
base: 3.x
Choose a base branch
from
Open

cli: improve get info #4890

wants to merge 5 commits into from

Conversation

kobenguyent
Copy link
Collaborator

Motivation/Description of the PR

➜  helloworld npx codeceptjs info
 Environment information: 

codeceptVersion:  "3.7.2"
nodeInfo:  18.19.0
osInfo:  macOS 14.4
cpuInfo:  (8) x64 Apple M1 Pro
osBrowsers:  "chrome: 133.0.6943.143, edge: 133.0.3065.92, firefox: not installed, safari: 17.4"
playwrightBrowsers:  "chromium: 133.0.6943.16, firefox: 134.0, webkit: 18.2"
helpers:  {
 "Playwright": {
  "url": "http://localhost",
...

Applicable helpers:

  • Playwright
  • Puppeteer
  • WebDriver
  • REST
  • FileHelper
  • Appium
  • TestCafe

Applicable plugins:

  • allure
  • autoDelay
  • autoLogin
  • customLocator
  • pauseOnFail
  • coverage
  • retryFailedStep
  • screenshotOnFail
  • selenoid
  • stepByStepReport
  • stepTimeout
  • wdio
  • subtitles

Type of change

  • 🔥 Breaking changes
  • 🚀 New functionality
  • 🐛 Bug fix
  • 🧹 Chore
  • 📋 Documentation changes/updates
  • ♨️ Hot fix
  • 🔨 Markdown files fix - not related to source code
  • 💅 Polish code

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

Copy link
Contributor

@DavertMik DavertMik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better not to launch browsers
But check otherwise

const browsers = await Promise.all(
['chromium', 'firefox', 'webkit'].map(async browser => {
try {
const browserInstance = await playwright[browser].launch()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, launching them seems as too much
can we check them without launching?

Can we do it with this: https://playwright.dev/docs/api/class-browsertype#browser-type-executable-path

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one just returns something like this not the version /Library/Caches/ms-playwright/chromium-1155/chrome-mac/Chromium.app/Contents/MacOS/Chromium

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/microsoft/playwright/blob/main/packages/playwright-core/browsers.json exists and contains current browser versions.
I have it installed in ./node_modules/.pnpm/[email protected]/node_modules/playwright-core/browsers.json.
But not sure how easily/universally get that file on various platforms (OS and npm vs. pnpm)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/microsoft/playwright/blob/main/packages/playwright-core/browsers.json exists and contains current browser versions

But it's for all browsers and there is no info that the browser was really installed. So it's probably useless.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-Pilot advised me this (and it works). Tested in TypeScript.

import { chromium, firefox, webkit } from "playwright";
import { execSync } from "child_process";

This returns Chromium 133.0.6943.16

const chromeVersion = execSync(
    `"${chromium.executablePath()}" --version`
)
    .toString()
    .trim();

The same way works for Firefox (e.g. Mozilla Firefox 134.0)

const firefoxVersion = execSync(
    `"${firefox.executablePath()}" --version`
)
    .toString()
    .trim();

Unfortunately if you use the same way for WebKit, you get only WebKitGTK 2.47.2 (unknown) and not the more common "Safari" version (e.g. 18.2)

const webkitVersion = execSync(`"${webkit.executablePath()}" --version`)
    .toString()
    .trim();

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, I'm not sure if there are easy ways to handle this unless we launch the browsers and get the version.

what do you think we just return the webkit path to acknowledge this webkit browser is available from playwright?
@DavertMik @mirao

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for me displaying of Chromium/Firefox version would be great as they change quite often with every Playwright release and as for WebKit any string/build is enough as Safari version doesn't change too often.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's see how the playwright team proposes then -> microsoft/playwright#35123

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 Environment information: 

codeceptVersion:  "3.7.2"
nodeInfo:  18.19.0
osInfo:  macOS 14.4
cpuInfo:  (8) x64 Apple M1 Pro
osBrowsers:  "chrome: 134.0.6998.45, edge: 134.0.3124.51, firefox: not installed, safari: 17.4"
playwrightBrowsers:  "chromium: 134.0.6998.35, firefox: 135.0, webkit: 18.4"
helpers:  {
 "Playwright": {
  "browser": "chromium",

worked like a charm for now @DavertMik @mirao

@kobenguyent kobenguyent requested review from DavertMik, mirao and thomashohn and removed request for mirao March 11, 2025 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants