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.

Getting errors using cy.get(...).contains(...).click()

See original GitHub issue

Current behavior

Currently, when running a test in headless mode, doing cy.get('element').contains('something').click() will be completed successfully, however will show up as an error:

Add Edit Contact - From Other Sections -- Can't edit unsaved OFF-NET number (failed)

and throw the following error along the way: 2021-08-25 19:27:57.384 Cypress Helper[66690:816470] In -[NSApplication(NSQuietSafeQuit) _updateCanQuitQuietlyAndSafely], _LSSetApplicationInformationItem(NSCanQuitQuietlyAndSafely) returned error -50

The issue here for us is it might seem like a flaky test, but it is actually not.

Desired behavior

In this situation, Cypress shouldn’t throw an error.

Test code to reproduce

cy.get('element').contains('something').click()

Cypress Version

8.3.1

Other

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bahmutovcommented, Sep 6, 2021

@yonatanaftali try reading the retry-ability guide linked above and use a single cy.contains command instead of cy.get+ cy.contains combination

cy.contains('[data-cy=call-row]', '(111) 111-1111').click();

As another precaution I would add

cy.contains('[data-cy=call-row]', '(111) 111-1111').should('be.visible').click();

For any more help, please provide the app we can run to see the problem.

0reactions
yonatanaftalicommented, Sep 12, 2021

@bahmutov I followed your suggestion and it solved our issue. Thanks! Much appreciated!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Messages | Cypress Documentation
Getting this error means you've tried to interact with a "dead" DOM element - meaning the current subject has been removed from the...
Read more >
Using Cypress cy.get() with a contains selector not working as ...
cy.get('body:contains(ATHLETE FIRST NAME)').click() will return the body element which is a single element so there will be no error.
Read more >
Misleading error message when trying to access ... - GitHub
Some of our tests sometimes showed the following error message: cy.contains() failed because it requires the subject be a global window object ....
Read more >
8 common mistakes in Cypress (and how to avoid them)
Remember, .should() command will make the previous command retry, but not the full chain. This means that our cy.get('[data-cy= ...
Read more >
`cy.click()` failed because this element is detached from the dom
Below is the error code that I am getting while I am trying to automate user creation scenario ... When you invoke cy.get(),...
Read more >

github_iconTop Related Medium Post

No results found

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 Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found