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

Cypress v13.6.0 no longer running commands (hangs) when we focus out of the window #28392

Closed
Julien-Marcou opened this issue Nov 23, 2023 · 53 comments · Fixed by #28898
Closed

Comments

@Julien-Marcou
Copy link

Julien-Marcou commented Nov 23, 2023

Current behavior

When I launch my E2E tests on Chrome, if I focus out of the Chrome window, the E2E commands are no longer running, it's hanging there doing nothing.

If I always stay focused on the Chrome window, the commands work as expected.

After focusing out, re-focusing in the window does not make the commands continue/restart.

Might be related to this PR this #28334

Desired behavior

I should be able to run E2E tests while not being focused on Chrome (as before) so I can do something else while the E2E tests are running.

Test code to reproduce

Sorry I don't have time to create a reproduction of the bug for the moment

Cypress Version

13.6.0

Node version

v18.18.2

Operating System

macOS 14.1.1

Debug Logs

No response

Other

No response

@jennifer-shehane
Copy link
Member

@Julien-Marcou That's certainly not intended. We haven't observed this behavior so I wonder if it is something specific with your tests. A reproducible example or a video of the hanging behavior would be helpful. We'll keep an eye on tracking for this.

@jennifer-shehane jennifer-shehane added v13.6.0 🐛 stage: needs information Not enough info to reproduce the issue labels Nov 27, 2023
@esetnik
Copy link
Contributor

esetnik commented Nov 27, 2023

I am experiencing the same issue in v13.6.0

@stephenmday
Copy link

I am experiencing this issue as well in 13.6.0 When I open a test in test runner it runs correctly, but if I go to VS Code and make a change to the code and save, normally the test will run again in test runner, but it hangs. I have to stop and restart the test every time I make a change to the code.

@chrisbreiding chrisbreiding self-assigned this Nov 28, 2023
@EllenFr
Copy link

EllenFr commented Nov 28, 2023

I have the same focus issue with Cypress 13.6.0 and Chrome 119 but it does not occur when selecting Edge, Firefox or Electron. In my case, saving changes in VS Code still causes the test runner to start over but because the focus was lost, the process stops there.

@valantic-dev
Copy link

valantic-dev commented Nov 28, 2023

We are experiencing the same issue after we updated to v13.6.0
The tests are executed in an Azure Pipeline and stop sending out the requests after 2-3 hours of execution.
Additionally, the issue @stephenmday and @EllenFr described appears on my local machine, too.
We went back to v13.5.1 for now.

NOTE:
I think I should mention that we are sending an HTTP request in "beforeAll" hook of each test to ensure that the test environment is initialized correctly. This one specific request is the one that gets stuck.

It's a globally defined "beforeAll" hook in the e2e.ts
image

@alexsch01
Copy link
Contributor

I see the same issue with 13.6.0

@chrisbreiding
Copy link
Contributor

Does anyone have a clone-able repo that can be used to reliably reproduce this issue? I've tried a few projects, but can't recreate the described behavior, so I wonder if there's something project-specific that I'm missing. A way to reproduce it locally would provide a way forward to diagnose and fix the problem.

@elebitzero
Copy link

I am seeing this constantly when running Cypress 13.6.0 with latest Chrome interactively on Windows.

If the Cypress window loses focus it will hang.

Even if I let it run, it eventually hangs when it gets to some download tests because the browser pops up a tooltip: 'Find your downloads here'.

@iomedico-beyer
Copy link

iomedico-beyer commented Nov 30, 2023

Steps to reproduce:

  1. Run in "open" mode with Chrome, Edge or Electron.
cy.get("#some-text-field").type("foo-bar-baz", { delay: 1000 }).blur()
  1. Wait until Cypress starts typing.
  2. Before blur you have plenty of time (about 10 seconds) to click on another window.
  3. Defocusing of the window leads to defocussing of the text field, so type kind of freezes and blur fails:

cy.blur() can only be called when there is a currently focused element.

Note that in Firefox the text field does not loose focus unwantedly until the Firefox window gets the focus back.

@jennifer-shehane
Copy link
Member

@iomedico-beyer I'm not able to reproduce this behavior from this example still :/

We are looking into the possibility that this issue may be the cause: #28443

If you open devTools after the hang, do you see a message like below?

Uncaught Error: Attempting to use a disconnected port object

@valantic-dev
Copy link

cypress_136.zip

Hi @jennifer-shehane and @chrisbreiding , I created a video and captured the test execution incl. 2 scenarios when Cypress gets stuck.

  1. During the test exeuction I open the browser console (via F12). As the console is openen, the execution stops and does not resume again. No errors like in Uncaught Error: Attempting to use a disconnected port object #28443 are in the console.
  2. I restart the test execution and then switch to VSCode during the tests are running. Here again, the executions stops and does not resume.

@iomedico-beyer
Copy link

iomedico-beyer commented Dec 4, 2023

@iomedico-beyer I'm not able to reproduce this behavior from this example still :/

I found something interesting after creating a complete code sample:

it("types into a text field", function() {
   cy.visit("https://www.google.com")
   cy.get("button:visible").first().click()
   cy.contains("English").click()
   cy.contains("button", "Reject all").click()
   cy.get("textarea").first().type("foo-bar-baz", { delay: 1000 }).blur()
})

I found that I couldn't reproduce my problem here either. So my (specific?) problem seems to be somehow related with the web app I am trying to test. It also is not Cypress 13.6 specific. Happens the same with Cypress 13.0 (don't know about even older).

@verheyenkoen
Copy link
Contributor

@jennifer-shehane In my case I only experienced this in a dual monitor setup I think where my editor and Cypress runner window are on different screens. Maybe you can reproduce it that way?

@esetnik
Copy link
Contributor

esetnik commented Dec 4, 2023

@iomedico-beyer I'm not able to reproduce this behavior from this example still :/

I found something interesting after creating a complete code sample:

it("types into a text field", function() {
   cy.visit("https://www.google.com")
   cy.get("button:visible").first().click()
   cy.contains("English").click()
   cy.contains("button", "Reject all").click()
   cy.get("textarea").first().type("foo-bar-baz", { delay: 10000 }).blur()
})

I found that I couldn't reproduce my problem here either. So my (specific?) problem seems to be somehow related with the web app I am trying to test. It also is not Cypress 13.6 specific. Happens the same with Cypress 13.0 (don't know about even older).

Hmm... In my case it is definitely related to v13.6 as rolling back to any prior version of cypress does not reproduce the issue.

@jennifer-shehane In my case I only experienced this in a dual monitor setup I think where my editor and Cypress runner window are on different screens. Maybe you can reproduce it that way?

I am also on a dual monitor setup for what it's worth.

@iomedico-beyer
Copy link

iomedico-beyer commented Dec 5, 2023

What happens in my case is: Let's say Cypress is typing into a text field which represents a date. When it already typed e.g. 2023-0 I click on another window => the text field looses its focus => some Ajax (of the web app I am testing) posts the input to the server. The response of the post request somehow clears the text field (because the date is invalid, I guess) => Cypress can't type in the rest (although it does not complain) and also can't blur (probably because the original text field was replaced by a new one).

So I guess my problem is something very different than what is discussed in this issue and may be related to a general constraint of the open mode in Cypress or even (at least Chromium based) browsers in general. Am I right? Cypress just can't suppress the focus loss? Is this documented somewhere, btw?

@valantic-dev
Copy link

@iomedico-beyer For me, the issue you describe seems to originate from the behavior of the UI component framework you are using in your app. Not really related to the topic discussed here.

@iomedico-beyer
Copy link

iomedico-beyer commented Dec 5, 2023

@iomedico-beyer For me, the issue you describe seems to originate from the behavior of the UI component framework you are using in your app.

Partly. I think my main problem is that Cypress cannot supress the focus loss which happens when I click on another window. There should not be a focus loss because the simulated user is typing in something, not clicking around. I just want to know if this is documented somewhere and then it's fine for me. @jennifer-shehane Do you know, perhaps?

It's just that I lost almost a week on this until I understood why my tests are so flaky ...

Not really related to the topic discussed here.

I agree.

@JarekSuchocki
Copy link

JarekSuchocki commented Dec 6, 2023

@jennifer-shehane We've got same issue. Since 13.6, only in Chrome browser, when you get focus out of cypress runner window it hangs without any errors. Also when I try to download a file in a test. it also hangs after the (download) step without any information. (Chrome 119)

@travisanderson
Copy link

Also getting this. New to cypress, but hard refreshes work, because focused on the chrome window. But save in vscode, and it just doesn't run in chrome unless I click over and focus, hard refresh again.

