question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Proposal: Support for Cross Browser Testing

See original GitHub issue

UPDATES: February 7th, 2020

šŸ“¦ We have added support for Firefox and MS Edge in Cypress v4.0.0.

UPDATES: Oct 20th, 2018

I gave more updates on the work weā€™ve been doing for cross browser support and other features on a webinar we gave.

https://youtu.be/FfqD1ExUGlw?t=2079

UPDATES: Sept 8th, 2018

Cross browser testing is now a front and center major focus here at Cypress. Weā€™ve been experimenting over the last few months and have a working implementation to add native event support for Chrome, Firefox, Edge, and IE11. We also believe adding Mobile Safari and Android should also be straightforward - with Safari actually being the most difficult to get.

The architecture by which we are doing cross browser testing is a best-of-breed design where we tap into the native APIā€™s for Chrome and Firefox (avoiding the use of webdriver) and for Edge and IE11 we only use a minimal set of Webdriver APIā€™s - none of which are the traditional sendKeys or value endpoints, which avoids the network latency problem entirely. We plan to eventually publish this architecture so people understand how Cypress is different than Webdriver. None of the other core components of the Cypress architecture are affected by this change, it is simply how to enable native events in a consistent manner across all browsers without introducing the latency / flaky / non-determinism of Webdriver.

In additional to all these things, we are also adding Sauce Labs support (at a minimum) and will also have a proof of concept prepared for that.

As we add support for native events we are subsequently adding support for the browsers at the same time to ensure all of our algorithms are normalized correctly. However, youā€™ll likely first see us release native event support in Chrome + Firefox, followed by IE11 sometime after that.

ā€¦below is the original post from 2016ā€¦

Does Cypress support cross browser testing?

Currently the answer is: No

Right now, we only support Chrome* variants such as Chrome, Chromium, and Canary.

Will you ever support other browsers?

Yes.

We will be able to support other Desktop Browsers and Mobile Browsers (using Webviews).

We have built Cypress from day 1 with cross browser testing in mind, and are very conscientious to ensure the APIā€™s we write today will work in the future.

The Technical Details

Why do you only support Chrome today?

  • Cypress taps into the underlying browser Automation APIā€™s of Chrome to do things like modify cookies, take screenshots, focusing the browser window, etc.
  • We also launch the browser using very specific command line flags to turn off things that get in the way of automated testing.
  • We have synchronized these Automation APIā€™s when Cypress runs headlessly (in Electron). This means running headlessly behaves identically to a real headed Chrome browser.

What do you mean by ā€œAutomation APIā€™sā€?

  • Automation APIā€™s describe the functions that a browser exposes to do things outside of the Javascript Sandbox.
  • Currently Cypress comes with its own universal Driver which implements most of the cy commands using Javascript - in the same run loop as your application. This is superior in the sense that Cypress can understand, know, wait for and modify its behavior based on how your application reacts to its commands in real time.
  • The downside is its impossible to fully automate a browser entirely in Javascript. Javascript is a security sandbox which restricts what you can do.
  • To fully automate a browser you must extend beyond the sandbox and tap into the underlying Automation APIā€™s which do not have these restrictions.

What will it take to support cross browsers?

  • We have to port commands which need to extend outside of the sandbox to each other browser we are attempting to support.

How will you port these Automation APIā€™s?

  • Either manually by hand
  • Or by using the existing browser drivers

What do you mean by ā€œexisting browser driversā€?

  • Each browser has built its own driver to the Webdriver Spec.
  • Here are some examples of drivers:
  • Google Chrome Driver (ChromeDriver)
  • Micosoft Edge Driver
  • SafariDriver
  • Mozilla GeckoDriver (Firefox)
  • Internet Explorer Driver
  • Appium

Why would you port these by hand?

  • Because using the existing drivers comes with a host of problems.

Whatā€™s wrong with the existing browser drivers?

  • They are built for and thus limited to the Webdriver spec.

What is the Webdriver spec?

  • Itā€™s a HTTP API spec which defines a common interface to drive all browsers consistently.
  • It enables developers to abstract away the details of how each different browser implements its Automation APIā€™s

What is the problem with Webdriver?

  • Itā€™s slow
  • Itā€™s async
  • Itā€™s stateless
  • Itā€™s exposed over an HTTP server
  • Itā€™s a lowest common denominator
  • Itā€™s limited in scope and features
  • There are small inconsistencies
  • There are various driver bugs

What do you mean by ā€œlowest common denominatorā€?

  • The spec is essentially limited to only including ā€œall the things that every browser can doā€.
  • This leaves a tremendous amount of power and capability off the table that more modern browsers provide.

