Skip to content

BUG: scrollElementIntoView recieves a promise #1129

@RodBuild

Description

@RodBuild

Environment (please complete the following information):

  • Node.js version: 24.14.0
  • NPM version: 11.12.0
  • Browser name and version: Chrome 146.0.7680.165
  • Platform name and version: MacOS Tahoe 26.3.1
  • WebdriverIO version: 9.26.1
  • @wdio/visual-service version: 9.2.0

Config of WebdriverIO + @wdio/visual-service

    [
      'visual',
      {
        baselineFolder: './visual/baselines',
        screenshotPath: './.visual',
        savePerInstance: true,
      } satisfies VisualServiceOptions,
    ]

Describe the bug
Hello, I found a bug for the @wdio/visual-service@9.2.0 : https://www.npmjs.com/package/@wdio/visual-service
The problem is that when trying to scroll the element into view, the element is passed as a promise to scrollElementIntoView (@wdio/image-comparison-core ). The default is that all elements get autoElementScroll: true.
So, with the element being a promise, I get this error: element.getBoundingClientRect is not a function
I changed my node_modules to await the element and the issue gets resolved.

To Reproduce
Steps to reproduce the behavior:

describe('ISSUE: scrollElementIntoView', () => {
  let element: ReturnType<WebdriverIO.Browser['$']>
  it('opens a page', async () => {
    await browser.url('https://webdriver.io/')
  })
  it('find elem', async () => {
    const elem = $('main section')
    await elem.waitForDisplayed()
    await browser.pause(750)
    element = elem
  })
  it('runs visual test', async () => {
    await browser.checkElement(element, 'section', {
      disableCSSAnimation: true,
      ignoreAntialiasing: true,
      ignoreAlpha: true,
    })
  })
})

Expected behavior
browser.checkElement should not throw an error

Log
Example should be enough

Additional context
Example should be enough

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions