Hot answers tagged

44 votes

How to check a button is disabled using Cypress

Well this was embarrassingly simple cy.get('button.mat-button.mat-primary').eq(8).should('not.be.disabled') cy.get('button.mat-button.mat-primary').eq(8).should('be.disabled') and this will allow me ...
  • 1,007
11 votes

How to check a button is disabled using Cypress

The Cypress documentation shows examples how you can use should() to verify elements are enabled/disabled: https://docs.cypress.io/api/commands/should.html#Assert-the-checkbox-is-disabled cy.get(':...
9 votes
Accepted

Is Cypress set to replace Selenium as the preferred tool for automating web applications?

In our last project we also evaluated different tools among these were also Cypress and Selenium. At the end we decided for Selenium, because we were testing front end applications and for us Cross-...
  • 1,173
7 votes

Is there a way to automate multiple tabs using cypress?

From the Cypress site: Because Cypress runs in the browser, it will never have multi-tabs support. We do have access to the browser automation APIs to actually switch tabs, but there is no ...
  • 10.2k
7 votes

Is Cypress set to replace Selenium as the preferred tool for automating web applications?

Probably not, mainly because: WebDriver is a W3C Spec WebDriver supports all major programming languages WebDriver is supported by all major browser vendors WebDriver is 100% open-source Cypress ...
6 votes

Cypress vs Protractor for end-to-end testing

Open Source: I am a developer at Cypress.io. Cypress recently released its public beta and is now open source. The code for it's core product, the Test Runner can be found here. The Cypress ...
6 votes
Accepted

Cypress vs Protractor for end-to-end testing

Open source: Cypress.IO looks promising, but I have been holding off with starting to use it on a production project. My main reason that it is a commercial company and I cannot be sure they keep ...
6 votes
Accepted

How to simulate a simple keypress in Cypress

Found an answer: cy.get('body').trigger('keydown', { keyCode: 27}); cy.wait(500); cy.get('body').trigger('keyup', { keyCode: 27}); The amount of time cy.wait() waits is arbitrary. It depends on ...
  • 9,810
6 votes

How to simulate a simple keypress in Cypress

The recommended command is: cy.get('#someId').type('{esc}'); I'm using this to disclose pop-ups and where it makes sense to use ESCape as a User. Cypress version: 8.3.0
5 votes
Accepted

Test all elements in a single test or 18 separate tests

Three things should be considered, all equally important: Performance: Will creating several tests increase the suite execution time? It highly depends on your framework. Even if the time to ...
  • 10.2k
5 votes

Is Cypress set to replace Selenium as the preferred tool for automating web applications?

It really depends on what you need. I've used both, so here's my opinion: Cypress seems better at handling waits (your point n. 2), this could be such a pain in other tools, but it's an internal part ...
  • 4,488
4 votes
Accepted

If else loop is not working/ element exists: cypress automation

$() is equal to findelement(by.css('')). And in your case the locator is: .Typography__StyledTypography-sc-153d8g4-0 jhYDmS TrainingQueueListstyles__EmptyListMessage-sc-19yfim3-1 ihRiqU which means ...
  • 10.9k
4 votes
Accepted

Do something as long as element is on page - cypress

Ok so there is a way, but I am not sure if this is "the" way when it comes to Cypress. You can write a recursive function that will call itself when the button is present. I have used a site which has ...
  • 1,047
4 votes

How to check a button is disabled using Cypress

I recently found this code working in my case where I wanted to check if the element was enabled for next actions: this.button().then(($btn) => { if ($btn.is("enabled")) { //do ...
  • 41
4 votes
Accepted

How to wait till all components are loaded in Cypress?

There's no such concept of waiting or even writing your own waits (like with Selenium) in Cypress. Cypress has this built in. I recommend reading their docs, it's one of the core concepts mentioned ...
  • 4,488
4 votes
Accepted

Assert that options (text) in drop down are unique

Get the text and add to a array Convert array to set and compare the size Set will have only unique elements (Removes the duplicates) So if length of set and array are different , it means there where ...
  • 10.9k
4 votes

How can Cypress be seen as an End-to-end testing tool when it cannot travel across different domains?

What you're describing is mentioned here in the Cypress documentation. Cypress documentation also mentiones some workarounds. I think the bottom line for you is this part: A common use case for this ...
  • 4,488
3 votes

How to check a button is disabled using Cypress

Your question mentioned both active and visible and they are separate as in: visible / not-visible active / not-active (disabled but visible) These two different pieces of state should be considered ...
3 votes

Cypress if-then-else, while and foreach

The creators have strong opinions on why you should not use conditional logic in your test however, Cypress doesn't disallow the use of javascript control methods. Cypress has a robust API you can ...
3 votes

End to End tests on multiple build agents?

Depends on the goal of the test. I like to differentiate test goals, for example between: Pure Functional, Tests which check if the functionality works in general. This should work on a stable ...
3 votes

Is Cypress set to replace Selenium as the preferred tool for automating web applications?

From what I remember Selenium handles iFrames and parallel testing far better than Cypress. Finally, If you learn cypress without learning selenium you won't build transferable skills. I'm a ...
  • 179
3 votes
Accepted

How can I measure the coverage of my E2E tests?

Michael Bolton proposes testing coverage as: “X coverage is how thoroughly we have examined the product with respect to some model of X”. And he completes: "Test coverage, like quality, is not ...
  • 10.2k
3 votes

How can Cypress be seen as an End-to-end testing tool when it cannot travel across different domains?

Remember context - what works for some may not work for you. Other than the suggestions above, consider your system and think about what you need. Cypress is a popular tool but not every test tool is ...
  • 255
3 votes

XHR requests are cancelled in Cypress

It seems you want to wait until routes resolve. If that is the case, you need to explicitly tell Cypress to do just that. For example, if I want Cypress to wait for a specific route, I write it like ...
  • 4,488
3 votes

How to return a value from a then() block and use it in another then block in cypress

It's mentioned in the documentation mentioned in the comment section, I recommend reading it. Specifically, you can read this part about closures. What you can do is to put the other cy.get() inside ...
  • 4,488
3 votes

Conditional testing on checkbox in Cypress

Conditional testing is not recommended by Cypress, but it's possible to deal with this situation like this: html: <div> <input type="checkbox" id="mytestcheckbox" /> ...
  • 4,488
3 votes
Accepted

Conditional statement in cypress

Just like jonrsharpe said in the comments, cy.contains will not return true/false depending on whether the element is there. In fact, it won't return anything of interest, as Cypress commands are ...
  • 136
2 votes

Test all elements in a single test or 18 separate tests

Usually my tests have one assertion per test. However for this specific issue for UI tests there is one single over-riding factor (in this discussion about 1 or many) and it is Performance In UI ...
2 votes

Test all elements in a single test or 18 separate tests

I decide these things by asking a question: If a responsibility fails one assertion, do I still want information from the other assertions? Usually the answer is yes, in which case I put the ...
  • 4,485
2 votes

Select files from system's local drive using cypress

Cypress does not support file upload out of the box. However there are several workaround that might or might not work for your particular case. You can observe the official cypress github discussion ...
  • 11.5k

Only top scored, non community-wiki answers of a minimum length are eligible