Sunday, December 13, 2009

Flex charts automation

Last few months, I was looking for solutions to automate flex charts. Charts automation is different from other GUI functionality automation. Idea is to develop the framework or reusable library, which is the combination of charts and flex objects. Flex is a new technology and support is critical. In other end, Charts verification is different than regular testing. In charts, tester needs to validate the values, position of axes, ticks and colors etc.

I was going through few articles and blogs for flex automation. I tried few commercial tools and few open source tools. I couldn't see any tool is fitting for my requirements. Many tools are having support for Flex environment. But none of the tools are supporting chart automation context sensitive based.

Flex chart requirements

  1. Each pie or bar value
  2. Data point value for each chart area
  3. Data tip or tooltip for each pie or bar or data point
  4. The color series for each object pie or bar or line)
  5. Each axis tick ( X, Y and Y2 axes)
  6. Font style, font size, font color for any object within chart
  7. Data label (pie or bar or line)
  8. Identify legend names
  9. Chart header and footer
  10. Axis values or labels

Sunday, November 8, 2009

Class concept in VBScript

In VB, Classes can be created using Class Module. Basic Module files are used to have user-defined procedures and variables. Many of the VB Scripts are designed by structure programming.

Using VBScript, one can apply OOPs based scripting also. Initalizing code should be added in Class_Initialize procedure. Similarly terminating code should be added into Class_Terminate procedure. Below I've given a sample VBS code for class implementation.

Sample code from Net: VBScript Class to Send Mail With CDOSYS
Sample VBS code for CLASS implementation

'' UtilClass.vbs ' Purpose: To illustrate Class concept in VBScript Class StringLib Private Sub Class_Initialize ' Class initialization MsgBox "Initializing StringLib class" End Sub Private Sub Class_Terminate ' Class termination -end of life MsgBox "Terminating StringLib class" End Sub ' Purpose : Checks the given file is avialable or not. Function FileExists(strPathName) Dim ObjFSO Set ObjFSO = CreateObject("Scripting.FileSystemObject") If ObjFSO.FileExists(strPathName) = False Then FileExists = -1 Else FileExists = 0 End If Set ObjFSO = Nothing End Function ' Purpose : To replace {dot} with {index}{dot} in the file name. Function ReplaceFileName(sFileName, iMySheetIndex) Dim RepChar, SearchChar SearchChar = "." ' Search for ".". RepChar = CStr(iMySheetIndex) & SearchChar ReplaceFileName = Replace(sFileName, SearchChar, RepChar) End Function End Class 'Using StringLib class Dim sText Dim sReplaced Set libStr = New StringLib sReplaced= libStr.ReplaceFileName ("c:\mytests.xls", 5) MsgBox "Replaced Text: " & sReplaced Set libStr = Nothing

Monday, October 19, 2009

Silk4Com

Silk4com is a COM interface for open agent. Still it is under development. It is an open source project and hosted on google code pages. I would say, it is an innovative idea.

URL: Silk4Com Project page

Summary from Project page
"This project is an add-on for SilkTest 2009. The goal of this project is to provide a COM interface for the Open Agent, which can be used by many different scripting languages to drive the Open Agent. With silk4com you can use most of the JTF API in VBScript, JavaScript or even in VBA, without the need of a Java Compiler and JUnit. "

I tried a sample script and it works fine.
VBS Code with Silk4Com

