Cypress: Failed to execute 'scrollTo' on 'Window': No function was found that matched the signature provided.

Created on 12 Nov 2018  路  10Comments  路  Source: cypress-io/cypress

It seems like the combo of Cypress/Electron doesn't like:

window.scrollTo({
   behavior: 'smooth',
   top: 0,
})

as I get this error:

Failed to execute 'scrollTo' on 'Window': No function was found that matched the signature provided.

To get around this, I'm currently doing:

try {
  window.scroll({
    behavior: 'smooth',
    top: 0,
  })
} catch(err) {
  if (err instanceof TypeError) {
    window.scroll(0, 0)
  } else {
    throw err
  }
}

Current behavior:

Failed to execute 'scrollTo' on 'Window': No function was found that matched the signature provided.

This error originated from your application code, not from Cypress.

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the 'uncaught:exception' event.

https://on.cypress.io/uncaught-exception-from-application

This error originated from your application code, not from Cypress.

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the 'uncaught:exception' event.

https://on.cypress.io/uncaught-exception-from-application
  Uncaught TypeError: Failed to execute 'scrollTo' on 'Window': No function was found that matched the signature provided.

  This error originated from your application code, not from Cypress.

  When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

  This behavior is configurable, and you can choose to turn this off by listening to the 'uncaught:exception' event.

Desired behavior:

Similar behavior to Chrome鈥攚ork without error.

Steps to reproduce:

Run a headless test on code that has the following:

window.scrollTo({
   behavior: 'smooth',
   top: 0,
})

Versions

"cypress": "^3.1.1",
electron scrolling 鈫曪笍

Most helpful comment

The issue was closed by the original person who opened this. We can reopen until newer version of Electron is released.

All 10 comments

I have the same problem with cypress version 3.1.1. So i decided to stay at cypress version 3.1.0.

Tried downgrading but no change for me.

This looks like a browser support issue. Cypress currently uses a version of Electron that uses Chrome 59. As far as I can tell, support for smooth-scrolling landed in Chrome 61. We'll be upgrading Electron and its Chrome version in the future, which will fix this.

Thanks @chrisbreiding

Believe I've just confirmed that it's not technically the smooth-scrolling, but passing in options to window.scroll() or window.scrollTo(), because this similarly fails:

window.scroll({ top: 0 })

Think I'm personally going to remove this in favor of CSS scroll-behavior.

Why is this issue closed?
cypress: 3.1.4 and the problem still exists

The issue was closed by the original person who opened this. We can reopen until newer version of Electron is released.

It's a big difference between the versions, Electron 59 and Chrome 71, why hasn't Electron been updated alongside the Chrome browser?

Or is this the latest version of the Electron browser?

If so, how did you come to the decision to use Electron for the headless runs?

The version of Electron is tied to the Cypress binary itself, since it uses Electron itself. Updating Electron means issuing a new version of Cypress, which we'll be doing with 4.0. When you run Chrome, it uses the Chrome installed on your system, which means you must have Chrome installed, but also means you can control the version separate from Cypress.

There are various reasons we use Electron for run mode. The biggest ones are that it allows us to easily do video recording of your runs for debugging and that, since headless runs are mostly used in CI, it doesn't require you to have to install Chrome in your CI environment. You can just install Cypress and have it work. (By the way, you _can_ use Chrome in run mode with the --browser flag, but video recording will be disabled).

Electron was updated to Chrome 61 in Cypress version 3.3.0 and this issue should be fixed.

Was this page helpful?
0 / 5 - 0 ratings