Also, even with the provided sample tests, when running in the middle, if I click out of chrome just to try and see what happens, it instantly hangs the moment I focus away from chrome.

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Dec 7, 2023

What OS and OS version is everyone using? Just seeing if there's a trend with OS.

@stephenmday
Copy link

MacOS 14.1.1 (23B81)

@JarekSuchocki
Copy link

Windows 10

@verheyenkoen
Copy link
Contributor

What OS and OS version is everyone using? Just seeing if there's a trend with OS.

MacOS Ventura 13.3.1

@esetnik
Copy link
Contributor

esetnik commented Dec 7, 2023

MacOS Sonoma 14.1.2

@travisanderson
Copy link

MacOS Ventura 13.4.1 (22F82)

@caseycling
Copy link

@Hafiz166 did you try this workaround that Chris mentioned above to see if it fixes your issue?

#28392 (comment)

@Hafiz166
Copy link

Hafiz166 commented Jan 4, 2024

Now it's working Thanks @caseycling 🤝

@xxluke
Copy link

xxluke commented Jan 15, 2024

I'm also having "Your browser is managed by your organization". The Cypress extension isn't even listed.

In Cypress 13.5.1 the commands were executed normally, still without the extension, though.

grafik

@ughitsaaron
Copy link

The workaround described in #28392 (comment) did seem to resolve the issue for me.

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Jan 16, 2024

@xxluke The Cypress Chrome extension has a static ID of caljajdfkjjjdehjdoimjkkakekklcck. This allows Cypress to be added to your allowed extensions when working under corporate policies that prohibit extensions.

Edit: Found the docs for this: https://docs.cypress.io/guides/references/troubleshooting#Allow-the-Cypress-Chrome-extension

@blackgrouse
Copy link

We are currently blocked from testing with the latest version of Chrome (v120) in our build pipeline due to #25891. Although fixed in Cypress 13.6.3, we cannot take this version as this issue seriously impacts developer experience. Would appreciate a quick fix for this issue. Thanks!

@jennifer-shehane
Copy link
Member

@blackgrouse The workaround is to manually turn on the Cypress extension as explained here: #28392 (comment)

We know this isn't ideal and we've been actively looking into ways to improve this experience. Not surprisingly, Google Chrome doesn't really offer an automated way for us to override a user's behavior to not allow an extension to take control of the browser, so there isn't a quick way to force our extension behavior to work.

There are some other things we're considering, like making the extension less necessary for users until they want to do an action that would require our extension. But we are working through ideas, so thanks for your patence.

@blackgrouse
Copy link

@blackgrouse The workaround is to manually turn on the Cypress extension as explained here: #28392 (comment)

We know this isn't ideal and we've been actively looking into ways to improve this experience. Not surprisingly, Google Chrome doesn't really offer an automated way for us to override a user's behavior to not allow an extension to take control of the browser, so there isn't a quick way to force our extension behavior to work.

There are some other things we're considering, like making the extension less necessary for users until they want to do an action that would require our extension. But we are working through ideas, so thanks for your patence.

@jennifer-shehane Thank you, appreciate you and your team's effort on this. FWIW, I have not edited the extension's permissions but am still seeing this issue.

@schirrel
Copy link

schirrel commented Feb 2, 2024

@jennifer-shehane @chrisbreiding does it possible to identify if the browser is managed by organization? if so maybe adding a banner to cypress app to warning dev its something that will be already a huge help. I am willing to help on this

@jennifer-shehane
Copy link
Member

@schirrel We did discuss something like a warning as an option, but I'll summarize what we're attempting to move forward with now.

We intend to move the logic that's executed from the Cypress extension around tab focus into the cy.puppeteer plugin, since the primary use case of adding this logic to the binary was to support this plugin. We thought the changes would be a benefit overall to test isolation and the experience of Cypress. We were not anticipating so many hurdles with enabling the Cypress extension.

This will mean that running tests without using cy.puppeteer (which is the majority case of our users) will not require the Cypress extension to be enabled at all.

We're prioritizing this work currently.

@schirrel
Copy link

schirrel commented Feb 2, 2024

Niceee, thanks a lot @jennifer-shehane ❤️

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 20, 2024

Released in 13.6.5.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.6.5, please open a new issue.

@cypress-bot cypress-bot bot removed the stage: ready for work The issue is reproducible and in scope label Feb 20, 2024
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Feb 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Generally Available
Development

Successfully merging a pull request may close this issue.