Skip to content

New Major Release#830

Merged
wswebcreation merged 14 commits intomainfrom
ws/new-major-releases
Apr 18, 2025
Merged

New Major Release#830
wswebcreation merged 14 commits intomainfrom
ws/new-major-releases

Conversation

@wswebcreation
Copy link
Copy Markdown
Member

@wswebcreation wswebcreation commented Apr 5, 2025

💥 BREAKING CHANGES

🔍 Viewport Screenshot Logic Reworked for Mobile Web & Hybrid Apps

What was the problem?

Screenshots for mobile devices were inconsistent due to platform differences. iOS captures the entire device screen (including status and address bars), while Android (using ChromeDriver) only captures the webview, unless the capability "appium:nativeWebScreenshot": true is used.

What changed?

We’ve reimplemented the logic to correctly handle both platforms by default.
This fix addresses [#747](#747).

💡 Credit to Benjamin Karran (@ebekebe) for pointing us in the right direction to improve this logic!

What’s the advantage?

✅ More accurate full-page and element screenshots on both Android and iOS.
⚠️ But this change may break your current baselines, especially on Android and iOS.


🍏 iOS Element Screenshot Strategy Changed

What was the problem?

iOS element screenshots were previously cut from full-device screenshots, which could lead to misalignment or off-by-a-few-pixels issues.

What changed?

We now use the element screenshot endpoint directly.

What’s the advantage?

✅ More accurate iOS element screenshots.
⚠️ But again, this may affect your existing baselines.


🖥️ New Full-Page Screenshot Strategy for Desktop Web

What was the problem?

The "previous" scroll-and-stitch method simulated user interaction by scrolling the page, waiting, taking a screenshot, and repeating until the entire page was captured.
This works well for lazy-loaded content, but it is slow and unstable on other pages.

What changed?

We now use WebDriver BiDi’s [[browsingContext.captureScreenshot](https://webdriver.io/docs/api/webdriverBidi#browsingcontextcapturescreenshot)] to capture full-page screenshots in one go. This is the new default strategy for desktop web browsers.

📌 Mobile platforms (iOS/Android) still use the scroll-and-stitch approach for now.

What’s the advantage?

✅ Execution time reduced by 50%+
✅ Logic is greatly simplified
✅ More consistent and stable results on static or non-lazy pages
📸 Example

Still want the old scroll-and-stitch behavior or need fullpage screenshots for pages who have lazy-loading?

Use the userBasedFullPageScreenshot option to simulate user-like scrolling. This remains the better choice for pages with lazy-loading:

// wdio.conf.ts
services: [
  ["visual", {
    userBasedFullPageScreenshot: true
  }]
]

Or per test:

await expect(browser).toMatchFullPageSnapshot('homepage', {
  userBasedFullPageScreenshot: true,
})

💅 Polish

⚠️ Deprecated Root-Level Compare Options

What was the problem?

Compare options were allowed at the root level of the service config, making them harder to group or discover.

What changed?

You now get a warning if you still use root-level keys. Please move them under the compareOptions property instead.

Example warning:

WARN The following root-level compare options are deprecated and should be moved under 'compareOptions':
  - blockOutStatusBar
  - ignoreColors
In the next major version, these options will be removed from the root level.

📘 See: [compareOptions docs](https://webdriver.io/docs/visual-testing/service-options#compare-options)


🐛 Bug Fixes


🔧 Other

  • 🆙 Updated dependencies
  • 🧪 Improved test coverage
  • 📸 Refreshed image baselines

* chore: update deps

* chore: revert major eslint

* feat: initial setup for device layer calculations

- this is work in progress

* chore: fixed some stuff and updated some broken UT's

* fix: right import and export

* fix: fix mocks

* chore: optimise code a bit and add docs

* chore: fix linking and types

* fix: fix return data from overlay

* feat: add Android support for blockouts based on device rectangles

* feat: support ios and android for checkScreen

- simplify determineStatusAddressToolBarRectangles
- reduce rectangle tests
- fix data url loading in Safari

* feat: add checkElement support

* fix: optimise code and fix UTs for element

* feat: support savefullpagescreenshot with new viewport data for Android

* feat: support fullpage for iOS portrait

* test: fix tests

* fix: multiple fixes for fullpage

- iOS had issues on landscape
- removed not needed code and files

* chore: remove logs

* fix: fix Android Appium 1 issues

- add fallback
- remove logs
- update images for android phones

* chore: update iOS stuff

- add LANDSCAPE for local android

* chore: updated safari desktop screenshots

* test: update snapshots

* feat: move the new logic to the webdriver-image-comparison module

* fix: fix unit tests

* breaking: taking element screenshot for iOS

- some other small fixes

* chore: optimise deviceRectangles

- remove devicePlatformRect
- enrich deviceRectangles with statusBar and homeBar
- change devicePlatformRect output to x/y instead of left/top to match a coordinate system
- fix UTs

* chore: refactor stuff

- rename function
- add screendata for deviceRectangles

* chore: improve readability for vars in utils

* chore: update baseline and workflow

* chore: last image updates
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 5, 2025

🦋 Changeset detected

Latest commit: 348ef0e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
webdriver-image-comparison Major
@wdio/visual-service Major
@wdio/visual-reporter Patch
@wdio/ocr-service Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Member

@erwinheitzman erwinheitzman left a comment

Choose a reason for hiding this comment

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

Love the feature but I have to say it's a lot of code to go through that does a lot of things differently from what I would expect so it was a bit of a tough cookie but I hope the review adds value nonetheless 👍

Comment thread packages/webdriver-image-comparison/src/methods/screenshots.test.ts
Comment thread packages/webdriver-image-comparison/src/helpers/utils.ts Outdated
Comment thread packages/webdriver-image-comparison/src/helpers/utils.ts
Comment thread packages/visual-service/tests/utils.test.ts
* feat: add viewport context manager

* feat: add new context manager

- revert old one
- add a wrapper for each command that checks for changes
- fix screensizes when the orientation changes and provide better fallback

There is a TODO regarding Multiremote on the global browser

* chore: fix UT's

* chore: add a last test

* feat: enhance context manager

- add mobile context
- add wrapper per command
- add and fix UT's

* fix: multiple fixes

- fix capabilities, should be requested
- assumed that the `'mobile: deviceInfo` didn't return landscape info
- added new images for android

* fix: reset orientation

* Fix: fix iOS orientation and make it generic

* chore: new iOS images

* fix: support proper appium cap present

- add new images
- add nativeWebScreenshot for proper webviews screenshots

* test: add iOS for webview tests

- add new images

* fix: fix tests
* feat: add bidi fullpage screenshot support

* chore: code optimizations

* chore: add changeset
@wswebcreation wswebcreation marked this pull request as ready for review April 14, 2025 07:26
wswebcreation and others added 6 commits April 14, 2025 09:29
* feat: deprecate root compare options

* chore: add changeset

* Update packages/webdriver-image-comparison/src/helpers/options.ts

Co-authored-by: alcpereira <[email protected]>

* Update packages/webdriver-image-comparison/src/helpers/utils.ts

Co-authored-by: alcpereira <[email protected]>

* Update packages/webdriver-image-comparison/src/helpers/utils.ts

Co-authored-by: alcpereira <[email protected]>

* chore: updated the options docs

* chore: updated tests after feedback

---------

Co-authored-by: alcpereira <[email protected]>
@wswebcreation wswebcreation merged commit 42956e4 into main Apr 18, 2025
19 checks passed
@wswebcreation wswebcreation deleted the ws/new-major-releases branch April 18, 2025 05:12
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.

2 participants