Please post your Web Driver questions in official Web Driver forum

Sunday, November 14, 2010

The Nanny

Have been watching Nanny and yet again it is as engaging as it was when I first watched it about 9 years ago. I can never get enough of Fran's honest concerns with kids especially Maggie. How Fran salvages her from situation which Fran herself experiences in past. I see CC as one of most downplayed character of show. Though she is portrayed chesty woman looking down upon at Niles and Fran, but they are equally responsible for making her hate them; be it Niles constantly lampooning her or Fran getting in the way of CC and Maxwell. Fran's granny Yetta, is another favorite of mine. She is the oldest person in the show but carries more warmth than any one else. And then there is Gracie, who is always protected by Fran (and so as the others kids in family). I dare say, The Nanny has potential to be as famous as Friends; just needs a better publicity.

p.s. got to know about nanny reunion should download soon.

Friday, August 13, 2010

XPath and single quotes


I had tough time dealing with XPath and single quote. Though W3C recommends using ' to escape it but I never got it working, let me know if any of you get through.
Came across this blog and found that “concat” could be used in this situation.
So original XPath expression is –

//meta[@name=’DESCRIPTION’][@content=’Tester’s Test’]

This is some thing which certainly fails as single quote in “Tester’s” marks it at end of string and then XPath blows up, next trial was –

//meta[@name=’DESCRIPTION’][@content=’Tester''s Test’]

This does not work despite w3c recommendation!

And then I used concat function and split the string as –

concat(‘Tester’,”’”,’s Test’)

NOTICE that single quote is kept in double quote while other characters are kept in single quotes.
So XPath looks as –

//meta[@name=’DESCRIPTION’][@content=concat(‘Tester’,”’”,’s Test’)]

And this works charm.



Wednesday, August 4, 2010

Bye Bye Ciber

