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

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

Closed
dustinhorton opened this issue Nov 12, 2018 · 10 comments

Comments

@dustinhorton
Copy link

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—work 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",
@Uniiq
Copy link

Uniiq commented Nov 12, 2018

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

@dustinhorton
Copy link
Author

Tried downgrading but no change for me.

@chrisbreiding
Copy link
Contributor

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.

@dustinhorton
Copy link
Author

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.

@felixpk
Copy link

felixpk commented Jan 4, 2019

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

@jennifer-shehane
Copy link
Member

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

@sswales
Copy link

sswales commented Jan 10, 2019

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?

@chrisbreiding
Copy link
Contributor

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).

@jennifer-shehane jennifer-shehane added the stage: awaiting external fix A 3rd party bug in Cypress - awaiting release label Jan 29, 2019
@jennifer-shehane
Copy link
Member

Related issue: #3200

@jennifer-shehane
Copy link
Member

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

@jennifer-shehane jennifer-shehane removed the stage: awaiting external fix A 3rd party bug in Cypress - awaiting release label Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants