Hot answers tagged

11

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 to check if buttons are disabled or not. Didn't even need to use the "expect" route.


6

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 reason for us to ever expose them. Most of the time this use case is needed when users click an that opens a new tab. Users then want to switch to that tab ...


6

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 Dashboard Service, used to display test recordings and data when tests are run in CI, will be free for open source projects and paid based on usage for private projects ...


6

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 their open-source promise. I think development tools should be open-source. I don't want to invest my time and our company's resources if I am not sure I can re-...


5

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 bootstrap a test is short, it can be damaging on the long-run; Test dependency: If you use only one test, you should be able to make the assertions independent - if the ...


3

$() 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 find the element with the class name as Typography.... But this is not validated locator as it contains space after Typography__StyledTypography-sc-153d8g4-...


3

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(':button').should('be.disabled')


2

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 tests I intentionally break that rule for 1 reason - speed. UI tests, e.g. browser tests are very slow and if they are used to give quick feedback you have to ...


2

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 assertions in separate tests. But for some situations, a failure in one assertion renders some other assertions meaningless or distracting. For those situations, I ...


2

Here: if(cy.get('a.auth0-lock-alternative-link').contains('Not your account?')) { cy.get('a.auth0-lock-alternative-link').contains('Not your account?').click(); } to evaluate expression in if statement you call contains('Not your account?') method. Since contains method has the default assertion that makes your test fail once the element does not contain ...


2

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 use to easily test a site but it also allows javascript logic so using any of the control structures you listed above already are allowed. I know this comment ...


2

Go Agile. Try it in small incremental steps. I would at least give it a chance for initial prototype by making a quick smoke suite out of it and see from there how it goes and will take further incremental steps as per the outcome.


2

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 a similar button and got it to work, the code would look something like this: function loadMoreProducts() { cy.get('body').then((body) => { if (...


2

E2E testing should be testing without stubbing and then having another layer for testing in isolation where stubbing will be more valuable. For the isolation testing, there may be some instances in which an application sends XHR on page load, so stubbing those requests would be beneficial for execution time.


2

Cypress stub() and spy() are adopted from Sinon.js spies and stubs. Based on Sinon documentation: When to use stubs? Use a stub when you want to: Control a method’s behavior from a test to force the code down a specific path. Examples >include forcing a method to throw an error in order to test error handling. When you want to prevent a ...


2

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 where people suggest their workarounds for your issue.


1

There are no best practices, only good practices in context. With the scripts configured correctly, nothing more than a make test is necessary. E.g., If you have a Jenkins job to run your automated checks: test: curl -X POST http://jenkins_server.com:port/job/job-name/build If you have to fetch code from other sources, you can run a git clone or a ...


1

You could try using it in a hook: beforeEach(function () { cy.server(); cy.route({ method: "POST", url: Cypress.env('GRAPHQL_API'), }).as("graphql"); }) it('test', function () { cy.wait("@graphql"); }) Note that, alias works only with beforeEach and not before all, as alias will be cleared after each spec (means each 'it' block) . https://...


1

João Farias provided a good link related to your direct question about multiple tabs, but since you mentioned that your specific scenario is logging in, there may be another approach you can use: The preferred way to handle login in Cypress is to bypass the UI and get login credentials directly from the backend--see this list of recipes. Of course, if you'...


1

You can use the beforeEach function to execute actions before every single test. The Cypress documentation gives an example of how you can use beforeEach, but it expects you to implement the resetDb function. This is not a generic function supplied by Cypress. Either remove the call to resetDb or implement it as a Cypress Custom Command.


1

Selenium aims to simulate browser activity - to check enviorments are properly setup and external services are in-place. It is end-to-end checking: From the UI, down to the DB and back, touch every integration along the way. If you want to test your React app, you should largely rely on React testing toolset: Enzyme, Jest, React Testing Library, etc. They ...


1

A brief comparison Selenium is very mature and widely used and as such it supports development in multiple languages including Java and has a active community Selenium Slack. As discussed here, Cypress probably has limited browser support. For the list of issues go to their respective Github projects cypress and selenium. Other considerations to take into ...


1

You can select out one of the fixtures present in project and pass it to your file unput via: https://www.npmjs.com/package/cypress-file-upload After that you need to submit a form (or start uploading in any other way), but that's details related to your specific case.


1

Cypress does not currently support native browser events such as filepicker, however, it is on their roadmap. native browser events The workaround is to add files to your fixture folder and then to create a custom command like Cypress.Commands.add( 'dropFile', { prevSubject: false }, (fileName) => { Cypress.log({ name: ...


1

cy.get('canvas').trigger('pointerdown', {clientX: 900, clientY: 500}) cy.get('canvas').trigger('pointerup', {clientX: 900,clientY: 500})


1

My colleague and I have worked out how to do this. I had to create a Cypress.env.json which contains a property and value that I want to use. Then in my test I replace the cy.visit('https://bvt-riskassessment.lmkcloud.net') with cy.visit(Cypress.env("riskApp")) Then in the bamboo build process we can specify which environment to call by using ...


1

I would make 18 different tests. It's better for debugging. If you group everything into one test, when it fails, you won't really know which one failed. And then you will have either rerun the test and watch or read the logs. Also, it could be that only one element failed to load. By having separate tests, you can narrow down what caused the error ...


1

Such test case we call a GUI tests or GUI Test cases and those have GUI in their name indicators. One test, multiple objects in it Usually, we put all GUI checks on one screen into one test. This is according to multiple test methodologies. Additionally, In javascript (ES) all checks are fired simultaneously anyway, so you will not miss other checks if ...


1

It really is a matter of preference, i personally prefer not to nest all in one test and split across 18 tests simply because of the reporting data. Once all are nested in one test if one fails the remaining values will not be evaluated, hence you might miss a failure.


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