Sub SimpleTestcase2(browser) Set searchField = browser.Find("//input[@name='q']") searchField.hugo = "asd" WScript.Echo(searchField.hugo) '' Added by Palani searchField.setText("silk4j tutorial") Set btn = browser.find(".//input[@type='submit' and @name='btnG']") 'Set btn = browser.find(".//DomButton[@type='submit' and @name='btnG']") ''Not working btn.click() End Sub
Silk4j Code
@Test public void testSimpleGoogleSearch() throws Exception { // DomTextField[@title='Google Search' and @maxLength='2048' and @size='55' and @name='q' and @autocomplete='off'] DomTextField searchText = (DomTextField)browser.find (".//DomTextField[@title='Google Search' and @name='q']"); searchText.setText(""); searchText.setText("silk4j tutorial"); DomButton btn = (DomButton)browser.find( ".//DomButton[@type='submit' and @name='btnG']"); btn.click(); }

Sunday, September 27, 2009

Extract info from Logs

One of my projects used to update set of log files for each action and scheduled actions. Exceptions are logged in those log files. Log file size is maintained upto 5 MB. We are unable to get the proper logs, if scripts are running more than 15 minutes. Entire suite runs almost 75 hours continuously.

Many times, we were unable to re-look at the exceptions in the logs for particular test case failed time. I thought to develop a vbscript to capture the exceptions from log file for frequent intervals and then write into another text file. It can be used for manual testing too. Here I made two things. First is, script has to parse the log file for the given string. Second is, script should not update the log information, which is already available. I meant, the same information should not be added multiple times.

Code to take only unique info It returns the information as Array. Array size is determined in run-time.


'-------------------------------------------------------------------------
' Method : TrimArrayToExtract
' Author : T. Palani Selvam
' Purpose : Remove the array elements based on given info (sItemToCheck).
' Parameters: arrInput - Array String, Contains logging message.
' sItemToCheck - String, to check the element match. Last element in the text file
' Returns : String - Array. Returns remaining elements from the given array.
' Caller : - Nil
' Calls : - Nil
'-------------------------------------------------------------------------
Function TrimArrayToExtract (arrInput, sItemToCheck)
Dim iArrItem
Dim sTemp
Dim arrOutput()

iIndex=0
If (IsNull(sItemToCheck) Or IsEmpty(sItemToCheck) Or (Trim(sItemToCheck)= "")) Then
TrimArrayToExtract=arrInput
Exit Function
Else
If (IsArray(arrInput)) Then
'If (Not (IsNull(arrInput) Or IsEmpty(arrInput)) And (UBound(arrInput)> 1)) Then
If (Not (IsNull(arrInput) Or IsEmpty(arrInput) Or (UBound(arrInput)=0)) ) Then
'WScript.Echo "ArrInput : " & arrInput
For iArrItem=0 to UBound(arrInput) ''-1
ReDim Preserve arrOutput(iIndex)
sTemp=arrInput(iArrItem)
If (sTemp=sItemToCheck) Then
iIndex=0
Erase arrOutput
Else
arrOutput(iIndex)=sTemp
iIndex=iIndex+1
End If

Next
End If
End If
End If

TrimArrayToExtract=arrOutput

End Function


Code for Extracting the information from Log file It returns the information in Array.

'--------------------------------------
' Method : ExtractInfoFromLog
' Author : T. Palani Selvam
' Purpose : To extract the lines from a log file based on given info.
' Parameters: sFileName - String, contains the log filename with full path.
' sInfo2Extract - String, Info to search.
' Returns : Array of String
' Caller : - Nil
' Calls : - Nil
'--------------------------------------
Function ExtractInfoFromLog (sFileName, sInfo2Extract)

Dim objFSO, objTextFile, sLine
Dim iPos
Dim arrExtract()
Dim iLinesToDo, iArrIndex, iLimit

Const ForReading=1
Const NoOfLines=10


iArrIndex=0
iLinesToDo=0
iLimit=1

Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(sFileName) Then

Set objTextFile = objFSO.OpenTextFile(sFileName, ForReading)

Do while Not objTextFile.AtEndOfStream
sLine = objTextFile.ReadLine
'Wscript.Echo sLine
If (iLinesToDo > 0) Then
arrExtract(iArrIndex)=sLine
iLinesToDo=iLinesToDo-1
iArrIndex=iArrIndex+1
Else

iLinesToDo=0
iPos=InStr(sLine,sInfo2Extract)
'WScript.Echo("iPos " & CStr(iPos))
If (iPos>0) Then
'WScript.Echo("Entered into If loop to extract from line: " & sLine)

'' iLimit = UBound (arrExtract) + NoOfLines
iLimit = iLimit + NoOfLines
ReDim Preserve arrExtract(iLimit)

arrExtract(iArrIndex)=sLine
iLinesToDo=NoOfLines-1
iArrIndex=iArrIndex+1

Else
iLinesToDo=0

End If
End If

Loop

End If

objTextFile.Close

Set objTextFile = Nothing
Set objFSO = Nothing

ExtractInfoFromLog=arrExtract
End Function

Note: Few user-defined functions might be used.

Sunday, September 20, 2009

Is KeyWord Driven Framework enough?

Recently I heard the term Key-Word Driven Framework from many testing people. Even people are showing interest to know about it and to implement it. Sometimes people are saying unknowingly as Keyboard Driven Framework.

Few months back, I have implemented Keyword Driven framework in one of our projects. We are using Silktest and data files are kept in XML format. The other automation team members also impressed with this kind of implementation. I found this article Automated Testing Institute - Building A Keyword Driver Script In 4 Steps useful to the professionals, who wants to implement KeyWord Driven framework.

After that the expectation goes to implement KeyWord Driven Framework to all automation projects. I am not against to Keyword Driven Framework. It can be used for many projects. But it is not the only one solution for all our automation issues or dependencies. For example, chart automation. For charts, verification will be different and It is difficult to generalize. May be Flex charts can be used if tools are able to identify all parts of charts. One more is unlimited Keywords. Assume that one project contains more than 500 keywords and the automation guys should know the functionality for all those words. It is definitely issue, if number of keywords increased beyond the limit. Currently I'm thinking the scenarios, where KeyWord or Table Driven Automation frameworks can not be used or should be avoided. Below I have listed the cases.

  1. More Context based Menus
    The menu items are shown based on the screen and object.

  2. Multiple Application interactions in single project

  3. Total Keywords beyond 200
    Testers should memorize all keywords. It is similar to remember Differential Calculus and Integral Calculus functions. One should remember keywords for action and verification for all set of objects.

  4. Many hierarchies for Object identification.
    It can be solved if testing tool supports X-path for object identification.

  5. Complex data.
    One of my projects required minimum 40 string data to create a report and it is just a first step for any test case. Also the data may change in the future. More than 1000 cases required like that. I can generalize the inputs data and it is difficult to maintain and modify the data.


To know the automation framework concepts, you can go through following links.

Test Automation White Papers
My Thoughts about Automation
What is an Automation Framework - from Dhanasekar's blog
Wikipedia - Test Automation
Wikipedia - KeyWord Driven Testing

Saturday, September 19, 2009

PDF File Verification

Sometimes testers need to verify the PDF file contents. Few times I have seen the questions related to this in few forums. Verifying graphical contents are not so easy. But we can verify the text content in three ways.

First way - Scripting
You can use any other scripting to verify PDF. You can use Java Script or VB Script. In this way, PDF file will not be opened physically and retrieve the contents internally. For more info, Read through this link - Accessing PDF

Second way - Utility
Convert the PDF files to text by using any utility and then verify text files. There are many freewares available for this kind of purpose. I suggest TextMining Tool. In this way also, PDF file is not opened physically.

Sample code in Silktest

 
STRING sPDF2TxtUtil = "F:\TextMining\minetext.exe"
sCmdExecute = "{sPDF2TxtUtil} {sPdfFile} {sConvertedFile}"
Print ("Command: {sCmdExecute}")
SYS_Execute (sCmdExecute,lsCmdOut)
Print (lsCmdOut)

Third way - Using Adobe Reader
In this way, Open the pdf file using Adobe Reader. Then go to File Menu and then click sub menu Save As Text. Now you can store pdf contents as text file and you can use the text file for verification.

To compare the PDF files, you can use comparison softwares (for ex Beyond Compare from 3.0). They internally convert to text file and then comparing it.

Tuesday, September 15, 2009

Java and myself

In my first job, I have used VB and Java. At that time, I was new to Internet. I used to develop programs in VB6 and Java2 around Internet programming. I wrote java programs using notepad and Emacs editors. After that many years I ran behind GUI automation tools such as VisualTest, WinRunner, QTP and Silktest. Sometimes I'm using VBScript for few testing tasks.

Recently many tools are supported to use Java as test language. Again I'm going to re-look at java. I was looking into my old java code. I tried to compile few java programs with recent Java version 1.6.0.14. Few classes are deprecated. I have used this command javac ZDownloadURL.java -Xlint:deprecation to compile java program.

In Sun Developer network, one tutorial was there for Basic Java. Link :Essentials of the Java Programming Language

Below program can be used to download any web page. I tried my blog and it still works.
To Compile - javac ZDownloadURL.java -Xlint:deprecation
To run the program - java ZDownloadURL



// $Id$

/**
*
*
* Created: Tue Oct 24 18:51:26 2000
*
* @author palani selvam
* @version $Revision$
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.io.*;


/* To Run this file, put command as
java -Dhttp.proxyHost=192.168.27.2 -Dhttp.proxyPort=3128 ZDownloadURL
*/


public class ZDownloadURL extends JFrame implements WindowListener,ActionListener {
String URL; //Given URL
// String inputLine; //To read Line by line
String title="Downloading Trial"; //To give title of the URl

static JFrame frame; //Parent Level Container
JButton save; //Save Button
JButton down; //Declare Download Button
JButton exit; //exit Button
JTextField url; //To enter URl
JTextArea contents; //Contents of specific file
//JPanel panel; //Second level Container
Container panel;
//JPanel temp;
Container temp;


public ZDownloadURL() {
//frame=new JFrame();
super.setTitle(title);
super.setForeground(Color.blue);
super.setBackground(Color.yellow);

panel=getContentPane();
temp=new JPanel();
temp.setLayout(new BorderLayout());
temp.setSize(10,20);

GridBagLayout grid=new GridBagLayout(); //Set GridBagLayout
GridBagConstraints c=new GridBagConstraints();
c.fill=GridBagConstraints.HORIZONTAL;

panel.setLayout(grid);
// grid.setConstraints(c); //Add GridbagConstraints

url=new JTextField(20);
contents=new JTextArea(30,30);
contents.setLineWrap(true); //To Wrap lines in TextArea

/***
* To create ScrollBars to JTextArea
*
*/

JScrollPane pane = new JScrollPane(contents);
temp.add(pane);



/***
contents.setColumns(20);
contents.setRows(10);
contents.setLineWrap(true);
contents.setWrapStyleWord(true);
contents.setSize(10,20);

temp.add(contents);
**/



down=new JButton("DownLoad");
save=new JButton("Save");
exit=new JButton("Exit");
JLabel label=new JLabel("Enter valid URL");

c.gridx=0;
c.gridy=0;
c.insets=new Insets(5,0,0,0);
grid.setConstraints(label,c);
panel.add(label);

c.gridx=1;
c.gridy=0;
c.gridwidth=1;
//c.gridheight=2;
c.insets=new Insets(5,0,0,0);
grid.setConstraints(url,c);
panel.add(url);

c.gridx=2;
c.gridy=0;
c.insets=new Insets(5,0,0,0);
grid.setConstraints(down,c);
panel.add(down);

c.gridx=0;
c.gridy=1;
c.gridwidth=20;
c.gridheight=10;
c.insets=new Insets( 20,0,0,0);
grid.setConstraints(temp,c);
panel.add(temp);


c.gridx=0;
c.gridy=12;
c.gridwidth=1;
c.insets=new Insets(10,0,0,0);
grid.setConstraints(save,c);
panel.add(save);

c.gridx=1;
c.gridy=12;
c.gridwidth=1;
c.insets=new Insets(10,0,0,0);
grid.setConstraints(exit,c);
panel.add(exit);

exit.addActionListener(this);
save.addActionListener(this);
down.addActionListener(this);
// frame.addActionListener(this);

// frame.add(panel);


}


public void windowActivated(WindowEvent we) {

}

public void windowDeactivated(WindowEvent we) {

}

public void windowIconified(WindowEvent we) {

}

public void windowDeiconified(WindowEvent we) {

}

public void windowOpened(WindowEvent we) {

}

public void windowClosed(WindowEvent we) {

}

public void windowClosing(WindowEvent we) {

System.exit(10);

}


/***
* pass the URL as string
*/


public void Download(String _url) {
try {
URL myURL=new URL(_url);
BufferedReader in=new BufferedReader(new InputStreamReader(myURL.openStream()));

String inputLine;
contents.setText("");

while((inputLine=in.readLine()) != null) {
//contents.setText(contents.getText()+"\n"+inputLine);
contents.append("\n"+inputLine);

}
} catch(Exception ex) {

System.out.println(ex.toString());
}

}

public boolean checkURL(String _url) {
if((_url.indexOf("http"))!=0) {
return true;
}
else {
return false;
}
}


public void actionPerformed(ActionEvent ae) {
//String action=ae.getActionCommand();

URL=url.getText();
Object action=ae.getSource();

//To Download

if(action.equals(down)) {
/** if(checkURL(URL)) {
Download(URL);
}
else
JOptionPane.showMessageDialog(new JFrame(),"Enter Valid URL in TextField!","Information",JOptionPane.INFORMATION_MESSAGE);

**/

Download(URL);


}


//To save that URL's contents
//Not implemented

if(action.equals(save)) {
JFileChooser fc=new JFileChooser();
int returnVal=fc.showSaveDialog(new JFrame());

if(returnVal==JFileChooser.APPROVE_OPTION) {
File file=fc.getSelectedFile();
super.setTitle(file.getName());
}
}

if(action.equals(exit)) {
System.exit(0);
}

}

public static void main(String args[]) {
frame=new ZDownloadURL();

frame.setSize(500,400);
frame.pack();
frame.show();

}

} // ZDownloadURL

/*
* $Log$
*/

Sunday, August 30, 2009

Skills for Automation

Last few months I was in interviewing candidates for Silktest and QTP. Many of them are good at tool related technical terms and concepts. But they are not comfortable to write few string handling functions. Main issue is many of the testers are not interested in hard-core programming. I strongly feel that programming skills is required apart from framework implementation. I used to give following tasks to any new comer for automation side.

Assignments for Automation

  1. Write a script to create a file,Read a file,Append a file and Delete it.
  2. To invoke browser and navigate through links,URL&button.
  3. To get Current Time like "24May2005-10hh-20mm-45ss"
  4. Find - Which window is active now in the taskbar.
  5. Prepare a script and the results should be stored into Excel sheet and Text file.
    Excel sheet should contain one line for each testcase and Text file should contain the information for all events.
  6. Automate simple Testcase without using GUI file. You should pass physical description directly.
  7. Retriving data from Database,Excel.
  8. Update data in Database,Excel.
  9. Access DLL functions.
  10. Implement function for following string problems
    Find and Replace in a given string.
    Get position of substring for given times.
    Get file name only from file's full path.
  11. Print list of files available in a directory.
  12. Create functions to create the log
    First log should contain all the details of the Script Actions.
    Second log file should contain only pass/fail detail of Testcases/Scenarios.
  13. Using any XML Parser, try to parse the XML contents based on given tag.

Sunday, August 16, 2009

Silktest 2009

Recently MicroFocus released Silktest 2009. In this release, Silktest has many enhancements for Open Agent and Eclipse Plugin.

Silktest 2009 Page on MicroFocus
Silktest 2009 - Release Notes
Silktest - Supporting documents

New in Silktest 2009

  • AJAX Testing with xBrowser
  • Support for Recording Testcases that Use Dynamic Object Recognition
  • Silk4J Eclipse Plugin
  • New Basic Workflow for Applications that Use the Open Agent
  • Dynamic Object Recognition Supports Locator Keywords
  • The Open Agent Supports Windows Forms Applications
  • Enhancements in the XPath Syntax
  • AnyWin Class Includes Several New Functions and Methods
  • SWTTree Class Includes Several New Functions
  • Several SYS Functions are Supported on the Open Agent
  • SilkTest Recorder

MicroFocus Acquisitions

Last month Borland was acquired by MicroFocus. Microfocus has acquired Compuware too. Borland and Compuware have similar kind of testing products. By these aquisitions, MicroFocus is the second largest market leading vendor in Testing tools.

Borland Testing tools:

  1. SilkTest - Functional Testing
  2. SilkPerformer -Performance Testing
  3. SilkCentral Test Manager - Test management

Compuware Testing tools:
  1. TestPartner - Functional Testing
  2. QALoad -Performance Testing
  3. QADirector - Test management

Apart from above products, Borland and compuware had other products. See the MicroFocus - Testing ASQ Products for more information.

Saturday, August 8, 2009

Programmers and Testers

I used to hear the rivalry between developers and testers from my friends. It is common in IT community. The depth of rivalry depends upon the maturity of both testers and developers. Every tester would have experienced this.

Many programmers are experts and specialized in particular technologies. Their duty involves mostly with complicated things. It might be new technology, new tool or new domain. They are not ready to do routine tasks as testing their code fully for each change. Many developers assumes that testing is an easy job and low end work. Sometime it might go as testing team is the wastage of resources, time and money.

Even if any rivalry occurs, it should be bust quickly. Either developer or tester should not take it personal. At the end, both are working for same goal. I hope, now these assumptions would have come down. Now a days, testers are involving automation framework design, unit testing etc.

Following tophics are listed under Interacting with Programmers in Book: Lessons Learned in Software Testing by Cem Kaner, James back and Bret Pettichord

  1. Understanding how programmers think
  2. Develop programmer's trust
  3. Provide Service
  4. Your integrity and competence will demand respect
  5. Focus on the work, not the person
  6. Programmers like to talk about their work. Ask them questions
  7. Programmers like to help with testability

Two weeks back, I was reading Debasis Pradham (Software Testing Zone) blog. Couple of his posts also talking about this feud and how to deal with them.

In Stickyminds.com, I found an article related to this tophic - Across the Great Divide: The Language of Common Ground between Testers and Developers By Susan Joslyn

Sunday, August 2, 2009

Selenium Overview

Selenium is a suite of tools to automate web app testing across many platforms. It is a GUI based automation tool. Initially it is built by ThoughtWorks. It supports various browsers on various platforms.

Selenium Home Page
Selenium Projects
Tool History
Platform Support

Selenium Projects
Selenium has many projects. Following projects are mostly used by testers.


  1. Selenium IDE (IDE)
    Selenium IDE can be used only in FireFox. It is an add-on for FireFox. User can record the actions and can edit and debug the tests. It can be used to identify IDs, name and XPath of objects. Only one test at a time.

  2. Selenium Core (CORE)
    Selenium Core is the original Javascript-based testing system. This technique should work with any JavaScript enabled browser. It is the engine of both, Selenium IDE and Selenium RC (driven mode), but it also can be deployed on the desired application server. It is used specifically for the acceptance testing.
    User can record the tests using Selenium IDE and can use the same tests to run in other browsers with minimal modifications. It provides support to run the tests in HTA (HTML Applications) Mode. This mode works only in IE.

  3. Selenium Remote Control (RC)
    Selenium Remote Control is a test tool that allows user to write automated web application UI tests in few programming languages against any HTTP website using any mainstream JavaScript-enabled browser. User can write the tests (More expressive programming language than the Selenese HTML table format) in Java, DotNet, Perl, Ruby and PHP. Also it supports few testing frameworks.

  4. Selenium Grid
    Selenium Grid allows easily to run multiple tests in parallel, on multiple machines, in an
    heterogeneous environment by cutting down the time required for test execution. Using this, user can run multiple instances of Selenium Remote Control in parallel.

Supported browsers
Selenium tools can run in following browsers.
  • Internet Explorer
  • FireFox
  • Opera
  • Safari
  • Seamonkey

Supported Operating Systems
Users can execute the selenium tests in following OS.
  • Windows
  • Linux
  • Solaris
  • OS X

Supported Programming languages
Below languages are supported by Selenium RC.
  • C# (DotNet)
  • Java
  • Perl
  • Ruby
  • Python
  • PHP

Lot of presentations and documents about Selenium are shared in SlideShare. You can do simple search and get many docs.

Recorded Selenese code through IDE
 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="" />
<title>GoogleSearch2</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">GoogleSearch2</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>q</td>
<td>silk4j tutorial</td>
</tr>
<tr>
<td>click</td>
<td>btnG</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>30000</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>q</td>
<td>Silktest extension kit</td>
</tr>
<tr>
<td>click</td>
<td>btnG</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>30000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>btnG</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>30000</td>
<td></td>
</tr>

</tbody></table>
</body>
</html>

Java code - Selenium RC
 

package com.example.tests;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

public class NewTest extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://www.google.com/", "*chrome");
}
public void testNew() throws Exception {
selenium.open("/");
selenium.type("q", "silk4j tutorial");
selenium.click("btnG");
selenium.waitForPageToLoad("30000");
selenium.type("q", "Silktest extension kit");
selenium.click("btnG");
selenium.waitForPageToLoad("30000");
selenium.click("btnG");
selenium.waitForPageToLoad("30000");
System.out.println("New Test is completed.");
}
public void tearDown() {
browser.stop();
}
}

