-
Continue reading →: Cypress: Asserting the text when there is infinite scroll
If you are working in react application, then in most of the cases the data in the UI is provided by Graphql. There will be times where the first set of data is loaded in a page and the next set would be loaded only after scrolling down, in such…
-
Continue reading →: Cypress: Adding a Custom Command
Cypress provides this great feature of adding custom commands, using which one can add repeatable code or functionality as Custom command. If you are new to cypress, in cypress commands are nothing by when you type cy. there are functions available like cy.get() cy.contains() . These are the cypress inbuilt commands.…
-
Continue reading →: Cypress: Executing Python scripts
There might be cases where we need to call python scripts within our cypress test workflow. In node.js world we can do this using the child_process but with Cypress we can just use cy.exec command to execute any system command. cy.exec(“python3 <filePath>”) > this will execute the command, and the…
-
Continue reading →: Cypress: Default Scroll Behaviour
Did you know that Cypress scroll to the element when you use commands like click(), select() and type() by default. And there will be instances where you don’t want this auto scroll to happen and Cypress provides option to disable this and you can disable this using flag scrollBehavior set to…
-
Continue reading →: Cypress: Did you know you can reuse the same test data file ?
Imagine you have a json request where you need to update datetimestamp every time you make a request. You can update it using various ways (Manually traverse to object and then replace the value). Using Handlebar JS we can keep the json request in .hbs file as template and reuse as…
-
Continue reading →: Cypress: How to assert substring with ignoring case ?
Cypress uses chai assertion library and Chai provides function called match which accepts regex for Comparision. Let’s consider we have a text called “CYPRESSIO” and we need to validate partial text ignore case, which is “cypress” We can use .should(“match”,<regex>). Attached code shows the example
-
Continue reading →: Cypress: Reduce your test execution time using cy.session
Cypress clears cookies and local storage before running every test by default. But we can let cypress know to cache the cookies and local storage using cy.session function. Say you have multiple tests where you need to login every time before performing next set of tests, in this case you…
-
Continue reading →: Cypress: Multiple Assertions for a given element.
Cypress provides ability to chain assertion using and() method if we need to assert more than one condition. Let’s take an example where we have image tag, and we need to validate the tag has attribute called src and its value. So we can write code like below
-
Continue reading →: Cypress: Asserting attributes for better check of Input Fields
In our application we have input field which accepts decimal value and it has upper and lower limit. So I had to write assertion to check what is the mode of input, the maximum and minimum value the field accepts. With cypress, using should function we can assert for attributes…
