Monday, March 24, 2008

Class Mapping in Winrunner

Class Mapping concept is explained in Custom Objects . Winrunner (WR) also provides class mapping. The Class Mapping enables you to map a custom class to a Standard class.

You can map the classes by two ways.


  • By using Winrunner editor. Use GUI Map editor from Tools Menu.

  • By setting dynamically through TSL (Test Script language) code. See following code snippet.


Code:


#-------------------------------------------------------------------------
# Method : WindowsCustomTextbox
# Author : T.Palani Selvam
# Purpose : It directs the execution according to actions in text box & mapping with given class.
# Parameters:
# sCtrlName - contains name of that control.
# sAction - contains type of the action should be happened.
# sData - contains data to be checked or played in controls.
# sCustomClass - contains class name to be mapped.
# Returns : Integer - returns int value (TRUE = 1 or non-Zero, FALSE = 0)
# Caller :
# Calls : - Nil -
#Logical expressions are assigned the value 1 if true, and 0 if false - From TSL Reference.
#-------------------------------------------------------------------------
public function WindowsCustomTextbox(in sCtrlName,in sAction,in sData, in sCustomClass) {
auto sResult;
auto sMappedClass;
auto sLocation;

get_class_map(sCustomClass , sMappedClass); #Get mapped Class name.
#Verify thr control name type.
sLocation = IdentifyType(sCtrlName);
if (sLocation != "") {
sCtrlName = "{class: edit,MSW_class: " & sCustomClass & ",location: " & sLocation & " }";
}

if (sMappedClass != "edit") {
set_class_map(sCustomClass , "edit"); #Mapping.
sResult = WindowsTextbox(sCtrlName,sAction,sData);
unset_class_map(sCustomClass); #released mapping.
}else {
sResult = WindowsTextbox(sCtrlName,sAction,sData);
}
return sResult;

} #end of function WindowsCustomTextbox

Sunday, March 23, 2008

Class Mapping in QuickTestPro

Class Mapping concept is explained in Custom Objects . QuickTest Professional (QTP) also provides class mapping. The Object Mapping enables you to map an object of an unidentified or custom class to a Standard Windows class.

You can do by Object Identification dialog box from tools menu. For more information, you can refer help for Mapping User-Defined Test Object Classes.

Saturday, March 22, 2008

Class Mapping in Silktest

Class Mapping is explained in Custom Objects . Silk test also provides class mapping. Class mapping only works for objects that are created with standard classes but are given non-standard names. You can achieve class mapping by two ways.

1. One is by using silktest editor. Go to Options->Class Map. Then set choose custom and standard classes.

2. Another option is by 4test coding. You can use Agent option OPT_CLASS_MAP. The class mapping table for custom objects, with each entry in the list in the form "custom_class = standard_class".

Friday, March 21, 2008

Silktest - Run script in different browsers

SilkTest has options set feature. It is used to save the required silktest settings. I have used batch file to run the script for different browsers. It is easy to run your scripts, without any settings manually.

Below batch file is run for My_IE6DOM.opt (option set). You can try for suite instead of script-wise.

IE6DOM.bat



rem ******************************************************
rem Used to run the scripts for different option sets
rem *******************************************************

rem * Setting path to SilkTest application *
set APP_SILK="c:\Program Files\Segue\SilkTest\partner.exe"

rem * Setting path to Silk source *
set SRC_SILK=C:\Automation\AUT\Silk

rem * Setting SilkTest options file*
set SRC_OPTIONS=%SRC_SILK%\..\My_IE6DOM.opt


rem *****************************************
rem * Running Security test suite *
rem *****************************************

rem * Running Security Options test script *
%APP_SILK% -q -opt %SRC_OPTIONS% -r %SRC_SILK%\scripts\security.t


Class Mapping in VisualTest

Already Class Mapping is explained in Custom Objects . Visual test also provides class mapping. VisualTest coding is similar to Visual Basic. But both are not same and used for different purposes. Below code is to treat any given custom class as Button class.

Code snippet:



'--------------------------------------
' Method : WindowsCustomButtonClick
' Author : T.Palani Selvam
' Purpose : Clicks the given Button element.
' Parameters: sButton - String, Contains name of control
' sBtnValue - String, Contains value of control
' sCustomClass - String, contains custom class name.
' Returns : Integer
' Caller : WindowsHandleClick(sContext, sForm, sElement ,sElementValue , sElementType)
' Calls : - Nil -
'-------------------------------------------
Function WindowsCustomButtonClick(sButton As String, sBtnValue As String, sCustomClass As String) As Integer

WButtonSetClass(sCustomClass)
WindowsCustomButtonClick = WindowsButtonClick(sButton, sBtnValue)
wResetClasses()
End Function

