Mar 20 2018 | Automation
Automation using Cypress.io
By: Neeraj Sharma

Automation testing has evolved over the years from UFT until selenium. Every tool works on providing the needs for automating the functions in a program or some units of a project. Each tool has its advantages and disadvantages. As the technology is changing new tools have come into the market which provide the change or need to updation to limitations of the current tool available. There are tools which are used for automation for Desktop, mobile, Websites, API Services, Middleware WebServices. Each tool gives some flexibility and learning to new modes of automation.

The latest one to enter is Cypress.io. For quite a while there is been one major player in the field of E2E web application testing — selenium. Most of the solutions out there were basically building their APIs on top of selenium, so they all suffered from the same problem that selenium has. Cypress.io is a new player that has no selenium dependency and is set to address the shortcoming of its predecessor.

Cypress is an end to end frontend test automation tool which has come up recently and its based on Node.JS. Cypress is based on latest Java Scripting technology, which will handle modern web applications based on Anjular.JS or React.JS.

Selenium operates by running outside the browser and executes remote commands across the network. All of the underlying commands are remote.

What you have is the test script running outside of the browser, executing remote commands into the browser. But it’s never able to understand in the same run loop the reactions in the events that are being fired in the browser.

Where Selenium WebDriver runs remotely outside the browser, Cypress is the exact opposite; it runs inside the browser.

For these instances, Cypress utilizes a lot of the same underlying browser automation APIs that selenium web driver takes advantage of, but without actually using Selenium WebDriver.

Cypress takes a different approach since it’s actually executed in the same run loop as your application. It also leverages a Node.js server to handle any task that need to happen outside of the browser. Because of this, they claim to be able to give more consistent results since it’s able to understand everything happening inside and outside the browser.

This also affords you native access to every single object without having to deal with object serialization or over-the- wire protocols.

As a result, it is able to synchronously be notified of every single thing that happens inside the browser. So you have native access to every single Dom element.

Cypress also makes it easy to simply drop a debugger into your application or spec code, which makes it easy for the user to develop using the various developer tools.

This tool has lot of features which makes it interesting to use:

1. There is no need of Selenium or Web driver in Cypress. They have their own execution engine and has consistent speed of execution.

2. No wait times in Cypress – There is no need for Wait commands in Cypress. It handles page loading automatically.

3. Cypress has in built features for capturing screenshots when an error occurs.

4. Test runner in Cypress is very good. As soon as we modify and save the script, it executes automatically.

5. It shows the last command executed and time taken to execute the script. Browser can also be changed through selection in the dropdown box.

6. Debugging is very interactive. It shows the snapshots of each executed command. A user can see the list of commands executed in a flow which help to analyze the code effectively.

 

 

References:

 

https://www.cypress.io/

https://github.com/cypress-io/cypress/issues

November 2015 Cypress Presentation(https://www.youtube.com/watch?v=yq99BvSe1AQ)