Sunday, July 19, 2009

Verifying Email notifications

For long time, I was looking a solution to automate the verification of email contents. It required to verify for few user accounts, attachments like Excel, PowerPoint and PDF docs. We have few critical features, which required to verify email contents and attachments. Silktest does not have any built-in functions for this activity. However I have to find a solution. The solution should supports IE6 and IE7 browsers and Windows 2000, Windows XP and Vista OS. I had four choices in mind. They are,

  1. Using a command line utility
  2. Using MS Office Outlook COM interface
  3. Using Collaboration Data Objects (CDO) Interface with Outlook Express
  4. Worst case - Automate any email client with UI

Automate any email client with UI
This option was last one. Because I do not want to automate with User Interface. We can build the solution in couple of weeks effort. The issue is the changes with that client. I have to look on support for different Operating Systems such as Windows XP and Vista.

Using Collaboration Data Objects (CDO) with Outlook Express
In my first company, I have used CDO with Visual Basic. See my previous post - Checking Mail Notification. I got a surprise, while I was searching information for CDO Help. Microsoft has stopped the updates on Outlook Express. Earlier Internet Explorer Intallation was bundled with Outlook Express.

Using MS Office Outlook COM interface
I am familiar with VB script. I have used Outlook COM interface [CreateObject("Outlook.Application")] earlier. The issue is, the particular user account mailboxes should be opened, while executing VB Script. Also I thought the license and installation costs.

