Skip to content

fix(webdriverio): get absolute paths using native path.resolve#14793

Merged
christian-bromann merged 1 commit intowebdriverio:mainfrom
macarie:fix/absolute-path-on-windows
Nov 29, 2025
Merged

fix(webdriverio): get absolute paths using native path.resolve#14793
christian-bromann merged 1 commit intowebdriverio:mainfrom
macarie:fix/absolute-path-on-windows

Conversation

@macarie
Copy link
Contributor

@macarie macarie commented Sep 29, 2025

Proposed changes

Fixes #14780.

Use native path.resolve to get the absolute path for the given argument as it handles all the edge-cases the previous implementation did not, while maintaining the same behavior:

If, after processing all given path segments, an absolute path has not yet been generated, the current working directory is used.
[...]
If no path segments are passed, path.resolve() will return the absolute path of the current working directory.

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Backport Request

//: # (The current main branch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against the v8 branch.)

  • This change is solely for v9 and doesn't need to be back-ported
  • Back-ported PR at #XXXXX

Further comments

Reviewers: @webdriverio/project-committers

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 29, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: macarie / name: Raul Macarie (0af55f4)

@macarie macarie force-pushed the fix/absolute-path-on-windows branch 2 times, most recently from d3b5508 to d4ae8cf Compare September 29, 2025 20:34
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

I don't think there is a point in having a getAbsoluteFilepath function. We should just remove its usage and replace it with path.resolve.

@macarie macarie force-pushed the fix/absolute-path-on-windows branch from d4ae8cf to 0af55f4 Compare September 30, 2025 21:37
@macarie
Copy link
Contributor Author

macarie commented Sep 30, 2025

@christian-bromann, removed and used path.resolve directly.

Other than the test in packages/webdriverio/tests/commands/element/saveScreenshot.test.ts (where path.resolve seems to be called ~1k times - not sure why it differs from the rest), everything else stayed the same.

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@christian-bromann christian-bromann merged commit 0072913 into webdriverio:main Nov 29, 2025
3 checks passed
@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: Incorrect detection of absolute paths on Windows when saving screenshots or other artifacts

2 participants