cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Safari (WebKit) Support

Open amirrustam opened this issue 5 years ago • 194 comments

Current Status - last updated August 4, 2022

✅ Prioritized and on the roadmap ✅ Doing exploratory work to assess requirements and timelines ✅ Under active development ℹ️ Cypress currently supports Firefox and Chrome-family browsers (including Edge and Electron).

Objective

Add support for running Cypress tests within WebKit, which is the engine used by the Safari web browser.

Task List

  • [ ] Initial PR to add development-only support: https://github.com/cypress-io/cypress/pull/15533
  • [ ] Fix broken driver/other functionality
    • [ ] Network functionality https://github.com/cypress-io/cypress/pull/23232
    • [ ] Keyboard tests
    • [ ] Video recording
    • [ ] Multi-domain implementation
    • [ ] Fix open mode close
    • [ ] Fix/skip focus from app
    • [ ] Fix global mode detection of npm module
    • [ ] Fix websocket polling/proxying/allowedSockets
  • [ ] Documentation - limitations, Linux dependencies
  • [ ] Add experimental flag, make available in production, update public types

amirrustam avatar Feb 12 '20 00:02 amirrustam

I've done a fair bit of work on getting Safari working well with web-platform-tests (a conformance test suite for browsers with a dashboard) and know a little bit about what kinds of problems you might run into.

I know that Cypress doesn't use WebDriver but rather CDP (at least for Chrome) but can someone sketch roughly what the requirements of the protocol are? I've had a look at CONTRIBUTING.md and browser support docs but couldn't find any high-level information about Cypress internals.

I ask because I'd like to understand if it would be at all feasible to communicate with Safari using safaridriver, or what the basic "API" or protocol between Cypress and a browser needs to be.

foolip avatar Feb 18 '20 09:02 foolip

hi @foolip we would need the following from either extension/devtools APIs:

  • get/set/clear cookies by domain
  • screenshot page
  • record video of page (this can be done via getUserMedia api if it supports capturing the browser tab, which we do in firefox)

in addition, we would also need:

  • a way to set a proxy server for all network traffic
  • a way to bypass the invalid ssl cert screen/prompt

everything else is done via JavaScript

kuceb avatar Feb 18 '20 19:02 kuceb

Thanks @Bkucera, that's a great list!

get/set/clear cookies by domain

It sounds like you need to get/set/clear cookies for domains other than the one currently loaded, is that right? It looks like the only way of doing that using WebDriver/safaridriver would be to load a page from that domain and then use the endpoints with an implicit domain, but that's not great.

record video of page

I don't think this is possible, but I did have fun recording the whole macOS VM in Azure Pipelines using screencapture once. One can also record a specific window, but I presume you want the content area without decorations.

a way to set a proxy server for all network traffic

I'm pretty sure this is not possible yet.

a way to bypass the invalid ssl cert screen/prompt

I wouldn't be surprised if this is already possible with some setting or command line argument, but I don't know what it is. Our setup for web-platform-tests is a bit special, we update /etc/hosts and add a certificate to the system certificate store. It's a bit much, and also requires that you know what the domains under test are before you start the tests, which is probably not the case for Cypress.

foolip avatar Feb 20 '20 13:02 foolip

@amirrustam We got Firefox and Edge support recently, love to see, Safari support soon since Safari have

  • 17.21% of global browser market share (2nd most used browser, second only to Chrome) : source
  • 36.28% USA browser market share (2nd most used browser in USA, second only to Chrome) : source
  • 33.48% UK browser market share (2nd most used browser in UK, second only to Chrome) : source

So please support Safari too.

kaushalyap avatar Feb 22 '20 11:02 kaushalyap

Yes for a lot of responsive sites mobile safari is a must have and can be the majority of the users.

kelly-tock avatar Feb 28 '20 12:02 kelly-tock

i want so badly to use Cypress, but I simply must use WebDriver because Safari support is a requirement over here

clockelliptic avatar Mar 20 '20 23:03 clockelliptic

I’d love to see a quick decision around this topic, especially now that playwright is gaining a lot of popularity.

Cypress team, please prioritise this compatibility.

lughino avatar Mar 26 '20 09:03 lughino

I would suggest to my company and all clients to use Cypress if Safari support is implemented

it-sha avatar Mar 27 '20 10:03 it-sha

Starting using cypress instead of selenium, great advantages over selenium, however Safari browser is a major requirement, would love to see cypress support for this soon to continue using cypress

lkoorsse-tails avatar Mar 31 '20 11:03 lkoorsse-tails

same, using Wdio just because safari support, management requirements. Please implement even a basic safari runner.

AlexanderTsipin avatar Apr 02 '20 14:04 AlexanderTsipin

Please add support to Safari !!!

flenerob avatar Apr 03 '20 04:04 flenerob

Could this issue to be locked for comments. Adding the "I really need this message" does not really help and it creates a new push notification that everyone subscribed receives and it is annoying. Do you want to reflect that you need this? Click 👍 on the issue.