Using a command line utility
I have searched many times and found a utility. GetMail is a command line utility and it is working in all windows OS. It is available at GETMAIL for Windows It is a cheapest and best utility to fit for my requirements.

Different Cmdline switches of GetMail
Getmail has different switches for various purposes. You can opt appropriate switches as per your requirement.
 

GetMail v1.33: WinNT console utility to download a mailbox's mail.
syntax:
Getmail -u <user> -pw <password> -s <server> [optional switches (see below)]
Getmail -install [ see install details below ]
Getmail -profile [-delete | "<default>"] [profile1] [profileN] [-q]
Getmail -h [-q]
Getmail -forceextract filename

-install <server> <userid> <password> [<delete> [<xtract> [<try> [<port> [<profile>]]]]]
: set's POP3 server, login, password, whether to delete or not (Yes/No),
whether to automatically extract base64/7bit/UU encoded files or not (Yes/No),
number of tries and port for profile
(<delete> <xtract> <try> and <port> may be replaced by '-').

-u <userid> : Specify userid on remote pop3 host
-pw <password>: Specify password for userid on remote mail host
-s <server> : Specify mail server (pop3) to contact
-nodelete : Do not delete messages after downloading (default)
-delete : Delete messages after downloading
-noxtract : Do not extract base64/7bit/UU files after downloading (default)
-xtract [defname]: Extract base64/7bit/UU encoded files after downloading messages
defname is an optional default filename for the extracted file
-domainstamp : Prepend sender's domain name to extracted attachments
-headersonly : Download only the headers of the message
-port <port> : port to be used on the server, defaults to POP3 (110)
-p <profile> : send with SMTP server, user and port defined in <profile>.
-q : supresses *all* output.
-n <n> : Only get 'n' messages
-m <n> : Only get message # n
-b <n> : Retrieve messages beginning from # n
-plain : Extract text/plain segments too (usually ignored)
-h : displays this help.
-try <n times>: how many attempts to access mail. from '1' to 'INFINITE'
-ti <n> : Set timeout to 'n' seconds.
-forceextract fn: Attempt to extract any encoded messages in 'fn'