Today was my last day at Ciber and I can not stop but blog about my experiences at Ciber/Iteamic. Looks like it was yesterday (13th Feb 2006) when I stepped in to Iteamic with three new joiners - Janakiram, Shamial and (well I don't remember third name). Happened to begin work with Emergent which turned out to be biggest testing team in Iteamic and found my first team lead Bindu who, well how much ever I admire would be less. A team lead who knows how to nurture new joiners. Made friends like Poornima, Shilpa (Chatter Box), Aarati (who was always ready to help with no strings attached) and Rekha (who made me understand req which other wise were Greek to me). By now I realized that I have strange habit of naming people on how I perceive them.

After three months I found my self associated with Anian and got to meet Mallikarjuna (My second team lead). Mallikarjuna has been most hard working team lead I have worked with, hard working to the extent that it intimidates me! I would find him leaving for home 4am morning and 8am he would be back to office. There were never any signs of fatigue on his face. Yet to figure out what he eats! After some time Mallikarjuna moved out of Anian and we were a test team with out any lead. This was the time when Geethanjli, Divya (both of them would always be there to stay late if I don't go home) and I came together and became best team mates.

Things changed and Anian was taken over by Reuters and became Reuters Insight and I happened to work with Prameela (Pamela) (as my team lead) Deepak and Skanda. Prameela has been coolest team lead I have come across.  Not to forget Raghu, Bala and Gurmeet from development team.

And then was the GSB. My association with GSB was supposed to be very limited but became full fledged soon. Enjoyed testing algorithm from algorithm uncle (Ashok Datla) b2b algorithm and yes how can I forget conflicts which were never implemented in first place. This was the time when one entire floor in Iteamic was dedicated to GSB. Here I met Hitler (Vyshali), TP (Mythri), Silent feature (Manju) Gabber Singh (Dore), Alien (Kini) Stock Market (Vinay), Maggie (Vijaya) and dearest ADW (Sneha, and only a few know what it means!). Will always cherish those memories.

Soon I found myself working in AMR, and I must admit this is the only project in which I have been impressed with dev than qa. Happened to meet most fearless person - Aravindan and then there were whole gamut of team members - PJ masters - Ruchi and ravi, Kool Prabin, Uncle Vickram, Savita (she is never going to forgive us for all those pranks!) "Dodda Maghu" (in Kannada - big boy) Jo and last but the not least Lakshmi bai (Madhavi) and Full of light (Prakash). Madhavi is the only person who I am impressed with coz of her soft skills than any thing else and Prakash, well some one should ask him how to laugh even under those toughest of times.

This post would be incomplete if I don't mention Ashwith (who I always look forward to when can't take decision my self), Naveen - truly technical manager (and only one who I have always been cautious of talking as he is NO nonsense), Ranjith (Kool Temprament), Rajesh T - who we can always look forward to when it comes to a caring amanger, Manav - No fabrication what so ever and last but not least Madhu for being supportive especially under unfavorable conditions.

I did not send "last day mail" today, but could not stop my self from showing my gratitude to all of you. I apologize to those who I might have missed here inadvertently. Wish u all a very bright and prosperous future.

~ T

Saturday, July 24, 2010

Test Automation Recovery Scenarios: how much recovery

This article is not specific to QTP but elaborates a more general problem with functional test automation. I caught the fancy of recovery scenarios when came across such feature in QTP. QTP's motive is to recover from problems of unexpected pop up windows (though concept itself is contradictory and requires you to know object properties of unknown window in advance!) .Though soon realized that it is more of marketing gimmick than of being of much importance to automation it self. Some thing which always puzzled me was how much of such scenarios to use.
While under going In house QTP training we were told to even check presence of objects before exercising them. This is to make sure that QTP does not throw any pop up error during test case execution. (at least this is what we were told during training). Later I realized that using QTP properties could be to order QTP do what is intended (though in a limited manner).
This idea of checking every object before test freaked me out. I started wondering if I have to check each object first before I perform any operation. Being a Selenium enthusiast I started doing some thing like -

public safeType (String obj, String testData) {
    if(selenium.IsElementPresent(obj))
       selenium.type(obj, test Data);
    else
       Reporter.log("Element: " +obj+ ", NOT found")
}

But then came across Unchecked Exception in java, and realized that non availability of object on page should be treated as run time exception and test automation should not make efforts to come out of these exceptions. But then I thought that "safe" approach could be used for non mandatory fields/tests on a page which would post error on test report but will let tests continue the execution. (Remember unavailability of an element makes entire tests stop in selenium). Well I am not sure how practical this approach is but I am curious to know how you would have approached it.

Friday, July 23, 2010

"Loading......." the contents

Came across a testing blog yesterday and started browsing all past blogs of it using calendar.
Look like my network is slow and I got to see "Loading...." message after clicking on calendar link. I collapsed the link and clicked on calendar again and got to see "Loading....... Loading.......". Each collapse and expansion of calendar increases the message "Loading......."  by count one.

After a few clicks













After a few more clicks

Thursday, July 22, 2010

So why did you write "this" certificate?

This is going to be an eternal post which I would modify as and when I find new reasons for writing certificates.
Though I personally don't admire certificates but happened to write one (QC 9.2) on my own. This happened last year when I was told about a project which needed experience on QC and client had asked have QC certified resource working on it. Well exam was really easy and I happen to clear it. Irony is project never materialized and I never got to work on QC. Happened to mention about certification on my resume and under the influence of this group removed it.

Of late I have been interviewing testing candidates and a few of them have certification batch with them. And we all know most famous certification batch in market is ISTQB (I must appreciate their marketing for sure and hope they contribute a share of their earnings to some open source testing projects. Though I am not very hopeful of this.).

I am listing here the responses I receive from the candidates -
  1. One candidate having more than 2 years of  experience said - "I wanted to learn testing concepts". My response - "So you were not aware of testing concepts for past two years". I can't recall the response of Candidate.
  2. One candidate said - "I have written foundation level exam for ISTQB". My question - "So what did you learn?". Candidate - "Nothing much but I am planning to write advance level and would definitely learn from it." !@#!@#!@#!$@$$!@
  3. Another candidate said - "Certification fetches you better salary", I can only imagine how much money I have lost so far.
This is an incomplete blog and would update this when I receive new answers.

So how do you Strategize it?

Happened to read Pradeep's blog today and got enthusiastic to write a blog. Found there is a intricate situation for me to blog about, and almost all of us would have faced it some time.

Of late I was called by one of the engagement manager to help one tester (the lone warrior and new joinee to organization) in project to help him on test strategy. Had a meeting in the after noon with project team and got to know that team has least information on project (assignment had begun a week ago). Project is a migration task from one java technology to other and testing activities would involve function testing (with no definition of scope) followed by performance testing. Team is bewildered as they have least information about project whereabouts and the tester has no idea on how he would carry out functional and performance testing. On top of this the very first deliverable for the project is test strategy document.

So our warrior has been asked to come up with test strategy. And he indeed developed a test strategy document on the basis of general info and experience ha has gained over years. The document does not consist any specific attribute to project (for obvious reasons). Now engagement head is not happy with length of document as this is a deliverable which is going to bring more money and probably more business. He believes that it has to have more info. I don't question him for his opinion as his objective is to get more business to company may be right from his perspective.

So what I did? Well first of all I consoled the poor tester who was feeling left out. A new joinee having feelings of not being able to live up to responsibilities of his first job. Besides this only option I could think of was questions, zillions of questions to be asked to client as we had least info about the project. I had a dedicated section added to doc about questionnaire which we had to know before having the testing assignment begun. He added a couple more pointers about exit and entry criteria for each phase of functional and performance testing. The document is sent to supervisor and review comments are awaited.

So what different would you have done in this situation?

Wednesday, July 7, 2010

Selenium - Stack Exchange website

Please support Selenium's own website on Stack Exchange here -

http://area51.stackexchange.com/proposals/4693/selenium

Saturday, July 3, 2010

Hacking Website from Google

If u have not yet seen this!
Google labs is offering a sample application with security vulnerabilities. I have just started browsing through and its very interesting. More interesting for some one who is new to Security Testing.
Website is available here and open to all for hacking with tips and tricks provided by none other than Google itself.

Sunday, June 20, 2010

Defect in Word 2007

This is my first post for tag "Universal Defects", though I had other similar posts but I never tagged them (must do that now).

Well I have been using word 2007 on my Dell Studio 15 lap top.Under "Mailings" tab there is an option called ''Select Recipients". Click on this and select option "Select from Outlook Contact ", and I see the following error -












and this is the error -












I don't have look configured on my laptop.
Microsoft, are u listening!!!!!!!!!!!

That's not test automation framework!!!

I have been flabbergasted by the amount of misinformation test automation engineers have.
Many of my colleagues use QTP or Test Complete and believe that they have developed a test automation framework. Using a tool or creating directory structure for test automation is not equivalent to creation of test automation framework, in fact not at all. Moreover Indian software industry is so fascinated with word "framework" that this question keeps popping - "Did u design any framework", I wonder if every software test project needs a customized framework, and if so then I am not that so expert that keep designing framework for each and every project!!!

Review of Selenium Book

Not long time ago when I participated in Selenium Documentation and contributed for Selenium Remote Control. I have got one more offer to review an upcoming Selenium book by David Burn.
I have never interacted David in person but looks to me he is as passionate about Selenium as I am. I had never imagined that I would get opportunities to review a book in my life, any ways. So far I have reviewed 3 chapters. I must accept that during review I came across Selenium facts which I my self was not aware and I must thank David for this. I hope the book gets finished soon and made available to Open Source community.

Thursday, June 10, 2010

Generating Dates in java

This is a small posts which helps in generating custom dates in java.
It would be helpful in data generation in Selenium.


package com.core;



import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.GregorianCalendar;



public class DateClass {



private static String currentDate;

private static String futureDate;



public static void main(String[] args) {       



SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy hh:mm");

Calendar cal = new GregorianCalendar();

currentDate = sdf.format(cal.getTime());



// Current date

System.out.println(cal.getTime());



// Formatted current date

System.out.println("Formatted Date is: " +currentDate);



cal.add(Calendar.DATE, 1);

futureDate = sdf.format(cal.getTime());



// Formatted future Date

System.out.println("Future Date is: " +futureDate);       

}

}

Sunday, June 6, 2010

Why I quit Figurine fitness

I had it on my mind from long though never penned it. This post is dedicated to all those work out freaks that are befooled by their trainer in to buying costly food supplement specifically at higher price then what is available in market. In this post I am not being critical of gym but I question all those trainers who forget their profession and mint money by fooling their clients.

Same happened with me and I have no qualms accepting it, I am rather glad that I realized it and moved out from gym.

It started in month of Jan 2009 when I joined Figurine fitness located in Jaynagar (as I said earlier I have nothing against gym in fact they have some of the most proficient and hard working trainers I have seen, but it’s because of my trainer I developed antipathy against gym!).

Inception of gymming was great. I was allocated a trainer who would teach me when to do what. After a couple of weeks my trainer asked me to start taking supplements as I needed extra protein to build up muscles (given that my body type is lean). My trainer asked another trainer to arrange for supplement for me.

This continued for a couple of months. I feel something went wrong between my trainer and other trainer who was arranging supplements for me. So my trainer asked me to not take supplements from other trainer and tell him that I would it from market (I was certainly lying for sake of my trainer). After this my trainer started providing me supplements. I realized that size of supplements packs had reduced but price had increased, when I enquired in market I found that same product was available in as less as 2000/-. At this point I decided to move out of that gym and joined another gym.

I could have done following –

1. Speak to my trainer

2. Speak to gym management

I thought of speaking to management but then they are not the one who asked me take supplements from trainer. And this would have only created resentment b/w trainer and me.

I quietly moved out of gym and join Legend Fitness, will jot down in another post as to why I have been able to continue with my current gym past more than 6 months, and hopefully in the future as well.

Saturday, May 22, 2010

How developers view testers


This is my first cartoon inspired by Cartoon Tester, hope you enjoy it.











Thursday, April 22, 2010

Mobile Theft in BMTC buses

 
Well, this is some thing I had heard of and was not expecting to experience.
I bought a brand new Nokia 5800 about 6 months ago and have fallen Victim of petty thieves in BMTC buses.
I got in to a non Volvo bus near Jayadeva flyover to head to Dairy Circle, IBC Park.
This is a mere distance of 2 km or so.
Bus was not very crowded and I was standing near front door as my destination was not very far.
I noticed a couple of guys who were also standing near me and I assumed that probably they also want to get down near by.
As soon as bus started one guy came behind me while two more guys quickly moved near closed bus door.
One guy in white shirt was standing next to me.
The guy who was behind me came forward and now there were three guys near closed door.
Bus stopped on next station and none of them got down nor were they willing to move and give space to incoming passengers.
Then was the next stop where I had to get down (and all this while I did not have an iota of impression about their objective). There were still three guys near exit door, so I asked them to move and give me space.
Though they did not bother to move, I tried to get down from remaining space and noticed some scuffle behind me (though I still did not bother to check my mobile and wallet).
This is when I got down from bus and saw a couple of guys getting in to another bus from the bus I was in.
At this point I realized not having my mobile with me, and was completely in shock to do any thing.
My intention of this blog is to make Bangalorean aware of such incidents which might be very common in BMTC buses, so if you notice –
 
  • Unnecessary scuffle in bus,
  • Guys standing at exit door, but not getting down,
  • Some one standing too close to you despite having sufficient space in bus,
  • Guys moving back and forth in bus
 
Then these are clear signs of you being next victim of mobile theft in BMTC bus.
 
Having realized that I had lost my mobile the very fist thing I did was to block the SIM as it was post paid connection.
Then I approached near by police station to lodge an FIR though was directed to go to another police station of. (Can’t there be coordination among police stations so we could lodge FIR any where)
When I approached another police station I was given all sorts of cogent comments to as to why FIR can not be launched in this case. (For some time I felt as if my mobile is not stolen at all!!!)
Finally they agreed to take complaint (though not FIR) and got me one acknowledgement.
Though I don’t have any hope of getting my mobile back, I wish that this post of mine would caution other about mobile theft in BMTC buses.
 
 
 
 
 
 

Tuesday, April 13, 2010

Working With FCK editors

I had troubles working with FCK editors using QTP.
As these editors are recorded as “WebElement” it is not possible to perform “Set” operation on them
I came across two posts which talk about dealing with this issue,
 
One is of Tarun’s where in talks about using “object” as well as “DeviceReplay” methods which could be used to simulate control on FCK editor
He suggests not using “object” for browsers other than IE as it is supported only in IE
 
 
Browser("testB").Page("testP").Frame("Frame").WebElement("WebElement").object.innerText = "Text
Browser("testB").Page("testP").Frame("Frame").WebElement("WebElement").object. innerHTML
= "<h1>Text</h1>
 
 
While other method uses object “DeviceReply” object to exercise object on which control is brought.
 
'Click on Application Object
Browser("testB").Page("testP").Frame("Frame").WebElement("WebElement").Click
 
'Create device replay object
Set oDR = CreateObject("Mercury.DeviceReplay")
 
'Send some text
oDR.SendString "Text Text"
 
'Deallocate Object
oDR = Nothing
 
There is one more portal which provides more detail information it – Advanced QTP, did not have time to go through it
 
THanks,
Tarun K
 
 

Thursday, April 8, 2010

Strange QTP Errors and Possible Solutions

Herein I have listed couple of error which I encountered while working with QTP. Some of these are very cryptic and you just can not guess about their Raison d'ĂȘtre.I have listed these errors
hoping it would help a new bird.









































Error while opening Test















On Debug











Error with Function

Error while using a function whose definition was not available in Action











Unable to work with IE

Unable to recognize IE window; had to restart the browser




















General Run Error

There have been multiple instances of General Run Error with QTP; they just don’t let u know as to what went wrong. On such instance is when I was mistakenly trying to check a check box which was disabled. Instead of General Run Error, there could have been a more comprehensible error like – “object is disabled…”


Monday, April 5, 2010

QTP AOM File

Here in I have got sample AOM file which invokes QTP test. This file also pushes test results to a designated folder. Herein there is no hard coding of path ant where in AOM file -

##################################################
Dim qtpApp 'As QuickTest qtpApplication
Set qtpApp = CreateObject("QuickTest.Application")
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable

qtpApp.Launch
qtpApp.Visible = True

qtpApp.Test.Settings.Launchers("Web").Active = False
qtpApp.Test.Settings.Launchers("Web").CloseOnExit = True
qtpApp.Test.Settings.Run.ObjectSyncTimeOut = 240000
qtpApp.Test.Settings.Run.DisableSmartIdentification = True
qtpApp.Test.Settings.Run.OnError = "Dialog"
qtpApp.Test.Settings.Web.BrowserNavigationTimeout = 60000

qtpApp.Options.Run.RunMode = "Fast"
qtpApp.Options.Run.ViewResults = True
qtpApp.Options.Run.MovieCaptureForTestResults = "Never"
qtpApp.Options.Web.AddToPageLoadTime = 10
qtpApp.Options.Web.BrowserCleanup = True
qtpApp.Options.Run.ImageCaptureForTestResults = "OnError"

'Get path to trunk
sn = Wscript.ScriptName 'Script Name
fn = Wscript.ScriptFullName 'Fully Qualified Script Name
fp = Replace(fn, "\" & sn, "") ' Drive / Folder path

Set fso = CreateObject("Scripting.FileSystemObject")

'Open the test in read-only mode
qtpApp.Open fso.GetFolder(fp).ParentFolder& "\test_scripts\GSBRegMF1Event", True

'Create the Run Results Options object
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")

'Set the results location
timeStamp = FormatDateTime(Now, 1)&" "& Hour(Time) &"-"& Minute(Time) &"-"& Second(Time)
qtResultsOpt.ResultsLocation = fso.GetFolder(fp).ParentFolder& "\results\GSBRegMF1Event\" &timeStamp

qtpApp.Test.Run qtResultsOpt 'Run the test


Set qtpApp = Nothing
Set qtResultsOpt = Nothing
Set fso = Nothing
##################################################

Thursday, April 1, 2010

Reading Outlook Contents From VB Script

There are instances when an application involves mail delivery for certain app features. one way to automated this is to hook with Outlook and read content of mail (though I am not very comfortable with this approach anyways!)

####################################
'Get the Count of Items in Inbox
Set app = CreateObject("Outlook.Application")
Set nameSpace = app.GetNamespace("MAPI")
Set MyFolders = nameSpace.GetDefaultFolder(6)
MsgBox MyFolders.Items.Count


'Read unread items in Inbox
Set cols = MyFolders.Items

For each mail In cols
If mail.unread Then
MsgBox mail.subject
MsgBox mail.sendername
MsgBox mail.body
mail.unread=false
End If
Next
####################################

VB Script and ADO DB

VB Script can be used to establish db connection. This is very useful in QTP for writing db test cases. DB connection can be established for both SQL Server Authentication as well as Windows Authentication -

#########################################
Function Func_dbConnect

On Error Resume Next

'Creating the Connection Object
set cn = CreateObject("ADODB.Connection")

'Setting the Data Source
strCS = "Driver={SQL Server}; Server=1.1.1.1; Database=GSBREG_021010; UID=us; PWD=us;"

'Open Connection
cn.Open strCS

If (Err.Number<>0) Then
MsgBox("Login Failed")
End If

Set Func_dbConnect = cn

End Function


Sub ExecuteSQLQuery

Set cn = Func_dbConnect()

'Creating RecordSet Object
Set rs = CreateObject("ADODB.recordset")
rs.CursorType = 2

'SQL query
FetchAcademicLevels = "Select even_id from allocation_event"_
&" where allocation_name = 'myname'"

Set rs = cn.Execute(FetchAcademicLevels)

If(rs.EOF) Then
MsgBox "No Records"
Else

For Each x in rs.Fields
MsgBox x.name
MsgBox x.value
Next
rs.MoveNext

End If

rs.Close
cn.Close

End Sub


ExecuteSQLQuery()
#########################################

For Windows Authentication Connection String should be -

#########################################
strCS = "Driver={SQL Server}; Server=171.64.216.197; Database=copernicus_gsbreg_b2b_new; Trusted_Connection=Yes"
#########################################

Google Chrome Crashes

Got this error message once while working on Chrome. Only Google can have such uncanny knack for error message

Tuesday, March 30, 2010

Testing XPath in Firebug

Given the lack of testing hooks in web applications, many a times Selenium Users use XPath to work on UI Objects. So far I used to use Selenium IDE to test XPath in Firefox. I read a blog post here and got to know that Firebug itself can be used to test XPath. This is accomplished using $x function in Firefox.









Consider that highlighted text box does not have a constant identifier hence following XPath is to be used > $x("//input[@name='search']")
Write this XPath on Console of Firebug and hit enter -



















Keep mouse pointer on 'input' in console and it would highlight the text box in page.
Using Firebug Lite Firebug can be used for other browsers as well and in turn to test XPath on other browsers.......

Wednesday, March 24, 2010

Working with URL Redirection with VB Scripts

Had chance to work on checking http status VB script. Looks like not all objects work when used URL redirect, so I used "WinHttp.WinHttpRequest.5.1".

Set winhttpreq = CreateObject("WinHttp.WinHttpRequest.5.1")

'Initialize HTTP Request
winhttpreq.Open "Get", "http://iteamic.com/"

'Send HTTP Request
winhttpreq.Send()


Print winhttpreq.StatusText
Print winhttpreq.ResponseText

for now iteamic website redirects to ciber and this code works perfect for it.

Tuesday, March 23, 2010

VB Script and Square Brackets '[]'

I had tough time working with vb script and square brackets '[]'. Looks like square bracket has special meaning when it comes to regular expression in vb script.
I was trying to write DP for check box collection on page as -

******************************************************************************
Browser("name:=.*").Page("title:=.*").WebCheckBox("name:=publishedSectionId[0]").Set "ON"
******************************************************************************

Execution of this line resulted in following error -

******************************************************************************
"Cannot identify the object "[ WebCheckBox ]" (of class WebCheckBox). Verify that this object's properties match an object currently displayed in your application."
******************************************************************************

I wonder if this error makes any sense, any ways problem is with square brackets in name property which is -

****************************
name:=publishedSectionId[0]
****************************

To correct this I provided backslash before square bracket -

****************************
name:=publishedSectionId\[0\]
****************************

and got through. :-)

Monday, March 22, 2010

Data Driven Testing with QTP Using Excel ADO

We all are aware of externalizing test data from test scripts in test automation.
We often stumble upon using excel as test data file, and I have seen crude ways of handling excel.
i.e. - Creating Excel Application object
Opening work book and fetching data
Disadvantages of this approach are detailed on Microsoft website here - http://support.microsoft.com/kb/278973/EN-US/
In a gist following above mentioned approach would be process heavy and would make script execution (especially in case of long running test suites) slow
Another crude way is to use sheet-name (which is still acceptable), Row and Column number (i.e. - (2, 5)), Row and Column range (B5, B10). Using row and column identifier is fragile as insertion of new data set in excel would break existing test scripts.
A better approach to overcome these is to use ExcelADO along with name of Range in Excel.
ExcelADO overcomes process over head and using Range to overcome fragility over Row and Column Range.
In excel an individual cell or collection of cell could be referenced with name. To do this - Select required cell range and use 'Insert' > 'Name' > 'Define' Menu
Following are couple of functions to do same using named range cell in excel file -


'‘**************************************************
'Function Name : Func_GetExcelData
'Description : This function is used to return value from named cell range in excel file
' This method should be used when getting data from individual cell and not from collection fo cell
'Input parameters : strFileName - Name of test data file
' strQuery – SQL Query to execute

'Date of Creation : 19th Feb 2010
'‘**************************************************

Function Func_GetExcelData(strFileName, strQuery)

Dim cn
Dim rs

Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strFileName & ";" _
& "Extended Properties=""Excel 8.0;HDR=Yes;"""


Set rs = CreateObject("ADODB.Recordset")
rs.Open strQuery, cn

'Remove Carriage Return and return the value
dataString = Split (rs.GetString, Chr(13))
Func_GetExcelData = dataString(0)

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing

End Function



'‘**************************************************
'Function Name : Func_GetExcelRangeData
'Description : This function is used to return multiple values from named cell range in excel file
'Input parameters : strFileName - Name of test data file
' strQuery – SQL Query to execute

'Date of Creation : 26th Feb 2010
'‘**************************************************
Function Func_GetExcelRangeData(strFileName, strQuery)

Dim cn
Dim rs

Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strFileName & ";" _
& "Extended Properties=""Excel 8.0;HDR=Yes;"""


Set rs = CreateObject("ADODB.Recordset")
rs.Open strQuery, cn

'Remove Carriage Return and return the value
dataString = rs.GetString
Func_GetExcelRangeData = dataString

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing

End Function




'‘**************************************************
'Function Name : Func_SetExcelData
'Description : This function is used to set data in one cell of excel file
'Input parameters : strFileName - Name of test data file
'strQuery – SQL Query to execute
'strVal - Value to be set
' intIndex - Index where value is to be updated

'Date of Creation : 19th Feb 2010
'‘**************************************************
Function Func_SetExcelData(strFileName, strQuery, strVal)

Dim cn
Dim rs

Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strFileName & ";" _
& "Extended Properties=""Excel 8.0;HDR=Yes;"""


Set rs = CreateObject("ADODB.Recordset")
rs.ActiveConnection = cn

rs.LockType = 2
rs.Source = strQuery
rs.Open

rs.MoveFirst
rs.Fields(0).Value = strVal
rs.Update

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing

End Function

Monday, March 8, 2010

Execute QTP Tests from AOM file

Herein I have got Sample QTP - AOM file.
Such sample files are easily available on net but they hard code test path as well as result path.
In this sample file I am going to read test path and results path dynamically from with in driver script, which would make script more portable
Dim qtpApp 'As QuickTest qtpApplication
Set qtpApp = CreateObject("QuickTest.Application")
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable
qtpApp.Launch
qtpApp.Visible = True
qtpApp.Test.Settings.Launchers("Web").Active = False
qtpApp.Test.Settings.Launchers("Web").CloseOnExit = True
qtpApp.Test.Settings.Run.ObjectSyncTimeOut = 120000
qtpApp.Test.Settings.Run.DisableSmartIdentification = True
qtpApp.Test.Settings.Run.OnError = "Dialog"
qtpApp.Test.Settings.Web.BrowserNavigationTimeout = 60000
qtpApp.Options.Run.RunMode = "Fast"
qtpApp.Options.Run.ViewResults = True
qtpApp.Options.Run.MovieCaptureForTestResults = "Never"
qtpApp.Options.Web.AddToPageLoadTime = 10
qtpApp.Options.Web.BrowserCleanup = True
qtpApp.Options.Run.ImageCaptureForTestResults = "OnError"
'Get path to trunk
sn = Wscript.ScriptName 'Script Name
fn = Wscript.ScriptFullName 'Fully Qualified Script Name
fp = Replace(fn, "\" & sn, "") ' Drive / Folder path
Set fso = CreateObject("Scripting.FileSystemObject")
'Open the test in read-only mode
qtpApp.Open fso.GetFolder(fp).ParentFolder& "\test_scripts\<TestName>", True
'Create the Run Results Options object
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")
'Set the results location
timeStamp = FormatDateTime(Now, 1)&" "& Hour(Time) &"-"& Minute(Time) &"-"& Second(Time)
qtResultsOpt.ResultsLocation = fso.GetFolder(fp).ParentFolder& "\results\<TestName>\" &timeStamp
qtpApp.Test.Run qtResultsOpt 'Run the test
Set qtpApp = Nothing
Set qtResultsOpt = Nothing
Set fso = Nothing
THanks,
Tarun K

Wednesday, March 3, 2010

QTP Glitches So Far...

Well, I have started work on QTP after having worked on couple of functional test automation tools like – Selenium and Test Complete.
My first impression with QTP has not been very positive; herein I have listed few glitches I experienced so (I can only hope this list not overgrowing with time)
  • No Refactor of code – so if u modify a function name in one place it has to be updated manually in all function calls
  • “General Run Error” – try to check a check box which is disabled and you receive “General Run Error”! Can’t it say object is disable
There have been other mysteriously intermittent instances of “General Run Error” about whom I am still groping in dark
  • If used ExecuteFile to get function definition in Action then there is no way to jump to function definition from action. Function has to be opened manually. (I don’t associate function library as it is going to hardcode path to function)
  • While running QTP tests on a System it can not be used for any other task, QTP keeps bringing browser to top on which tests are executed
  • QTP on locked system, File Upload just does not work on locked system
  • Keep shared repo opened while executing test and be ready for unknown errors
  • Unable to test API on fly (It is Test Complete feature I love most), so if you want to check Web Table data – GetCellData(row, column)
Then you should execute it in test and there is no way to tests it from Object Spy itself
  • Some time have static screen while executing test and I keep waiting for next action, good if there were Test Complete sort of display during test execution
SO FAR………….
THanks,
Tarun K

Close Browser in QTP

Want to close browser on the basis of there creation time, just use –
Browser("CreationTime:=1").Close
THanks,
Tarun K

Tuesday, February 23, 2010

Initial QTP Scripts in CVS

In a QTP Test following files should be committed to cvs/svn –
In Action
ObjectRepository.bdb
Resource.mtr
Script.MTS
Root Folder
Default.xls
Test.tsp
Out of these files only “Script.MTS” is used by QTP tests for My App, but QTP still needs other files to open test, hence I had to add those as well.
THanks,
Tarun K

Friday, February 12, 2010

Sravan Durga Outing

Best corporate outing I have ever had.....



Deallocating memory in VB Script

I came across a few articles which talk about setting objects to 'Nothing' after its usages to release memory though I did not find any specific pointer about normal variables.
I variable should be set to 'Empty' to deallocate memory, i.e.

******************************
Dim aVariable
aVariable = 1
aVariable = Empty

MsgBox IsEmpty(aVariable)

Dim aObject
Set aObject = CreateObject("Scripting.FileSystemObject")
Set aObject = Nothing

MsgBox aObject Is Nothing
******************************
For more on this refer here


commented on - 16th Feb 2010
Looks like some one has different thought here

Thursday, February 11, 2010

Using ExcelADO to fetch data from excel

We all are aware of externalizing test data from test scripts in test automation.
We often stumble upon using excel as test data file, and I have seen crude ways of handling excel.

i.e. - Creating Excel Application object
Opening work book and fetching data

Disadvantages of this approach are detailed on Microsoft website here - http://support.microsoft.com/kb/278973/EN-US/
In a gist following above mentioned approach would be process heavy and would make script execution (especially in case of long running test suites) slow

Another crude way is to use sheet-name (which is still acceptable), Row and Column number (i.e. - (2, 5)), Row and Column range (B5, B10). Using row and column identifier is fragile as insertion of new data set in excel would break existing test scripts.

A better approach to overcome these is to use ExcelADO along with name of Range in Excel.
ExcelADO overcomes process over head and using Range to overcome fragility over Row and Column Range.
In excel an individual cell or collection of cell could be referenced with name. To do this - Select required cell range and use 'Insert' > 'Name' > 'Define' Menu

Following is a function which returns collection of items from named range in excel file -

'‘**************************************************
'Function Name : Func_GetExcelData
'Description : This function is used to return value from named cell range in excel file
' This method should be used when getting data from individual cell and not from collection fo cell
'Input parameters : strFileName - Name of test data file
' strQuery – SQL Query to execute

'Date of Creation : 19th Feb 2010
'‘**************************************************

Function Func_GetExcelData(strFileName, strQuery)

Dim cn
Dim rs

Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strFileName & ";" _
& "Extended Properties=""Excel 8.0;HDR=Yes;"""


Set rs = CreateObject("ADODB.Recordset")
rs.Open strQuery, cn

'Remove Carriage Return and return the value
dataString = Split (rs.GetString, Chr(13))
Func_GetExcelData = dataString(0)

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing

End Function



'‘**************************************************
'Function Name : Func_GetExcelRangeData
'Description : This function is used to return multiple values from named cell range in excel file
'Input parameters : strFileName - Name of test data file
' strQuery – SQL Query to execute

'Date of Creation : 26th Feb 2010
'‘**************************************************
Function Func_GetExcelRangeData(strFileName, strQuery)

Dim cn
Dim rs

Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strFileName & ";" _
& "Extended Properties=""Excel 8.0;HDR=Yes;"""


Set rs = CreateObject("ADODB.Recordset")
rs.Open strQuery, cn

'Remove Carriage Return and return the value
dataString = rs.GetString
Func_GetExcelRangeData = dataString

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing

End Function




'‘**************************************************
'Function Name : Func_SetExcelData
'Description : This function is used to set data in one cell of excel file
'Input parameters : strFileName - Name of test data file
'strQuery – SQL Query to execute
'strVal - Value to be set
' intIndex - Index where value is to be updated

'Date of Creation : 19th Feb 2010
'‘**************************************************
Function Func_SetExcelData(strFileName, strQuery, strVal)

Dim cn
Dim rs

Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strFileName & ";" _
& "Extended Properties=""Excel 8.0;HDR=Yes;"""


Set rs = CreateObject("ADODB.Recordset")
rs.ActiveConnection = cn

rs.LockType = 2
rs.Source = strQuery
rs.Open

rs.MoveFirst
rs.Fields(0).Value = strVal
rs.Update

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing

End Function

################################################
This Function takes file name and cell range name as arguments. Call to this function would return String with collection of items. These items then can then be separated using split function in vbs.

MsgBox fExcelCellADO("Path to Excel", "MyRange")

I will be more than glad to know a better approach than this.

~ T

n.b I have seen problem while fetching data from just one named cell in office 2003, it works perfect with office 2007

Friday, February 5, 2010

Selenium Function Library

Poornima and I built collection of java Classes for selenium which provide capabilities which are not built in Selenium like - HTML Table Parsing, Custom Verification, Logging to name a few. This project is been existent from some time now, though I never had chance to write up on this. Whole project is available under "Repository" section of Veda for "Testing Competency" project and can be opened using java IDE like Eclipe.
Best way to get acquainted with this API is to generate java doc your self which is no more than child's play.
Make sure you have java 1.5 or higher and ANT 1.7.0
Configure System variable for Java and ANT, once having done this u should be able to see version of java and ant on your console on doing - "java-version" and "ant -verison"
On Console navigate to path where Sel Library is check out, it turns out to be following for me -
"D:\SelFunctionLibrary\SeleniumFunctionLibrary>"
Execute following ANT Target -
D:\SelFunctionLibrary\SeleniumFunctionLibrary>ant -buildfile build.xml javadoc
This will build java doc files in "javadoc" folder of Sel library, which describes package, methods and classes available in Sel Library. These files are in html format and can be easily opened using browser. You should see following out put on execution ANT Target -
###########################################################################
Buildfile: build.xml
init:
[mkdir] Created dir: D:\SelFunctionLibrary\SeleniumFunctionLibrary\build
[echo] Creating Time Stamp
setClassPath:
javadoc:
[javadoc] Generating Javadoc
[javadoc] Javadoc execution
[javadoc] Loading source file D:\SelFunctionLibrary\SeleniumFunctionLibrary\sr
c\com\ciber\core\SelTestCase.java...
[javadoc] Loading source file D:\SelFunctionLibrary\SeleniumFunctionLibrary\sr
c\com\ciber\core\functionlibrary\CustomVerification.java...
[javadoc] Loading source file D:\SelFunctionLibrary\SeleniumFunctionLibrary\sr
c\com\ciber\core\functionlibrary\FileHandler.java...
[javadoc] Loading source file D:\SelFunctionLibrary\SeleniumFunctionLibrary\sr
c\com\ciber\core\functionlibrary\HTMLTableParser.java...
[javadoc] Loading source file D:\SelFunctionLibrary\SeleniumFunctionLibrary\sr
c\com\ciber\core\functionlibrary\LogSelenium.java...
[javadoc] Loading source file D:\SelFunctionLibrary\SeleniumFunctionLibrary\sr
c\com\ciber\core\functionlibrary\Misc.java...
[javadoc] Loading source file D:\SelFunctionLibrary\SeleniumFunctionLibrary\sr
c\com\ciber\core\functionlibrary\SafeSelenium.java...
[javadoc] Loading source file D:\SelFunctionLibrary\SeleniumFunctionLibrary\sr
c\com\ciber\core\functionlibrary\WebObjects.java...
[javadoc] Loading source file D:\SelFunctionLibrary\SeleniumFunctionLibrary\sr
c\com\ciber\testclass\WebTest.java...
[javadoc] Constructing Javadoc information...
[javadoc] Standard Doclet version 1.6.0_11
[javadoc] Building tree for all the packages and classes...
[javadoc] Building index for all the packages and classes...
[javadoc] Building index for all classes...
BUILD SUCCESSFUL
Total time: 3 seconds
#####################################################################################
We appreciate if you contribute to this project in form of - Review, Defects, and Enhancements etc.
~ T

Thursday, January 28, 2010

How to Avoid Hard coding of Paths in QTP Tests

We should avoid hard coding of paths in tests as this adds to portability of test from one machine other.
Consider an action having following statement –
Execute File (D:\GSB\QTP\fucntion\test.vbs)
When tests are ported on a different machine then there is no guaranteed about drive mapping being same.
To over come this, we can read path run time instead of hard coding it; as following -



Make sure assignment of Global is first action as only then Run Time Env file would be available for usage.

THanks,
Tarun K
Fork me on GitHub