'---------------------------------------
' Method : WindowsButtonClick
' Author : T.Palani Selvam
' Purpose : Clicks the given Button element.
' Parameters: sButton - String, Contains name of control
' sBtnValue - String, Contains value of control
' Returns : Integer.
' Caller : WindowsHandleClick(sContext, sForm, sElement ,sElementValue , sElementType)
' Calls : - Nil -
---------------------------------------
Function WindowsButtonClick(sButton As String, sBtnValue As String) As Integer

WindowsButtonClick = False

If (WButtonExists(sButton)) Then
WButtonClick(sButton)
LogWrite("Successfully clicked button " + sButton, 1)
WindowsButtonClick = True
Else
LogWrite("Failure to Click Button " + sButton,1)
End If

End Function

Thursday, March 20, 2008

QTP - Getting INPUT objects

I wrote a qtp (Quicktest Professional) code for listing INPUT element's objects. Descriptive Programming is a feature in QTP. It is used to handle dynamic objects. I will write later about Descriptive Programming. Here below function returns particular type of objects in a web page.

Function:



'Calling function to list editboxes
Set ObjEditAll = ListAllWebObjects (Browser("My APP").Page("First Form"),"text")

Function ListAllWebObjects (ObjContainer,sControlType)
' Getting all type of INPUT objects
Dim MyDescription,objEditBoxes,NoOfChildObjs,Counter,strReport
Dim sTemp, objEdit

'Initialization
'ListAllWebObjects = Nothing
Set MyDescription = Description.Create()
MyDescription("html tag").Value = "INPUT"
MyDescription("type").Value = sControlType

Set objEditBoxes = ObjContainer.ChildObjects(MyDescription)
NoOfChildObjs = objEditBoxes.Count

strReport = ObjContainer.ToString() & " contains the following child object(s):"
For Counter=0 to NoOfChildObjs-1
strReport = strReport & vbNewLine & objEditBoxes.Item(i).ToString()
set objEdit = objEditBoxes(Counter)

sTemp = objEdit.GetROProperty ("name")
Reporter.ReportEvent micDone, objEdit.ToString() & " - name property", sTemp

sTemp = objEdit.GetROProperty ("class")
'sTemp = objEdit.object.ClassName
Reporter.ReportEvent micDone, objEdit.ToString() & " - class property", sTemp

sTemp = objEdit.GetROProperty ("index")
Reporter.ReportEvent micDone, objEdit.ToString() & " - index property", sTemp

sTemp = objEdit.GetROProperty ("location")
Reporter.ReportEvent micDone, objEdit.ToString() & " - location property", sTemp

sTemp = objEdit.GetROProperty ("html id")
Reporter.ReportEvent micDone, objEdit.ToString() & " - html id property", sTemp

sTemp = objEdit.GetROProperty ("innerhtml")
Reporter.ReportEvent micDone, objEdit.ToString() & " - innerhtml property", sTemp

sTemp = objEdit.GetROProperty ("outerhtml")
Reporter.ReportEvent micDone, objEdit.ToString() & " - outerhtml property", sTemp

sTemp = objEdit.GetROProperty ("innertext")
Reporter.ReportEvent micDone, objEdit.ToString() & " - innertext property", sTemp

sTemp = objEdit.GetROProperty ("outertext")
Reporter.ReportEvent micDone, objEdit.ToString() & " - outertext property", sTemp

Next

set ListAllWebObjects = objEditBoxes

Reporter.ReportEvent micDone, ObjContainer.ToString() & " child objects", strReport
End Function

Wednesday, March 19, 2008

FireFox Vs Internet Explorer

I have used different browsers such as Netscape, Opera, Internet Explorer, Firefox and few more. Earlier I used netscape and Internet Explorer regularly. But now I am using often Firefox and Internet explorer. It helps me to do browser compatibility testing.

In 2005, I started to use FireFox browser and it has many advantages while comparing with Internet explorer. Now Most of the sites are supporting Firefox also. I like the features such as tabbed browsing, popup blocker and download manager. These features are not upto the mark in IE. Opera browser already has similar to tabbed browsing. Opera is not popular as Firefox. Current IE7 is not fast as Firefox and also having security issues. Firefox has greater ease of use and more personalization options. It has improved performance and security features.

I am comfortable with firefox than IE. I heard that IE version 8 and FF version 3 are going to be released soon. Searched net for comparison. Got two interesting pages. Some old Comparison around 2004. Recent comparison is available here

Tuesday, March 18, 2008

MS XML Parser by Visual Basic

I love to use XML Parser. It is very easy to do by Visual basic. You can get the equivalent visual test code here - Visual Test - MS XML Parser. I'm thinking to use it in Quick Test Professional (QTP). Below code snippets are simple and easy to use.

Case1: To load any XML content



