Skip to main content

Cypress UI Automation - part 4

 

Visual Testing

Cypress does not check on CSS changes on elements, instead, I used Visual Testing Tool to achieve this. I integrated Percy Visual Testing in the Cypress automation as follows:

Firstly, I created a Jira ticket for visual testing. Then I pulled the develop, our main branch from GitHub using Visual Studio Code IDE, and created a new local git branch, this would ensure I have the latest merged code to begin the test.

I run the npm command -

npm install --save-dev @percy/cypress

To install Percy. Then imported -

import '@percy/cypress';

in support/commands.js

which will give us access to the Percy snapshot command-

cy.percySnapshot().


Also, percy expects a PERCY_TOKEN to be set, this value can be found on the Percy project in the BrowserStack dashboard. 

Set PERCY_TOKEN=<PERCY_TOKEN VALUE>

I logged into the Browserstack online dashboard and created a project then copied the PERCY_TOKEN value provided.

Using the following command, I issued PERCY_TOKEN on the command line:

Set PERCY_TOKEN=<PERCY_TOKEN VALUE>

Then echo the following command to make sure the value is set:

Echo %PERCY_TOKEN%

This is part of the security measures on your product to conceal the PERCY_TOKEN, which is unique to every Percy project.

Once it was confirmed I entered the npm command to run the visual test.

npm run percy:tests



Percy Global SDK Configuration.

Configure Percy SDK with a global configuration file using Percy YAML file.

The YAML file was placed in the test project root. 




In the above screenshot, I have set up the widths, iframes and images not to be displayed as those are dynamic elements. Below are screenshots from Percy –


The above screenshot was a snapshot of the main navigation headings. I have eliminated images and iframe elements to focus on the static elements.




The above screenshot was a snapshot of the subcategories, just in case there is a change in the future, then we can check with the team before allowing deployment into Production.



Find the part - 5 - Conclusion, here:









Comments

Popular posts from this blog

Working with Dropdownbox elements in Selenium WebDriver

How to select element from a Dropbox We are going to use Selenium webDriver and chrome driver to test this. In addition, this test was created on Mac.  I assume you have installed and setup java in your system path.  Also, install Eclipse for jee. 1. First let's take a look at a quick test case: Test case: TC_1. Register on http://automationpractice.com/index.php TC_1.1: Launch hope page -http://automationpractice.com/index.php TC_1.2 : Click on link ‘Sign in’ TC_1.3 : Under “Create Account” subheading, enter Email address in ‘Email address’ textfield TC_1.4 : Click on ‘Create an account’ button. —————————————————————————————— Test data: Email address: gorgeous12@hotmail.com http://automationpractice.com/index.php ---------------------------------------------------------------- Expected : http://automationpractice.com/index.php?controller=my-account ———————————------------ 2. Next, create a maven project in Eclipse 3....

Cypress UI Automation - part 1

Java to Cypress-JavaScript Automation Migration Introduction: Across Cancer Research UK engineering department, we currently use a Java automation framework for our User interface and API testing. The framework has evolved in the last 3 to 4 years and currently, we have 19 products/project, (running approximately 1350 test scenarios) using the framework to run the respective sanity/regression packs. The project/products extend across different technology stacks such as Drupal, Symphony, React JS, .Net, OBI and Siebel CRM.   The Quality Assurance (QA) test team are currently under the process to be transformed into a fully-fledged Quality Assurance function.   As part of this transformation, we would like to have a comprehensive, automated test suite that can be maintained by developers and testers. Furthermore, our front-end web development is moving into JavaScript, now is the right time to migrate our automation framework also from java into JavaScript. The introduction ...

Performance Testing

  Performance Testing As part of the Quality Assurance Test Approach, each tester has to implement performance testing within its product team. In this section of the project, I will be using Apache JMeter as the testing tool for the test approach. Apache JMeter is an open-source performance testing tool for load, stress and many more testing. Screenshot from: https://www.youtube.com/watch?v=817zU_bXh9Y&list=PLUDwpEzHYYLs33uFHeIJo-6eU92IoiMZ7 JMeter works by creating a request to a target server(website), the server then responds, saves responses, collects, calculate statistics, return results to request and then generate reports.