Adding Programming Constructs

 

You need to manually insert the programming constructs such as for, if, while etc after doing the bare minimal recording of the web page.

 

A skeletal script will be generated. Then you can add the programming statements as desired. You need to ensure that the Jython language syntax and semantics is not violated. You can refer to the detailed usage of Jython in the following Jython PDF file.

 

An example script which includes the for loop construct.

 

Please note, to avoid syntax errors while using a for loop construct, indent the lines after the for loop with a single <TAB> key press.

 

useLocalMapFile()

launchApplication("about:blank")

changeURL("http://$QE_SERVER:$QE_PORT/qehome/examples/payrollsystem/index.html",2)

setWindow( "AdventNet Payroll System",2)

clickList("View",2)

setWindow( "AdventNet Payroll System Package - Form to View Employee Details",2)

initDataSet("test_datasource")

result = getValuesFrom("test_datasource")

#********************************************************************************

#result is a 2D array which stores the values fetched from the specified dataset.

for i in range(0,len(result)):

    displayMessage(len(result))

    //Storing the value of name fetched from the 2D array in a variable

    name=str(result[i][0])

    displayMessage(name)

    //Storing the value of department fetched from the 2D array in a variable

    dept=str(result[i][1])

    displayMessage(name)

    //Replacing the setText statements with the variable

    setText("yourname",name,3)

    setText("dept",dept,3)

#********************************************************************************

closeWindow( "AdventNet Payroll System Package - Form to View Employee Details",3)

 

Refer to the document illustrating for construct in tutorials for the detailed explanation of this script.

 

An example script which includes the if..else construct.

 

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) 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") 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")

 



Copyright © 1999, AdventNet Inc. All Rights Reserved.