Installing GetMail
You need to follow the belows steps to install it. Assume that getmail.exe is stored under D:\tools.
  1. First open a command prompt.
  2. Go to D:\tools folder.
  3. Install it by executing below commmand
    Getmail -install mailserver script1@auto.com wrongpwd
    Here mailserver means the mail Server name or IP address

Verifying GetMail
To verify the GetMail installation, you can use following steps.
  1. Goto folder D:\tools
  2. Execute the following command for any user.
    For example, D:\tools\getmail.exe -u script1 -pw TestPassword -s mailserver
  3. Check any error exists on command prompt.
  4. Check on that folder, whether all the mails are downloaded or not. You can see mails like msg1.txt,msg2.txt,..etc

4Test code - To Verify the GetMail
 

[ ] sMailCommand = "{gsToolsDir}\getmail.exe -u {sUser} -pw {sPass} -s {sServer} {sAdditionalSwitch}"
[ ] Print ("Mail Command: {sMailCommand}")
[+] // if (bDeleteAfterReceive)
[ ] // sMailCommand = "{gsToolsDir}getmail.exe -u {sUser} -pw {sPass} -s {sServer} -delete"
[+] // else
[ ] // sMailCommand = "{gsToolsDir}getmail.exe -u {sUser} -pw {sPass} -s {sServer} -nodelete"
[ ] // Checking any errors on command line output
[+] if( 0 != SYS_Execute( sMailCommand, lsGetmailOut ) )
[ ] ListPrint( lsGetmailOut )
[ ] LogError ( "FAIL. Unable to receive the mail." )
[ ] return FALSE
[ ]

Sunday, July 12, 2009

Top 10 Silktest blogs/forums

