What is synchronization
Synchronization in test automation, is the mechanism by which you ensure the application state is ready to perform interactions while running a test. When working with Web or mobile applications, you typically need to synchronize every time a new page is loaded and also at other salient points during the interactions with the application.
For example, before you start entering the username on the login page, you need to ensure the page is fully loaded. Similarly, you may have a situation where a set of new fields may appear on the screen based on other interactions. In such a case, you need to ensure the new set of fields are loaded before starting to verify/interact with these.
ACCELQ supports these objectives with a comprehensive synchronization capability:
- Context-level synchronization
- Synchronization in the Action logic
Every context you create in ACCELQ can define its own Synch strategy. When an Action belonging to this Context is called in a Scenario, ACCELQ verifies this synchronization implicitly while running the test. In other words, you do not need to put any logic for this in your Action. The system implicitly waits for the page to fully load based on specified criteria, at the beginning of an Action.
Creating a synch point for Context
- Open the Context on which you want to set up synchronization, from the Navigator grid.
- On the Context page sidebar, under Info tab, go to the Synchronization section. Click on the link for synchronization.
- Select Element or Page option from the Wait On dropdown field, depending on how you would like to set up the synchronization. Select an element if you decide to synch on an element.
- Select the condition that you would like to define for the synchronization. Follow the fields on the screen.
Note: If you cannot find the element you need for synchronization, open a View for the Context and right-click on the desired element. You can create an element and come back to synchronization.
You can set up synchronization on either an element's state or on the page state. Here are the options available for the synch conditions.
Best practices for synch point
If you do not set synchronization for a Context, a warning is displayed in the Results page before every Action belonging to this Context. It is a good practice to set context-level synch to avoid timing-related test failures.
In addition, it is very important that you exercise due diligence in selecting an appropriate Synch Point. A properly setup Synch Point can make the test runs more resilient and reliable. A few guidelines to consider while setting up Synch Element:
- Unique Element: Pick an element that is unique for the given page. In many instances, there may be common elements across multiple pages. If you pick such elements, you may get a false confirmation even when the required page is not loaded.
- Consistent Element: Ensure the element or page characteristic is stable and universally applicable for this page, in various states of the application. For instance, some elements may be displayed in a page only when certain business rules or inputs are met. Such elements won't be appropriate to use, as you may see false failures trying to find an element that is not relevant in the page.
- Slow Element: Choose an element that often loads slowest in the page. This ensures the rest of the page functionality is accessible by the time synchronization is complete.
Remember, if you cannot find a suitable candidate for synch element, you also have an option to synchronize on the page text or title.
Configuring the amount of wait time
When the test is running, ACCELQ will wait for the page to load based on the specified synch criterion. The amount of wait time can be configured when you run the test.
In the Run modal, click on the PAGE/ELEMENT TIMEOUT section and configure the values. Configure this value based on the worst-case possibility for page loading time on your network.
Note that the configured timeout is only the maximum time system would wait for the successful page load. If the page loads quicker, then the test proceeds with the next steps immediately.