ScreenCapture in UI Automation
In UI automation, how to know if the script played correctly?
One way is check the log messages and the check the output. That will be an cumbersome process to do. The better way is to see screenshots of the page. QEngine has a function to do this.
| Code: |
| saveScreenShot(outFileName,waittime) |
| Code: |
|
import time def screenshot(): filename=time.strftime("%Y_%m_%d_%H_%M_%S") saveScreenShot(filename,"1") |
| Code: |
|
import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import java.io.File; import java.util.Calendar; public class SaveScreen { public static void main (String args[]) { } public void saveScreen() throws Exception { Calendar now = Calendar.getInstance(); int year = now.get(Calendar.YEAR); int month = now.get(Calendar.MONTH); int day = now.get(Calendar.DAY_OF_MONTH); int hour = now.get(Calendar.HOUR_OF_DAY); int min = now.get(Calendar.MINUTE); int sec = now.get(Calendar.SECOND); String fileNameone = "Screenshot_" year "_" month "_" day "_" hour "_" min "_" sec ".png"; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle screenRectangle = new Rectangle(screenSize); Robot robot = new Robot(); BufferedImage image = robot.createScreenCapture(screenRectangle); ImageIO.write(image, "png", new File(fileNameone)); } } |
| Code: |
|
String fileNameone = "Screenshot_" year "_" month "_" day "_" hour "_" min "_" sec ".png"; |
| Code: |
|
String fileNameone = foldername "Screenshot_" year "_" month "_" day "_" hour "_" min "_" sec ".png"; |
As you know QEngine based on Jython(Java implementation of Python), you can write Java code and import that in QEngine.
| Code: |
|
public class test { public static void main(String args[]) { } public void work() { } } |
| Code: |
|
import test as te t=te(); use the method mentioned there def makework(): t.work() |
| Code: |
|
workfile.py contains import test as te t=te(); def makework(): t.work() |
| Code: |
|
from workfile import * |
| Code: |
|
from workfile import makework |
Hi All,
We have published Performance Testing Evaluation Guide in the QEngine website in the below link,
or You can download it as PDF from the below link,
Raghavan
If you encounter the dynamic windows in the UI automation, you can easily handle them.
Here are the functions available
| Code: |
| setDynamicWindow(parenttitle,parentindex=1,framepropertyname="NONE",framepropertyvalue="NONE",frameindex=1)
closeDynamicWindow(parenttitle,parentindex=1) |
| Code: |
| getLastWindowTitle()
getWindowTitle() getWindowURL() getLastWindowURL() |
| Code: |
|
setDynamicWindow("Test page",1,"NONE","NONE",1) closeDynamicWindow("Test page",1) |
| Code: |
|
setDynamicWindow("Test page",1,"title","mypage",1) closeDynamicWindow("Test page",1) |
| Code: |
|
gwt=getWindowTitle() gwtn=getWindowTitle() if gwt!=gwtn: setDynamicWindow(gwtn,1,"NONE","NONE",1) closeDynamicWindow(gwtn,1) |
| Code: |
|
gwt=getLastWindowTitle() gwtn=getWindowTitle() if gwt!=gwtn: setDynamicWindow(gwtn,1,"NONE","NONE",1) closeDynamicWindow(gwtn,1) |
| Code: |
|
gwt=getLastWindowTitle() gwtn=getWindowTitle() if gwt!=gwtn and gwt!= setDynamicWindow(gwtn,1,"NONE","NONE",1) closeDynamicWindow(gwtn,1) |
Hi All,
We received a good question from one of our customer. The question is
Why should i parameterize the transactions in Load Testing ?
It is indeed a nice question. Actually his question is, i am not configuring those parameters while recording. Then how do i know what are the parameters it takes and its value.
Here is the solution. Yes the user don't know what are all the parameters it takes while submitting a page. Hence in QEngine we introduced a feature called Auto parameterization.
What is Auto Parameterization ?
Auto parameterization facilitates to automatically extract the parameters from the associated reference page and use it while submitting the particular page to the server.
This is what happens while submitting the page while browsing in the browser.
This feature will work perfectly for most cases.
But for some cases the server may require unique value for each virtual user. In those cases, you may be required to parameterize value for the username, password and those parameters which you input during recording in the browser.
For this QEngine easy to use user interface namely Parameterization screen. It will list all the parameters for each URL separately, thus user can easily configure the value for the parameters. QEngine provides various options to parameterize such as Dataset / Cookie / Java script / Previous Response Content / HTML Element / Random values etc.
To know more on parameterization look at the below URL:
There are still more improvements can be done in parameterization. This will happen in future QEngine releases.
Raghavan
[/b]
There is an endless debate going on in the testing world regarding the strategy for automation testing. What to use, scripting or record/paly back tool?
Before commenting which one is best, we need to understand what are the pros and cons these two.
Let us see pros and cons of scripting
pros
1. Standard scripting language and standard library
2. No vendor scripting
3. Version Control
4. Running with own testsuite or with standard library
cons
1. Need to build from scratch
2. Time consuming process
3. Suited for individual need. May not be applicable to other software
4. Need to identify the elements from source manually.
For record/playback tool,
pros
1. Easy identification of elements
2. Maintenance will be taken care by vendor
3. Will come with utilities to run the test suite
4. Easy setup and running
cons
1. Maintaining the scripts is difficult.
2. Version control may not be available.
3. Vendor scripting may have a deep learning curve
Both the options offer some advantageous. If we can combine both, we can reduce time and do the things in a hassle free manner. That will offer best of both worlds, then it is easier to do automation, Isn't?
So the ideal tool should have the version control, minimal vendor scripting, options for one or more standard scripting languages. Next time when you evaluate an tool, check these options in it.
Rajasankar
rajasankar at zohocorp dot com
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
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')
|
| Code: |
| fireEventOnElement(tagName,propertyName,propertyValue,index,actionName,actionValue='',regExpRequired='false')
|
| Code: |
| getElementProperty("A","href",propertyValue,index,"href",regExpRequired='false') |
| Code: |
| getElementProperty("A","href",".*",index,"href","true") |
| 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 |
| Code: |
|
for i in range(0,len(values)): setLastWindow() fireEventOnElement("A","href",values[i],i,"click","NONE","false") |
| Code: |
|
for i in range(0,len(values)): setLastWindow() url=" fireEventOnElement("A","href",url,i,"click","NONE","false") |
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/
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