Earlier I have seen Dmitry Motevich's post 15 QTP sites/blogs/groups/forums. Similarly I have listed for Silktest.

  1. SQA Forums
    Initially it was QAForums. Many silktest users are participating here. You can find many silktest expertise in this forum. It is having more than 50k posts and sample code.
  2. Borland Support
    Tool vendor's support site. Recently borland made compulsory service contract to access Knowledgebase articles and silktest community. It has plenty of usefull KB articles.
  3. Silktest FAQ & Tips
    Great blog for Silktest FAQ and tips. It has detailed solutions for common silktest issues.
  4. Silktest and Automation Tips
    Here user can find Silktest tips, code and automation tricks. Also covering advanced features of Silktest.
  5. Silktest tips
    One more good blog with limited posts.
  6. Silktest Yahoo groups
    It is the only active Silktest yahoo groups. One can find many expertise here.
  7. Silktest Tutorial
    Having detailed tutorials for Silktest.
  8. Silktest on QACampus
    Few more Silktest information is shared here.
  9. Darshan's blog
    Contains mixed of silktest and python posts.
  10. CSDN blog
    Many posts are in Chinese language. Has covered most of the silktest features.


Also I would like to mention few popular silktest sites, which are not available now. Many of you would have seen Bret Pettichord's Software Testing Hotlist. But most of the Silktest links are not exist today. All of them having fundamental and advanced concepts of Silktest. Also they have shared 4test sample code and white-papers.

Jeff Hemsley-OOPs and Classes concepts
Non-exist Link: http://www.weirdness.org/jeff/articles/a_classes.html
Current Page: Classes, Objects, Dynamic Instantiation and Constructors: Is 4Test Really an Object-Oriented Language?

Tony Venditti's Silk Automation Page
Non-exist Link: http://www.iris.com/web/irisdevs.nsf/c404f3f7c0cc20458525618c00633c15/f41c9c2b9b8dc4508525666700747f56?OpenDocument
Info about him: IBM page

Silktest White Papers - ameliortech
Non-exist Link: http://www.ameliortech.com/stuff/toolkits/ST/st_whpap.htm

4Test Hints and Tips
Non-exist Link: http://www.testmap.com/4test/4test_support.htm

Automation Expertise Tutorials
Non-exist Link: http://www.automationexpertise.com/Tutorials/SilkOrganizer/pages/Parent.htm

Mr. Cluey's Kludge Page
Non-exist Link: http://www.sqa-test.com/mr_cluey/

Automation on Quality Tree website
Non-exist Link: http://www.qualitytree.com/autotest/qapartner.htm

Automation Junkies
Non-exist Link: http://www.automationjunkies.com/resources/experts.shtml

I think that I can put them here, If I am able to retrieve those missed pages from my storage or from others. What do you say?

Sunday, July 5, 2009

Silk4J Overview & Analysis

Silk4j was introduced from Silktest 2008. Hereafter user can use Java as test scripting language with the help of Silk4J Package. It is supported only with Open Agent. I hope that Borland might target developers too. User can write java unit tests as well as GUI tests.

From Silktest Help - Silk4J Eclipse Plugin

Silk4J enables user to create functional tests using the Java programming language. Silk4J provides a Java runtime library that includes test classes for all the classes that Silk4J supports for testing. This runtime library is compatible with JUnit, which means you can leverage the JUnit infrastructure and run and create tests using JUnit. You can also use all available Java libraries in your testcases.

The testing environments that Silk4J supports include:

  • Adobe Flex applications
  • Java SWT applications
  • Windows Presentation Foundation (WPF) applications
  • Windows API-based client/server applications
  • xBrowser applications


Silk4J with Open Agent - Google Search testcase

I have gone through documents such as Silk4J_QuickStartGuide_en.pdf and Silk4J_AdvancedUserGuide_en.pdf. I created the sample code and it works fine.

package com.palani;
import org.junit.Before;
import org.junit.Test;

import com.borland.silktest.jtf.Desktop;
import com.borland.silktest.jtf.TechDomain;
import com.borland.silktest.jtf.xbrowser.BrowserWindow;
import com.borland.silktest.jtf.xbrowser.DomButton;
import com.borland.silktest.jtf.xbrowser.DomTextField;

public class GoogleSearch {
private Desktop desktop = new Desktop();
private BrowserWindow browser;

@Before
public void setUp() throws Exception {

browser = (BrowserWindow)desktop.executeBaseState(
"C:/Program Files/Internet Explorer/iexplore.exe", null, null,
".//BrowserWindow", TechDomain.XBROWSER);
browser.navigate("http://www.google.co.in/");
}

@Test
public void testSimpleGoogleSearch() throws Exception {

DomTextField searchText = (DomTextField)browser.find (".//DomTextField[@title='Google Search' and @name='q']");
searchText.setText("");
searchText.setText("silk4j tutorial");
DomButton btn = (DomButton)browser.find(
".//DomButton[@type='submit' and @name='btnG']");
btn.click();
}
}


4Test with Open Agent - Google Search testcase
The same case is written in 4Test. SilkTest supports a subset of the XPath query language. It gives dynamic object recognition.

[ ]
[-] testcase GoogleSearch1 () appstate none //DefaultBaseState
[ ] STRING sUrl="http://www.google.co.in/"
[ ]
[-] if (! InternetExplorer.Exists(2))
[ ] InternetExplorer.Invoke ()
[ ] InternetExplorer.SetActive ()
[ ] InternetExplorer.Maximize ()
[ ]
[ ] WINDOW wMain = Desktop.Find(".//BrowserApplication")
[ ] WINDOW wBrowser = wMain.Find(".//BrowserWindow")
[ ]
[ ] wMain.SetActive()
[ ] wBrowser.Navigate (sUrl)
[ ] WINDOW wText1=wBrowser.Find(".//DomTextField[@title='Google Search' and @name='q']")
[ ] wText1.SetText("Silk4j Tutorial")
[ ] wBrowser.Find(".//DomButton[@name='btnG' ]").Click ()
[ ]
[ ] WINDOW wText2=wBrowser.Find(".//DomTextField[@name='q']")
[ ] wText2.SetText("Silktest Extension Kit")
[ ] wBrowser.Find(".//DomButton[@name='btnG' ]").Click ()
[ ]
[ ]


