cy.url() and/or cy.location(‘href’) does not return a string

tl;dr Cypress commands are asynchronous, you have to use then to work with their yields. cy.url().then(url => { cy.get(‘.editor-toolbar-actions-save’).click(); cy.url().should(‘not.eq’, url); }); Explanation A similar question was asked on GitHub, and the official document on aliases explains this phenomenon in great detail: You cannot assign or work with the return values of any Cypress command. … Read more

Using Cypress, how would I write a simple test to check that a logo image exists on a page

I figured out the solution on my own. cy.get(‘form’).find(‘img’).should(‘have.attr’, ‘src’).should(‘include’,’My-Logo’) I inspected the element and found the <img src… line was embedded within a <form>. I could do a cy.get(‘form’) and pass, but could not do a cy.get(‘img’) to pass. So then I chained them together and it passed. I am not sure why I … Read more

How can I get Cypress to run a specific folder of tests by specifying it as a project?

I think you’re looking for –spec path/to/folder/*.js You can run all the tests in a folder, or even in all subfolders of a folder, ex/ npx cypress run –spec cypress/integration/subsetA/**/*-spec.js would run all .js specs in all folders under the “subsetA” folder in cypress/integration. So in your case: npx cypress run –spec cypress/integration/apps/smhw-qa/**/*-spec.js should do … Read more

How to get div ‘text’ value in Cypress test using jquery

I might try this: cy.get(“.ibxudA”).find(‘.WildnessText-kRKTej’).should(‘have.text’,”Wildness”) or cy.get(“.ibxudA”).find(‘.WildnessText-kRKTej’).invoke(‘text’).then((text) => { expect(text.trim()).equal(‘Wildness’) }); This might be a similar question: How do you check the equality of the inner text of a element using cypress?

In cypress, how do I wait for a page to load?

You can add some assert inside: cy.click(‘#someButtonToNavigateOnNewPage’); cy.location(‘pathname’, {timeout: 60000}) .should(‘include’, ‘/newPage’); cy.click(‘#YouAreOnNewPage’); You can change default timeout – by default it’s 4000 ms (4 secs) – to ensure that user navigated the page. I’ve put a big number here – 60,000 ms – because I’m sure that 99% of users will leave if they … Read more

Cypress test: is .contains() equivalent to should(‘contain’)?

The result on your cypress test will be the same if the element with name=planSelect does not contain dummyPlan, that is, the test will fail at this point. The difference between them is that in the first form, using contains(), you’re actually trying to select an element, and the result of cy.get(…).contains() will yield this … Read more

tech