jhuesos avatar Apr 03 '20 07:04 jhuesos

In the meantime, could we update the error to show that Safari is not supported in Cypress rather than the current misleading error that Safari isn't installed on the system? I wasted a few hours trying to debug my CI because I thought Safari was not installed.

Here's the current error message

> npx cypress run --browser  "safari"

Can't run because you've entered an invalid browser name.

Browser: 'safari' was not found on your system.

Available browsers found are: chrome, firefox, electron

mydiemho avatar Apr 09 '20 16:04 mydiemho

I would love to have that!

estefafdez avatar Apr 25 '20 09:04 estefafdez

Found Solution: TestCafe supports Safari and iphone, real devices and emulators

AlexanderTsipin avatar Apr 26 '20 10:04 AlexanderTsipin

I'm gonna add +1 to people requiring Safari support in Cypress. We're currently experimenting with different frameworks and we narrowed down our selection to TestCafe and Cypress. While most of us want Cypress, we also need the ability to test on Safari (due to ~30% of our users using it, 77% of which are using mobile version) along with other (currently supported) browsers.

Can we have at least some rough estimate for when any work would start? SoonTM is too broad and we can't really risk rewriting our tests if we don't get it in, let's say, a year or so.

wojciech-sygier avatar Jun 16 '20 12:06 wojciech-sygier

@wojciech-sygier We too have the similar user segment and we took a call to proceed with TestCafe and it is working for us. We are using BrowserStack to run the tests on real devices and it is super cool.

0xc0d3r avatar Jun 17 '20 02:06 0xc0d3r

Please, Add suport for Safari!!!

galeza avatar Jul 01 '20 19:07 galeza

We evaluate current feature work on a number of factors and have to make tough decisions on which to currently work on. This is not part of our current feature work. This is not to say that it will never be delivered. We will comment in this issue when that decision changes. We do not have a rough estimate on when this will be delivered.

We are always re-evaluating what to work on next and feedback from people using Cypress is a big part of that evaluation. We welcome comments in this thread on how this feature would impact your testing.

jennifer-shehane avatar Jul 02 '20 05:07 jennifer-shehane

@mydiemho This error message was updated to be clearer about which browsers are supported in Cypress 4.8.0. https://github.com/cypress-io/cypress/pull/7375

jennifer-shehane avatar Jul 02 '20 05:07 jennifer-shehane

Where can we see the current feature work that is prioritized?

kelly-tock avatar Jul 02 '20 12:07 kelly-tock

+1 for Safari support has been long-awaited, as the second most used browser (Mac and iOS/iPadOs) for us. Getting to a point of considering placing all the test coverage to an alternative such as testcafe for browser support.

aikhelis avatar Jul 02 '20 13:07 aikhelis

Our Roadmap highlights some of the larger features that are under development.

jennifer-shehane avatar Jul 02 '20 14:07 jennifer-shehane

Thank you @jennifer-shehane - this is useful and I'm sure some of these features are important, as long as users do not switch to another tool for the coverage of their user real experience across key browsers.

aikhelis avatar Jul 02 '20 15:07 aikhelis

+1 for safari support browser

apis3445 avatar Jul 15 '20 01:07 apis3445

+1 for Safari support

jprealini avatar Jul 17 '20 18:07 jprealini

Hi @jennifer-shehane,

I think this is more around showing open commitment on providing support for safari, it's quite concerning that the official roadmap doesn't mention it at all and this topic still says:

image


It would be great to have this moving forward, at least in terms of direction.

hitmands avatar Jul 31 '20 15:07 hitmands

I'm curious if the team is also considering adding standalone WebKit support in addition to Safari for MacOS? (I can't seem to find any issues about this).

One of the big benefits is that WebKit is Linux compatible. Which means CI systems or Docker environments can make use of this automation. It's also the engine backing most mobile browsers on iOS which is an important part of coverage for most companies (including Airbnb, where I work).

We've been experimenting with Playwright as well and they seem to support WebKit out of the box https://github.com/microsoft/playwright#documentation--api-reference.

sharmilajesupaul avatar Aug 03 '20 23:08 sharmilajesupaul

I'm curious if the team is also considering adding standalone WebKit support in addition to Safari for MacOS? (I can't seem to find any issues about this).

@sharmilajesupaul If nothing changed since I last checked, WebKit is way less uniform than Blink. Browsers using Blink generally depend on Chromium without major changes to the engine so they all render web pages identically. WebKit, on the other hand, has multiple build flags so various WebKit-based browsers may be quite different between each other. That’s one of the reasons Safari & Chrome have always had many differences in supported Web APIs.

Maybe it changed since Blink was forked out of WebKit, I don’t know.

mgol avatar Aug 04 '20 10:08 mgol

@mgol Thats interesting, I hadn’t considered Blink since chrome browsers are well supported by Cypress. My thinking was around the fact that WebKit with an emulated device would probably be the closest thing to mobile Safari that we could run in Docker environments.

sharmilajesupaul avatar Aug 05 '20 02:08 sharmilajesupaul