Illustrating Dynamic Functions

 

The sample script named test-dynamic-window is an illustration of how to use some of the dynamic functions which are as follows:

These functions are added in non-recording mode and thus does not use the map file during playback. The detailed description of this sample script is given below:

 

In this script, the UserQueryForm.html page is recorded which is bundled with QEngine in <QEngine_Home>/examples/payrollsystem directory. After navigating to this page, the doesWindowExists() is used to check if the window with the parent_window_title "Details of David" exists in the HTML page. The Jython if construct is used to check the return value of the doesWindowExists(). The value returned as 1 indicates that the window does not exists. If window does not exists, uses the setDynamicWindow() to dynamically set the parent_window_title as "User Entry Form" during playback.

 

Following are the lines in the sample script which does the above during playback:

 

useLocalMapFile()

launchApplication("http://$QE_SERVER:$QE_PORT/qehome/examples/payrollsystem/UserQueryForm.html")setWindow( "Cross-Window HTML",6)

setText("word","David",7)

clickButton("Show User Details",1)

winexists=doesWindowExists("Details of David",1,"NONE","NONE",1)

if winexists == 1:

setDynamicWindow("User Entry Form",1,"Name","right",1)

...

...


Once the window is dynamically identified using the setDynamicWindow() with the given parent_window_title, any actions can be fired on the objects in this window using the fireEventOnElement(). Thus the fireEventOnElement() is used to fill all the user details in the User Entry Form as shown below:

 

Following are the lines in the sample script which does the above during playback:

 

...

...

...

if winexists == 1:

setDynamicWindow("User Entry Form",1,"Name","right",1)

fireEventOnElement("input","name","username",1,"settext","David","false") fireEventOnElement("input","name","age",1,"settext","12-6-2001","false") fireEventOnElement("input","name","gender",1,"click","NONE","false") fireEventOnElement("input","name","dept",1,"settext","Marketing","false") fireEventOnElement("select","name","communication",1,"select","Fax","false") fireEventOnElement("input","name","telephone",1,"settext","091-443-882181","false") fireEventOnElement("input","name","mail",1,"settext","david@ymail.com","false") fireEventOnElement("input","name","add",1,"click","NONE","false")

 

Once the user details are filled in the form, the doesPopUpExists() is used to check whether the popup with the specified title "Microsoft Internet Explorer" exists during playback. The Jython if construct is again used to check the return value of the function. If the return value is 0 (which indicates success) uses the getPopUpText() to read and get the text message in the popup. The message retrieved is displayed in the testout.txt file using the displayMessage(result). After printing the message in the logs, the popup is closed using the closePopup() which takes the title of the popup to be closed as the argument. The last two lines which includes the else part displays the message as "User Details Obtained" in the logs, if the doesWindowExists() is able to find the window with the parent_window_title "Details of David" in the HTML page during playback.

 

Following are the lines in the sample script which does the above during playback:

 

if winexists == 1:

...

...

...

fireEventOnElement("input","name","mail",1,"settext","david@ymail.com","false") fireEventOnElement("input","name","add",1,"click","NONE","false")

popexists=doesPopUpExists("Microsoft Internet Explorer")

if popexists == 0:

result = getPopUpText("Microsoft Internet Explorer",1) displayMessage(result)

closePopUp("Microsoft Internet Explorer",1)

else :

displayMessage("User Details Obtained")

 

You can playback this script from the default suite AdventNetPayrollSystem to view the output.



Copyright © 1999, AdventNet Inc. All Rights Reserved.