Selenium RC Java format - Google Search testcase

Selenium is a open source tool and can be used only web based applications. But user can choose different languages to develop the suite. Selenium tests can be written with Selenese, PHP, Perl, Python, Ruby, DotNet and Java.

import org.openqa.selenium.server.SeleniumServerTest;
import com.thoughtworks.selenium.*;
import junit.framework.*;
import org.openqa.selenium.server.SeleniumServer;

public class TestSearch extends SeleniumServerTest {
private Selenium browser;
public void setUp() throws Exception {
SeleniumServer seleniumServer = new SeleniumServer();
browser = new DefaultSelenium("localhost", 5555, "*firefox", "http://www.google.com");
seleniumServer.start();
browser.start();
}

public void testGoogle() {
browser.open("/webhp?hl=en");
browser.type("q", "hello world");
browser.click("btnG");
browser.waitForPageToLoad("5000");
assertEquals("hello world - Google Search", browser.getTitle());
}

public void tearDown() {
browser.stop();
}
}


Few Questions

Now Silktest and selenium both supports in Java language. Silktest supports many type of applications. In other end, Selenium supports many Operating Systems and browsers. I have few questions on Silk4J.
  1. Can Silk4J utilize silktest features such as TestcaseEnter,TestcaseExit,scriptEnter and ScriptExit?
  2. Target audience?
  3. Any Success stories (implementations)?

Saturday, June 27, 2009

Silktest Questions

Last two weeks, I was trying to compile all the silktest related questions. It helps me to dig, how much I know in Silktest. I have left out few areas. I did not cover much on the recent silktest features or additions. I have given just questions only not answers. For answers, you can try this blog - SilkTest FAQ and Technical Questions .

Silktest Basics

  1. What are the file types available in silktest and usage of that?
  2. What is the usage of SilkMeter?
  3. What is a SilkTest Agent?
  4. What is “appstate” in silk?
  5. What is the difference between appstate and testcase?
  6. What is the difference between testcase and function
  7. Can any testcase be called within another testcase?
  8. Can any testcase be called within function?
  9. How can you make shared variables in Silk?
  10. Tell me about options set file (*.opt)?
  11. What is 4test? Do you know about classic 4 test and Visual 4test?
  12. What is a test frame?
  13. Tell me silktest workflows?
  14. Where can you find all the methods for a class?
  15. What is test identifier and tag?
  16. What are the prefixes of every tag identifier while taking window declarations?
  17. If you want to record the mouse move event, then what you have to do?
  18. Explain Basic Workflow in silktest?
  19. Explain Data Driven flow in Silktest?
  20. Different types of tags and can we set the tag dynamically?
  21. What do you meant by Silk Extension?
  22. What are the different Variable pass-modes available and how will you use in scripting?
  23. How can you start one application?
  24. What do you mean by a DefaultBaseState and what role does it play in automated testing?
  25. When is the SilkTest Recovery System used?
  26. How can you run only the failed testcases in the second round of testing?
  27. How can you do database testing using silk?
  28. How will you implement immediate If statements?
  29. How silkAgent interacts with script statements?
  30. Description Equivalent to a function or method call.
  31. Array and List Declaration
  32. Can you give few of common silktest errors
  33. What are the different file opening modes available in silk?
  34. What is the difference between “Log Error”, “Log Warning”?
  35. What is the difference between “ExceptLog” and “LogError” function?
  36. How can you handle exceptions in silk?
  37. What is the difference between “raise” and “re raise” statements in silk?
  38. What are the uses of “Use Path” & “Use File” text field Silk’s option> runtime dialog box?
  39. What does it indicates “Agent.SetOption (OPT_APPREADY_TIMEOUT, 180)”?
  40. How can you identify each and every radio button under radio button group?
  41. What is extension enabler?
  42. How will you access Database, retrieve the records using Silktest? Is there any limitation?
  43. How do I add steps to DefaultBaseState?
  44. Can I call Silk Scripts from an external shell program?
  45. What are the default testplan attributes?
  46. How to define new testplan attributes?
  47. Where are the testplan attributes stored?
  48. How to assign attribute values to test cases?
  49. How to include a test case into a testplan?
  50. How record a test case into a testplan automatically?
  51. How to run all test cases in a testplan?


Application Related
  1. What are the extensions available for IE and Netscape?
  2. How can you develop script, to wait for complete navigation or what is the function to wait until browser is ready?
  3. What is the difference between Browser and Browser2 objects?
  4. How will you open a Browser (IE/Netscape/FireFox)?
  5. Why is a new layer of HtmlText being recorded by SilkTest 6.0?
  6. How can both Netscape and Internet Explorer declarations for SilkTest be consolidated into one set of declarations?
  7. What is the use of “SetUserOption”?
  8. What is the usage of "ShowBorderlessTables" option?
  9. What is the difference between BrowserChild and BrowserPage objects?
  10. How to specify a browser extension to a Web application?
  11. What is class map? What are the different ways of defining class map?
  12. What is option set? Have you ever used option set in silk?
  13. How will you invoke the application, which has login dialogbox?
  14. How will you invoke multiple applications in single test suite?
  15. Have you ever tested images using silk? What are the methods you have used?
  16. Custom objects - Not similar to any standard objects. For ex., Excel, SpreadSheet
  17. What is silk bean?
  18. What are the settings required to invoke a Java application?
  19. What are the settings required to identify Flex objects?