'-----------------------------------------
' Method : XMLParserLoadXML
' Author : T.Palani Selvam
' Purpose : Creates XML Parsing object according to the given XML String.
' Parameters: sXML - String, contains data in XML Format.
' Returns : Returns a Object, which contains XML Parsing object.
' Caller : - Nil
' Calls : - Nil -
'------------------------------------------
Function XMLParserLoadXML(sXML As String) As Variant
Dim objXML As Variant

XMLParserLoadXML = Null

Set objXML = CreateObject("Microsoft.XMLDOM") 'Declare a Object
objXML.async = False
objXML.loadXML (sXML) 'Load xmlformat String

'OleSetProperty(objXML,"preserveWhiteSpace") = False

If (objXML.parseError <> 0) Then
LogWrite ("Parsing Error in the File :" + sXMLFile)
Exit Function
End If

'Top Node of given file
Set XMLParserLoadXML = objXML.documentElement
End Function



Case2: It parsed the given tag in given content and returns the node.


'-----------------------------------------
' Method : XMLParser
' Author : T.Palani Selvam
' Purpose : Creates XML Parsing object according to the given XML Format File and Element.
' Parameters: sXMLFile - String, contains a file name, which is in XML Format.
' sTag - String, contains element name from which Tag or element based object to be returned.
' Returns : Returns a Object, which contains XML Parsing object.
' Caller : - Nil
' Calls : - Nil -
'-----------------------------------------
Function XMLParser(sXMLFile As String, sTag As String) As Variant
Dim objXML As Variant, objNode As Variant, objTemp As Variant, objRoot As Variant
'Dim varTest As Variant
Dim iIndex As Integer, iTemp As Integer
'Dim objRoot As node

XMLParser = Null
sTag = Trim(sTag)
Set objXML = CreateObject("Microsoft.XMLDOM") 'Declare a Object
objXML.async = False
objXML.Load (sXMLFile) 'Load xmlformat file

If (objXML.parseError <> 0) Then
LogWrite ("Parsing Error in the File :" + sXMLFile)
MsgBox ("Parsing Error in the File :" + sXMLFile)
Exit Function
End If

'Top Node of given file
Set objRoot = objXML.documentElement
'Print "XML File is : " & sXMLFile
'Print objRoot.nodeName & " Name of the node.."

If ((sTag = "") Or (sTag = objRoot.nodeName)) Then
'XMLParser = CVar(objRoot)
Set XMLParser = objRoot
'Set varTest = objRoot
'XMLParser = objRoot
Exit Function
End If

If objRoot.hasChildNodes <> 0 Then
objTemp = objRoot.childNodes
iTemp = objTemp.length

For iIndex = 0 To iTemp - 1
objNode = objTemp.Item(iIndex)
If (UCase(Trim(objNode.nodeName)) = UCase(sTag)) Then
XMLParser = objNode
Exit Function
Else
Set objNode = Nothing
End If
Next iIndex
End If

objTemp = objXML.getElementsByTagName(sTag) 'Search whole file with sTag
iTemp = objTemp.length
If (iTemp > 0) Then
objNode = objTemp.Item(0)
XMLParser = objNode
End If

End Function

Monday, March 17, 2008

Globalization

Globalization :
It is a precess of developing,manufacturing,marketing software products that are intended for worldwide distribution.It is achieved through
Internationalization and Localization.

.
Internationalization:

  • It is the process of designing an application to adapt to different languages and regions.
  • It is often appreviated as I18N or i18n or i18N.Where the number 18 refer to the number of letters omitted.
  • •I+n1t2e3r4n5a6t7i8o9n10a11l12i13z14a15t16i17o18+n.
Importance:
  • Build once we can sell anywhere.
  • Translation is easy.
  • Addition of localization data the same executable can be run worldwide.
Localization:

  • It is the process of adopting software for a specific language or region.
  • It is a process of translating software user interface from one language to another.
  • It is appreviated as L10n.
  • During localization,some references to history or culture are replaced with an equivalentnative reference which ideally doesnot change the meaning of the statement.
•






•


VisualTest Support

VisualTest support has been stopped for around 8 years. But Still few companies are using Visual Test. The two active forums are available for Visual test. One is mt_info Yahoogroups and another one is in SQA Forums. Recently that Yahoo groups also closed.

Visual test cost is very less and many users were there. The last version is 6.5 But still few people are using VT. Thats why I thought to put few visual test code snippets. I am planning to put few posts for visual test.

See the one post from a VT user.
Quote:

After a very extensive search i have found this forum,and i suppose it is still active for Visual Test. Right now i knew that Visual Test is obsolete in the market.But i am pushed to use the tool.As i am very new to testing and currently i do not have the tool as well,I'll be getting it by November 1st week.So could any one help me in starting the preparation.If any of you can guide me where to get the Book Visual Test Bible by Thomas R.Arnold it would be really help full.If any one have the copy same and ready for selling i am ready for purchasing it.So please please help needed.


I hope that this will be applicable to Winrunner in the future.....!!!