rajasankar

Vendor Script Functions in QEngine

Aug 17 2009 01:56:47 AM Posted By : rajasankar
Comments (0)

Vendor Script Functions in QEngine.

Before seeing what are the vendor functions, we need to understand what is Vendor Scripting?

Vendor Scripting defined as script/functions specific to the program or application. In other words, such functions available only in that application and won't be used anywhere else.

Vendor scripts can be a deciding factor in the learning curve of the automation tool. The more vendor scripting, more time needed to learn.

Here is the separation of vendor scirpt and common functions

1. Window Functions or Dynamic Functions
2. HTML Special Functions
3. HTML Check Functions or HTML Get Functions
4. AJAX Functions
5. Invoke Script Functions
6. General Functions (optional)
7. Default Recorded Functions(optional)

Common functions
1. XML Validation Functions
2. String Manipulation Functions
3. File Manipulation Functions
4. E-Mail Functions
5. Date Functions
6. Database Functions

Check this page for all functions available in the QEngine.

Rajasankar
rajasankar at zohocorp dot com

How to follow web links in Dynamic web page

Aug 13 2009 09:00:38 PM Posted By : rajasankar
Comments (0)

In this article, I am going to show, how to follow the web links in the Dynamic web page is easy with QEngine.

Here are the two function used in that.

You can get the DOM element property with the following function,

Code:
getElementProperty(tagName,propertyName,propertyValue,index,propertyNeeded,regExpRequired='false')

You can click on the element using the following function,
Code:
fireEventOnElement(tagName,propertyName,propertyValue,index,actionName,actionValue='',regExpRequired='false')

Here
tagName = DOM tag name such as TD,IMG,SPAN
propertyName= Property of the tag which is used such as Name,ID
propertValue= Value of the property.

First find the values in the page using getElementProperty,

Code:
getElementProperty("A","href",propertyValue,index,"href",regExpRequired='false')


Here the propertyValue is the one we don't know and that one we need. How to get this? Simple, use regex to get any value in href property.

Code:
getElementProperty("A","href",".*",index,"href","true")


Now this will match everything in that property and entire string. Let call this in a loop and get the values as an array.

Code:

i=1
while i>0:
values=[]
setLastWindow()
property=getElementProperty("A","href",".*",i,"href","true")
if property is not None and property!='':
values.append(property)
i=i 1
else:
i=0
return values


Now use the values in the fireEventOnElement function


Code:

for i in range(0,len(values)):
setLastWindow()
fireEventOnElement("A","href",values[i],i,"click","NONE","false")


You can also concatenate the web url if the value is relative.



Code:

for i in range(0,len(values)):
setLastWindow()
url="" values[i]
fireEventOnElement("A","href",url,i,"click","NONE","false")


Bingo!



You can use the same idea for any tag in the web page.

Let me know, how this works.

Rajasankar
rajasankar at zohocorp dot com

In Notepad you can add function complete for custom languages. Existing Auto Completion files can be edited too which means I can add QEngine functions too.

I've spent an hour to add the QEngine functions into python.xml file. Now, I don't have check the Framework.py for the syntax of the functions.

The QEngine script file has extension of .wcs, associate that to the python language and see the difference. Those files will be located in the /QE home/projects//webscripts/< script name>/.

Here is the file, change the extension into .xml and replace that under /Notepad home/plugis/APIs/.

This feature also available in the QEngine inbuilt editor. If you need this one for any other text editor, let me know.

Rajasankar
rajasankar at zohocorp dot com

Using Dynamic Functions in Unusual Way

Jun 05 2008 03:48:52 AM Posted By : rajasankar
Comments (0)

I've discussed overcoming the user interface/ web interface changes here. Script maintenance and related issues are discussed here. Take a look at the Script maintenance guide here. The examples used in those articles are simple ones. However, in real world testing, we'll encounter complex web interfaces to deal with.

We know we can use Dynamic Functions of QEngine to handle any element that is added dynamically in the web application. How about using those functions for a static element which might change in future.
Let me explain using an example. When I am automating OpManager, I've encountered a situation to check the device snapshot pages.