Advanced Silktest
  1. Explain about Open Agent
  2. Difference between Classic and Open Agent
  3. Explain about Silk4j.
  4. Explain about Extension Kit.
  5. Explain how silktest supports OOPs concepts? Give few examples.
  6. How will you extend a method, which is defined for a class?
  7. What does the recording statement do?
  8. How will you overwrite default script and Testcase procedures ?
  9. Have you automated any dynamic pages/controls? How have you done, explain?
  10. How silktest supports DLLs?
  11. How will you run the scripts into another machine?
  12. What are the steps or procedures, you will follow to make silktest suite as robust?
  13. Give an example of setting agent value at runtime?
  14. What is default base state in silk? How can you implement the default base state to its customized base state?
  15. When it is necessary to create a “plan” file instead of “suit” file in silk?
  16. What are the different tags available in “partner.ini” file?
  17. How can you define your own property set?
  18. Silk is having built in recovery system. How is it working?
  19. Few lines of code for some string manipulation operations.
  20. How do I set a option set file dynamically?
  21. How will you handle if a window has many parents?
  22. How will test the application remotely?
  23. Can you avoid the use of sleep()? How?
  24. Have you used Registry related functions?
  25. To create, or "spawn," multiple threads, which statements you will be going to use?
  26. Have you ever used “multitestcase”? Can you tell me in brief.
  27. What is LinkTester?
  28. What are the functions offered by DBTester?


Automation Framework
  1. What is automation framework?
  2. Tell me about few of the Industry standard automation frameworks
  3. Have you ever make an internationalization frame work using silk? What are the constraints you need to take care while making your silk framework as independent of OS, Language?
  4. Different types of framework with a brief explanation of each.
  5. Efficient ways of handling custom objects and Dynamically changing objects?
  6. Have you used XML and Excel files as your input data?

Thursday, April 30, 2009

Flex component automation with Silktest

Overview about Flex
Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross-platform rich Internet applications based on the proprietary Adobe Flash platform. MXML, an XML-based markup language, offers a way to build and lay out graphic user interfaces. Interactivity is achieved through the use of ActionScript, the core language of Flash Player that is based on the ECMAScript standard.

The Flex SDK comes with a set of user interface components including buttons, list boxes, trees, data grids, several text controls, and various layout containers. Charts and graphs are available as an add-on. Other features like web services, drag and drop, modal dialogs, animation effects, application states, form validation, and other interactions round out the application framework.

For more info, visit Flex Wiki page Wiki - Adobe Flex

Help from Vendors
Adobe has developed few libraries to support test automation for flex components. To know more about these libraries, you can go through following links.


Borland has given a separate document for flex configuration. You can search in Borland site for ‘QuickTour_Flex.pdf’. Similarly Adobe has published a document ‘Flex2_at_api.pdf’ for Testing Flex Components.

Even Silktest Help documentation contains few pages for Flex and Open Agent. You can check following Silktest Help pages:
  • Testing a Flex Sample Application Using a Dual Agent Approach
  • Enabling Extensions Automatically Using the Basic Workflow
  • Enabling Extensions for Embedded Browser Applications that use the Classic Agent
  • Configuring Security Settings for Your Local Flash Player


Silktest Flex API
As a first step, we need to copy Silktest flex library before building Flex components.
  1. Navigate to Windows Explorer -> Silktest_Installed_Directory\ng\AutomationSDK\Flex\3.0\Automation
  2. Copy FlexTechDomain.swc
  3. Paste into C:\Program Files\Adobe\Flex Builder 3\sdks\3.1.0\frameworks\libs
  4. In this libs folder, you can see few more files such as automation.swc, automation_agent.swc & automation_dmv.swc
Change in Flex XML configuration
To change flex-config.xml
  1. Navigate to Windows Explorer -> C:\Program Files\Adobe\Flex Builder 3\sdks\3.1.0\frameworks
  2. Open flex-config.xml and set the following:
    <include-libraries>
    <library>/libs/automation.swc</library>
    <library>/libs/automation_agent.swc</library>
    <library>/libs/FlexTechDomain.swc</library>
    <library>/libs/automation_dmv.swc</library>
    </include-libraries>NOTE: Remove the comments for include-libraries tag.

Flex Compiler Settings
  1. Open the project.
  2. Project Menu-> Properties.
  3. Select Flex Compiler.
  4. In additional compiler constants, set the following:
    -include-libraries "${flexlib}/libs/automation.swc" "${flexlib}/libs/automation_agent.swc" "${flexlib}/libs/FlexTechDomain.swc"

Browser Setting

To set security settings for Flash Player:
  1. Navigate to FlashPlayer Setting
  2. In Global Security Settings, select radio button 'Always Allow'.
  3. From the Edit Locations drop-down menu, click Add Location.
  4. Click Browse for folder and navigate to the folder where your local application is installed.
  5. Click Confirm and then close the browser.


To Enable JavaScript:
  1. In Internet Explorer 6.0 and 7.0, Choose Tools/Internet Options.
  2. Click the Security tab.
  3. Click Custom level.
  4. In the Scripting section, under Active Scripting, click Enable and click OK.

Settings in Silktest
  1. It is important to start the Open Agent before starting your flex application.
  2. Enable extensions for flex
  3. Check your include files (From Options menu-> Runtime). Flex.inc and flexDataTypes.inc files should be included in the UseFiles. I have given a sample UseFiles value of a simple project below:
    D:\Flex\MyFlex1\frame.inc,extend\explorer.inc,extend\xBrowser\xbrowser.inc,extend\Flex\Flex.inc,extend\Flex\FlexDataTypes.inc,extend\WIN32\WIN32.inc

Sunday, January 25, 2009

Mapping - Silktest Versions

Borland is using product names instead of versions for Silktest. We are using different versions of Silktest to execute our silktest suites. Sometimes it is confusing for testers, who is trying to execute silktest suites. Below I have given a mapping for product name and version.

Product Name

Version

SilkTest 20068.1
SilkTest 2006 R28.5
SilkTest 20089.0
SilkTest 2008 SP19.1
SilkTest 2008 R29.2

Saturday, January 24, 2009

New Release - SilkTest 2008 R2

Borland has released SilkTest 2008 R2 recently. It has many enhancements for Open Agent.

New Features


  1. Dynamic Object Recognition (Open Agent)

  2. Windows Presentation Foundation (WPF) Support for the SilkTest Open Agent

  3. xBrowser Support

  4. JavaScript Support

  5. Custom Class Attributes in Java SWT and xBrowser Applications

  6. Ability to Suppress Controls for Certain Classes

  7. New Methods Supported for Adobe Flex

  8. Enhancements for Silk4J Eclipse Plugin

For more information, you can have a look at SilkTest 2008 R2 documentation.