|
||||||||||||||||||
Automating Dynamic Web Application with QEngine
Websites and applications are becoming crucial to the success of businesses and hence need to be tested thoroughly and frequently.However, these applications change constantly and the challenge of test automation projects is in dealing with these changes. Successful automation is possible only if the automation tool can handle the changes and allow reuse of the automation project. In this paper, we present an overview of how QEngine allows you to reuse the test automation project even after the application has changed. Introduction The purpose of this paper is to outline the provisions of QEngine product that allows users to reuse the test scripts when the application has changes. Reuse of scripts offers tremendous productivity gains in terms of time and effort.
For
further information about QEngine, visit the URL:
Applications under test may change and they change constantly and the challenge of test automation projects is dealing with these changes. Successful automation is possible only if the automation tool can handle all of the scenarios described below:
Handling Applications with varying Response Speeds
An application's response speed is dependent on the system / network in which it runs. The expected window might appear immediately on a faster system / network or might appear after a significant delay when running on slower systems / network. QEngine has an option to wait for the configured timeout period(in seconds) for the window to appear. By default, QEngine will wait for 60 seconds for the particular window to appear. If the window appears before the configured timeout period, it will immediately proceed to the next script actions. If the needed window does not appear within the configured timeout period, the particular setWindow action will be reported as "Failed" and the script will proceed to execute the remaining part of the script. The timeout period can be modified as required, as explained below in "Adjusting Playback Speed". Adjusting Playback Speed To synchronize QEngine playback with the speed with which the application window appears, configure the settings as given below:
Handling Application Window Title / Size / Content Changes Application window title and size are other aspects of application that might undergo change from one version of application to another. Application window size changes will not affect QEngine playback as it does not depend on screen coordinates for locating Window elements. Similarly,inserting additional elements or removing elements into or from the application after recording will also not affect playback. QEngine will identify the elements on the web page based on the element properties such as name / id / innertext, etc., However, if the window title changes, then the change has to be incorporated in the QEngine script. QEngine has an effective way to handle the changes with the support of regular expressions for a successful playback. You can configure the Regular Expression for Window Title as explained in the "Using Regular Expressions" topic below: Using Regular Expressions for Window Title Assume that the application window title is changing dynamically such that only the starting or ending word of the title remains the same across pages. To playback the scripts that includes such pages, you can specify regular expressions for the window or parent title in the GUI Map file. The steps to achieve it are as follows:
Handling Application Window Element Changes A good automated testing solution should ensure that tests can run unattended regardless of application behavior during test execution. During a play session, the elements in the web page will be identified based on the element properties stored in the GUI Map file. The GUI Map file will contain the properties that were got during the recording session. Following are the element properties that governs the element identification during playback:
In the above properties, "ID" will take precedence, followed by other properties appropriate to the element type. If any of the main identification property value used to identify the element changes after the recording, the test may fail during playback session. Following are the various categories of property changes that need to handled by the automation software. Handling of the above property changes are discussed further here. Category 1 : Element Property Changes after RecordingWhen the property values of the objects in your application has changed to another value after recording, QEngine allows you to modify the corresponding test object property values in the GUI map (or Object repository), so that you can continue to use your existing test scripts. For Example : The ID attribute of an element changes as required in the web page after the automation script is recorded.This should be changed appropriately in the GUI Map file in order to ensure successful execution of script. You can configure the property changes of the element in the map file as explained in the Configuring Element Property Changes in Map File topic below : Configuring Element Property Changes in Map FileTo configure the element property changes in the Map file, follow the steps given below:
The location of Window Elements usually will not change, but could change between one release of your application and another, basically to improve the aesthetics of the screen. QEngine playback does not require any configuration as QEngine identifies the element on the web page based on the properties of the element, which is not dependent on the order of the elements on the screen. Category 3: Element Type ChangesAnother possibility of a web application change is the element type itself changing from one to another such as link to a button / button to image, etc. after recording. In this case, the element properties are required to be added to the GUI Map file using learn mode and the script action for this element should be inserted into the script from the learn mode view. Configure the element properties using learn mode, as explained in Configuring Element Type Changes using Learn Mode in topic given below. Configuring Element Type Changes using Learn ModeLet us consider an image in the application is replaced with a button in the web application that got recorded. The above change should be incorporated in the recorded script. Otherwise, the script will fail stating "ELEMENT_NOT_FOUND" for the particular image element, which does not exist now. To reflect the change of element in the script, we have to learn the particular button element properties and should use the appropriate action over the element for the successful execution of the script. To learn the properties of the particular element to the GUI Map file and to insert the relevant function or user action for the element type using learn mode, follow the steps given below:
You can now successfully playback the script with the changes in the element incorporated into the script. Category 4 : Element Property Changes DynamicallyThe element properties such as ID, name or innertext of a certain element might change dynamically to meet the goal of the application.In such a scenario, the recorded element properties will not be helpful in identifying the element in the web page. If the changed property value is known, we can override the element property value stored in the GUI Map file with the above value during runtime using overriding functions. Let us consider an example where auto generated ids are used in the elements in the page as ID or innertext. Each time it is played, the element identification property needs to be overwritten. QEngine provides property-overriding functions to override the particular property of the element. Configure the overriding property as explained in the "Configuring Overriding Property" topic below: Configuring Overriding PropertyAssume an online ticket booking system where a user fills in a form to book a ticket. Once a ticket is booked, assume a message is displayed in the HTML page as "New Ticket ID: T1001 has been successfully generated" and a dynamic link is created to view the booked ticket details. Now, to click on this dynamic link whose id and innertext properties include the Ticket ID, you need to fetch the TicketID from the message that is displayed using the webGetText() and pass the fetched TicketID value as the fourth argument in the clickLink() as shown below: Example script which uses the webGetText() and clickLink() with four arguments for a link whose innertext and id properties are dynamically generated during playback:
useLocalMapFile() Here, the webGetText() will search and fetch the value(TicketID) placed in between the given prefix and suffix text and stores it in the ticketIDVal variable. This variable is then used as the fourth argument for the clickLink() to click on the dynamically generated link. Similarly, there are a variety of other four argument functions such as clickButton, clickImage, selectItem, clickElement, setText, clickList, etc., available to handle specific HTML elements such as Button, Image, Select, Table, Textfield, Div, etc. whose property value changes dynamically.
For details, refer to the help documentation in If multiple identification properties of the same element change in the web page, we can use the substitution of Environment Variable for the element properties in the GUI Map File. Configure the Environment Variable for the property value in the GUI Map file as explained in the Configuring GUI Map Element Propertieswith Environment Variable topic below. Configuring GUI Map Element Properties with Environment VariableLet us assume the identification properties such as id and name of an element in a web page change dynamically for each session. In such a scenario, the element identification will fail with therecorded properties during playback session as the property value changes dynamically. For successful playback, both id and name properties of the element should be substituted properly for the playback session. With the overriding element property value discussed above, we can override asingle property of an element. We cannot override multiple properties of the same element. To dynamically substitute multiple properties for the same element, we have to use the "Environment Variables" for substitution. Follow the below steps to configure "Environment Variables" for substituting element properties:
Similarly, we can configure the substitution for dynamically changing GUI Map element property values. Handling Applications with Dynamic Windows & ElementApplications can sometimes be designed to have varying window elements that cannot be predicted at the time of playback. Following are the scenarios to be handled,
QEngine has built-in functions to fire event on such dynamic elements & windows. You need not record all the element actions and the window that comes after the click. You can handle all the possibilities with QEngine's built-in functions itself. Utilize the built-in functions of QEngine as discussed in Using Dynamic Functions of QEngine topic given below. Using Dynamic Functions of QEngineHandling dynamically added elements Let us assume a scenario where anew text field is added to the web page based on the user input. To input to the above text field that got added dynamically, we can use the fireEventOnElement function available with QEngine.
fireEventOnElement() - To fire the specified event over the given HTML element.
fireEventOnElement("tagName","propertyName", "propertyValue", occurrence ofthe element, "actionName", "actionValue","useRegExp")
Example:
fireEventOnElement("input", "type","text", 1, "setText", "dynamicvalue","false")
The above function will set text over the dynamically added text field in the web page. Similarly, we can fire event over any HTML Element.QEngine supports following actions over the HTML Element via fireEventOnElement function,
To dynamically identify the window that appears based on dynamic element click, use the following functions:
setDynamicWindow - To set browser window that got launched during playback which is not part of the recording.
setDynamicWindow(parent_window_title,parent_window_index,frame_window_title or frame_window_name,value_of_frame_title or value_of_name,frame_window_index)
Example:
setDynamicWindow("My_parent_window_title",1,"frame_window_title","My_frame_window_title",1)
This will dynamically identify the window with parent title as "My_parent_window_title" and frame window title as "My_frame_window_title" so that further actions on any element in this window can be achieved using fireEventOnElement.
You can refer the dynamic functions reference in the following link: One of the hardest things when developing automation scripts is handling the case where an unexpected popup, like an ALERT box, pops up. Let us take the case of an application that generates an error message if the user input data exceeds the allowed limit, and does not generate an error message if your input data is valid during the next test run. The Exception Handling mechanism of QEngine allows you to handle unexpected popup that arises during playback. Configure Exception handling as explained in the Handling Exceptions in Playback topic below: Handling Exceptions in PlaybackTo automatically handle unexpected popups during playback, follow the steps given below:
Another aspect of the application that will change after recording or anytime during playback is the host in which the application runs and the port it uses. QEngine allows configuring of modified host and port without changing the scripts or GUI map file. This also allows the tester to run the automation project against any number of servers by just a single point and click. Configure Host Port changes as explained in Handling Host Port Changesduring Playback topic below. Handling Host Port Changes during PlaybackTo configure the server and port changes, follow the steps given below:
This concludes the paper on handling dynamic changes of application in your automation project with QEngine. We hope that you now have a better understanding of the features and capabilities of ManageEngine QEngine.
Visit our website www.qengine.com for more information.
|
|||