Can you give me some examples?

  • In Webdriver you cannot clear all cookies for all domains - you can only clear cookies for the current domain context under test.
  • There is no way to tell the browser to clear its cache.
  • Chromedriver cannot run tests with Dev Tools open.
  • Oftentimes the drivers may miss elements youā€™re trying to interact with.
  • You cannot easily control the application under test.
  • You donā€™t have native access to window, youā€™re limited to stringifying objects over the wire.

Does Cypress currently use Webdriver?

  • No. We wrote our own universal driver.

What would be the benefit of using Webdriver?

  • We could possibly use the existing drivers to port over various commands without having to write the manual integrations by hand.
  • This would allow us to support cross browsers much faster.

If you use Webdriver wonā€™t Cypress also inherit these limitations?

  • In most cases - no.
  • In some cases - possibly.

How can you avoid these limitations?

  • By using our universal driver to do as much automation as possible and only go outside of the browser for a limited set of commands.
  • The whole point of Cypress is to exceed the boundaries of the current testing ecosystem.
  • Because we automate the browser with a completely different architecture we are in a position to extend beyond the Webdriver Spec and also normalize its behavior consistently across all browsers.

Can you give me an example of this?

  • Cypress can clear all cookies of all domains instead of just the current domain under test.
  • We perform work outside of the browser but then synchronize it seamlessly like with cy.request.
  • We have many commands which work outside of the browser which donā€™t need to be ported.

But wonā€™t you still be limited by Webdrivers flakiness?

  • No. Even if we were to issue native events through Webdriver, because your application is always tested through Cypress, that means Cypress can respond synchronously to events that take place, and modify its behavior accordingly.
  • The vast majority of commands do not ever have to leave the browser anyway.

Can you give me an example of what youā€™re talking about?

  • Imagine this scenario: you have a modal opening which animates in, and you want to click the ā€œSubmitā€ button.
  • In Webdriver, because its an HTTP API which often involves multiple network hops, there is usually a significant delay.
  • Letā€™s assume youā€™re attempting to issue a native ā€œclickā€ to the submit button.
  • When you issue the ā€œclickā€ command, the browser driver calculates the center coordinates of the button at say: {clientX: 50, clientY: 100}.
  • It then issues the native click event with those coordinates.
  • By the time your application ā€œreceivesā€ this event, it could possibly ā€œmissā€ the button altogether.
  • Your test fails because your button was never clicked, and the modal was never dismissed.
  • What happened?
  • Because the modal was animating it, its coordinates were changing rapidly. Webdriver has no idea or concept of this, it only takes a coordinate snapshot at the moment in time and because it asynchronously dispatches the native event, it misses.

Why isnā€™t this a problem with Cypress?

  • Because Cypress is in the same run loop as your application, its impossible for it to ā€œmissā€.
  • It can synchrously run calculations, and it already automatically figures out if an element is animating beyond a certain threshold - and therefore wait until it stops.
  • If it did issue a native event, it could detect that this event has yet to happen, and if the element moved from the coordinate, immediately attempt to recover by either canceling the click event or issuing another click at new coordinates.

When do you think youā€™ll support other browsers?

  • We really donā€™t know, its not a priority for us right now.

Why isnā€™t it a priority? This is super important!

  • We disagree, cross browser testing is not as important as you think it is.

ā€¦

The reasoning and examples behind this are a WIP. Weā€™ll be updating this doc when they are ready.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:399
  • Comments:98 (25 by maintainers)

github_iconTop GitHub Comments

109reactions
brian-manncommented, Dec 7, 2020

We will be adding cross browser support likely by EOY. @chrisbreiding next project is that.

The support will be:

  • Firefox
  • Safari
  • Edge

No IE support is planned. It is substantially more difficult.

106reactions
brian-manncommented, Jan 10, 2018

First passing test running Cypress in Firefoxā€¦

screen shot 2018-01-09 at 11 13 11 pm

Read more comments on GitHub >

github_iconTop Results From Across the Web

Top 10 Tools for Cross-Browser Testing - Apriorit
Learn what cross-browser testing is, explore the best 10 cross-browser testing tools, and find out how to choose the most suitable tool forĀ ......
Read more >
Cross Browser Testing Strategy Explained in Three Easy Steps
Start testing by prioritizing the browsers based on the relevance of the browsers and then going on to the least relevant browser. Makes...
Read more >
Cross-browser Testing With Cypress.io - Applitools
While Cypress.io lacks support for cross-browser testing, Applitools supports it via their Applitools Ultrafast Grid. You can combine the bestĀ ...
Read more >
Cross-Browser Testing: Optimizing your visitors' experience
Cross -browser testing is ā€œtestingā€ the website using different browsers. In its simplest form, it is just viewing the different webpages within a...
Read more >
A Systematic Literature Review in Cross-browser Testing
We propose this study in cross-browser compatibility testing through a systematic literature review, aimed to find: testing.
Read more >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found