A,B,C are device names in the network. I need, QEngine to click on these links. Discovery of the devices will run on everyday to check the daily build performance of OpManager. If any device is down at the time of the discovery, it wont make into this list. Sometimes, the name of device may be changed or may be removed from network. When I record this page using QEngine, I've got this,

Code:
clickLink("A",1)
setWindow( "OpManager",1)
clickLink("Server",1)
setWindow( "OpManager",4)
clickLink("B",5)
setWindow( "OpManager",7)
clickLink("Server",1)
setWindow( "OpManager",4)
clickLink("C",5)


I can't run the same script if the devices names are changed like this,


Using the following functions may resolve issues like this,
fireEventOnCellElement
To invoke or fire the specified event for the given HTML Table Cell element

fireEventOnElement
Using this function, desired action can be initiated over the certain HTML element identified through the arguments to the function. The element details need not present in the GUI map file.

fireEventOnChildElement
Using this function, desired action can be initiated over the certain child HTML element of the given parent HTML element identified through the arguments to the function. The element details need not present in the GUI map file.


Instead of the above script we can use like this,

Code:
setWindow( "OpManager",1)
fireEventOnCellElement("main",1,2,"click","NONE","NONE","NONE","NONE",1)
fireEventOnCellElement("main",1,3,"click","NONE","NONE","NONE","NONE",1)
fireEventOnCellElement("main",1,4,"click","NONE","NONE","NONE","NONE",1)

This will play in every situation. Even if the device name changes, it will play.

I am using the newly introduced fireEventOnChildElement in OpManager.
Using that function reduces the 10-15 days of manual effort in the
every testing cycle.

Script reusing has one basic requirement, no hardcoding. Here Hardcoding means, using constants where it can be replaced using variables.
I'll discuss another aspect of this in the next post.

Send your feedback/comments to rajasankar at adventnet dot com

Automated Testing is a good concept. Most of the testers go for manual testing in spite of huge cost benefits by automated testing. The following reason is cited for not using automated testing,

Quote:
Changes in Web Interface/User Interface will make the test automation not feasible.


There are ways, we can overcome these issues in test automation. In this post, I am going to discuss one of the methods to do the test automation.

Quote:
Create scripts using defined functions instead of recording every script.


I've described what is going to be discussed in the above line. Let me elaborate this for easy understanding.

The script for login to the OpManager web interface recorded by QEngine will look like this,

Code:

launchApplication("about:blank")
changeURL("http://opman-winxp/",5)
setWindow( "AdventNet OpManager",1)
setText("userName","admin",1)
setText("password","admin",1)
clickImage("http://opman-winxp/webclient/common/images/Login_submitBut.gif",6)


Instead of recording the above steps every time or copying this to the every script, lets define the function for this,

Code:

def login(usename,password):
launchApplication("about:blank")
changeURL("http://opman-winxp/",5)
setWindow( "AdventNet OpManager",1)
setText("userName",usename,1)
setText("password",password,1)
clickImage("http://opman-winxp/webclient/common/images/Login_submitBut.gif",6)


Call the login function wherever is needed,
Code:

login(admin,admin)


It is pretty easy to use and simple too. Assume that the name of the image is changed. Just change the name of the image in the login function.
i.e.,
Code:

def login(usename,password):
launchApplication("about:blank")
changeURL("http://opman-winxp/",5)
setWindow( "AdventNet OpManager",1)
setText("userName",usename,1)
setText("password",password,1)
clickImage("http://opman-winxp/webclient/common/images/Login.gif",6)


There is no need to change in the scripts. So for so good. Now, you've got an idea of how to do this. Let's see the other two scenarios

1. User Interface changes here and there
2. A complete revamp of the User Interface.

Both the cases can be handled using the functions. For the second case, you may need to put an little extra effort to create the functions. One time recording is required to create these functions. Remember to use the SuiteLevelMap in QEngine to use these functions.

Send your feedback to rajasankar at adventnet dot com.