Automated test execution speed can be improved with golden nuggets
Regression tests are the most difficult part of an agile testing team. Cross-browser and multi-device testing is a challenge. Development teams are now looking at scaling up their automation testing stack, more than ever. Automation helps stop manual labor. It also helps to avoid overlooking. Human eyes adjust to the screen behavior and are able to see very obvious issues/bugs because they interact with it on a regular basis. Automation is a powerful tool for developers. It's not just a great topic.
Automation is the integration of it into the CI/CD pipeline in order to trigger regression automatically when there is a code merging (pull request). This will reduce the need for manual follow-up and execution. It's not all rose-colored roses. It is not a problem as long as the test suite remains small. The suite grows rapidly as more tests are added. This leads to an increasing build time. If the test suite is run across browsers, the pain can be exponentially greater.
These are some good practices to follow when automating tests. These practices reduce clicks and page load times, which can help you build faster tests.
1. Login/Logout without UI
Everyone's favorite, the "Login sequence". The login screen is a great place to test new ideas or verify feasibility. However, how much time is consumed every time the login sequence through the UI triggers?
Do you remember the "beforeEach", hook that is executed before each test?
To login to the application, use API calls. This will skip the UI interaction. Some login scenarios only require username and password, such as cookies. To gain access, you should understand the login security scenario.
cy.request( method: 'POST', url: 'https://blog.com/logIn', form: true, body: username: 'Automation_tester', password: 'Automate123', , ) 2. Avoid the Consent banner interaction
Every test engineer is likely to get annoyed by the consent banner popup. Think about how many times you need to interact with this consent banner to close the dialog box or perform other actions. It's just overkill. Most consent banners can usually be stopped by setting required cookies prior to the page-load. Once you have identified the correct cookie, it is easy to fix. The test is sent directly to your application.
In the screenshot below, we can see that google creates a cookie named "CONSENT". The consent banner dialog won't be displayed if this cookie is not fed with the correct value.
3. For interaction, always use the Direct Link
Automating test flow automation requires attention. Every manual sequence is translated into test steps by testers. Instead of clicking on the navigation links to get to a page, it's better to load the URL directly. This reduces clicks and page loads. This also decreases script flakiness.
This is a dangerous mistake
cy.visit('www.blog.com'); cy.get('.nav_item_name').click().within(() => cy.get('.event').should('be.visible').click(); ); Try This
cy.visit('https://www.blog.com/events') 4. API Prep
Some scenarios are not possible to execute directly. Some scenarios may require initial preparation of the SUT. You can use underlying APIs for the prepping, as it takes a lot of time to set up the conditions.
export const Images = () => return requestHeaders().then((headers) => const wait = method: 'POST', headers: headers, url: `$apiLink/images/suit`, body: page: 0, size: 15 ; ); ;The above example shows a utility method to upload images into the application. This will later be used for other user journeys. This avoids multiple clicks for multiple images.
5. Avoid third-party interaction
When test scripts interact with third-party applications, the friction can be very high. We are dealing with code that we do not control. These weak links are responsible for frequent failures and flakiness in tests. Avoid such interactions as much as you can.
One infamous example is payment scenarios. E-commerce applications will often associate themselves with one or another payment portal. After the system has been prepared, it is recommended that the payment be made through backend API calls. This will bypass the third-party UI. You can avoid any external waits.
6. Atomic Tests
Automated tests must be independent and executable in order to harness the full potential of parallelization.
Parallelization allows you to run multiple tests simultaneously on different machines, thereby exponentially decreasing the test execution time.
This requires meticulous planning. Brainstorming sessions can be used to help identify the dependent scenarios and make the necessary preparations. The majority of prep activities will be part of utility methods that can be called whenever necessary.
7. Avoid dynamic sections of UI
Avoid interfacing with animated elements or dynamic elements if they are displayed on the screen. You may need to increase the time it takes to test, or make things more difficult. The shopping bag animation is one example. The little icon that appears when the user adds a product to their shopping bags jumps or opens. This shows the product being added and closed.
Quick Review
- Login/Logout without UI
- Avoid the Consent banner interaction
- For interaction, always use the Direct Link
- API Prep
- Avoid third-party interaction
- Atomic Tests
- Avoid dynamic sections of UI
These golden nuggets will help you notice an improvement in your automated tests' execution speed.

Comments
Post a Comment