Updated : 03/10/2018
When you hit a URL in a web browser, the request is submitted to the server and the server returns a response. The browser engine parses the received response and renders elements such as text fields, buttons, etc. on the web page as appropriate. Any action performed on a control that’s present on the web page can have any of the following effects:
OK, so how is that related to test automation?
If you dig a little deeper, you will realize that any operation that you do on a web page must be aligned with how a remote server or a web application would respond. For example, you hit a website and it takes about five seconds to respond, your test script must wait for at least five seconds before going ahead with further operations; that means every operation is controlled by a timeout after which a failure is reported in the test script and a defect in turn as well. Hence, in principle, while creating your test scripts, you must also devise mechanisms for handling “wait durations” and define “timeouts” – not only at a page level, but also at an element level.
How would synchronization help?
Synchronization is a mechanism in which two or more components work in parallel with each other. Typically, two components are involved in test automation – the application under test (AUT) and the test automation tool. Either works in a specific speed, and so you should write test scripts in such a way that both components work at the same speed. This will help you keep the dreaded “Element Not Found” errors at bay. Test maintenance after all is a key concern with large test packs; hence, anything you can do to mitigate non-functional failures is a win for your team.
In what ways does the Web UI perspective extend Selenium?
You can handle synchronization challenges in multiple ways by using the Web UI Testing capability available within the Functional Tester offering. Unlike in the case of Selenium, you need not write even a single line of code in your tests, which means you don’t have to spend time learning new APIs.
There are two broad categories of synchronization in test automation: unconditional synchronization and conditional synchronization.
In this case, you only specify a timeout value. The automation tool will wait for the timeout duration before proceeding with further operations.
To pause the execution for a duration specified:
With the Delay feature, you can pause the test execution for a certain amount of time. To specify a delay, open a test and select any node (in case of a compound test, select a test). Click Insert, select Delay from the context menu, and set a value.
The Think time feature causes the test execution to pause for a specific duration. The value gets captured automatically during recording – it is the difference between when a response is received (that is, when the page is completely loaded on the client side) and when you click a key or a hyperlink, to perform an action. You can also manually update the value by selecting any Web UI test step.
The Web UI Testing capability also supports a “global” think time, which truncates all think times that exceed the specified value – that means you don’t have to search for and edit each think time (associated with test steps) that’s longer than expected. The possibility of combining global and local think times helps you achieve unconditional synchronization more efficiently.
To enable a global think time and set a value, go to Windows > Preferences > Test > Test Execution.
In this case, you specify a condition along with the timeout value. The automation tool waits to check the condition and exits when the condition is met. The timeout value is for enabling the tool to proceed with further execution when the condition is not met.
A time out value causes Web UI test execution to wait until when a control becomes visible for you to perform a UI action (or) the timeout, whichever occurs first. You can set a timeout at a test level (the scope of which is all the steps in the test) and/or at a step level (the scope of which is that test step only). In case of a conflict between a test level timeout value and a step level timeout value, the latter takes preference.
To set a time out at a test level, select the top node of a test and open the Mobile and Web UI tab in the Test Details panel on the right and update the value.
To set a timeout value at a test step level, select a test step within a test and select the Time out check box in the User Action Details panel on the right and enter a value.
You can also set a timeout value for an application launch. This will ensure that the step next to the application launch gets executed after the application launch (or) the timeout, whichever occurs first.
With Selenium, you must learn complex APIs to handle synchronization issues, whereas in Web UI, it is completely GUI-driven and saves you, the tester, the hassle of writing many lines of code.
NAVANIT K SINGH
Software Test Architect
Navanit K Singh is a Software Test Architect who is currently working on Rational Functional Tester and Rational Test Web UI Tester. He has more than 11 years of experience in the software industry.
Principal Technical Writer
Shivi is a senior technical writer who has more than 13 years of experience in the software industry. She's currently a member of the Integration Tester project team and works out of the HCL office in Bengaluru.
HCL OneTest Studio is a trademark of IBM Corporation in at least one jurisdiction and is used under license.