Wednesday, 4 February 2009

Change the system time through QTP!!

Dim mytime
sNewDate = Time
msgbox sNewDate
mytime = split(sNewDate,":",-1,1)
hr = mytime(0) + 10
msgbox hr
min = mytime(1) + 20
msgbox min
sNewDate = (hr)&":"&(min)
sNewDate = cstr(sNewDate)
msgbox sNewDate
Dim oShell
Set oShell = CreateObject ("WSCript.shell")
oShell.run "cmd /k Time " & sNewDate & "& Exit"

Tuesday, 14 October 2008

Passing the parameters to a function ByRef..

Dim O1
Set O1 = Description.Create
O1= "Any Property goes here"


Call Fun1(O1)

Function Fun1(ByRef O1)

msgbox O1

End Function

Monday, 6 October 2008

Implementing the datadriven framework

RowCount1 = Datatable.GetSheet("CRM_Supplier").GetRowcount

For j=0 to RowCount1-1

Datatable.SetCurrentRow(j+1)

Monday, 29 September 2008

System Date change through QTP

Many a times an automation engineer can come up with a scnerio where he needs to change the system date. So how to approach this? Following is the code snippet that i have used and it works sucessfully:

sNewDate = Date + 5
sNewDate = Cdate(sNewDate)
Dim oShell
Set oShell = CreateObject ("WSCript.shell")
oShell.run "cmd /k Date " & sNewDate & "& Exit"

Sunday, 21 September 2008

Why to go for SetTOProperty in QTP.

The SetToProperty can be useful when the engineer does not want to add the multiple objects of same type with differing values. The same can be explained with an example like we have two editboxes in the application and both differ by an assistive proprty.Here we can add only one of them in ObjectRepository and while dealing with the second one we can use the first Object and define the assistive property at runtime in code. The code can go as

Object(Description).SetTOProperty Property,Value

Lets explore the same with Flight application example:

Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Type "shantanu"
Dialog("Login").WinEdit("Agent Name:").SetTOProperty "attached text","Password:"
Dialog("Login").WinEdit("Agent Name:").SetSecure "4884a1b87838d0a7a817a550056f14667e65eecd"
Dialog("Login").WinButton("OK").Click

Now here my ObjectRepository(OR) does contain only one WinEdit box and that is "Agent Name" only. So what i have done here is reduced the load on OR by defining the only one editbox and adding the second edit box at run time.

Tuesday, 15 July 2008

DescriptiveProgramming and QTP

Why do we go for Descriptive Programming?

Many a times this question is posted on the various QTP Forums. Taking a practical example from my project i will try to illustrate why we go for Descriptive Programming.

My Project uses data driven Automation framework where we use the shared object repositories as well. The repositories are created after which there is always some addition of Objets on the same screens from AUT. So next time when i go for scripting the same screen i need to identify the newly added objects but i can not change the Object repositories as well as modifying the same will require me to change the name of the it and can hamper the smooth execution of previously crated scripts.

And so here comes into picture a handy feature of the QTP called DP(Descriptive Programming). So what i do exactly?

Through Object spy , I identify the mandatory properties of these Objects and write a code which looks like:

dim EdPartCombo 'Declare the Variable
Set EdPartCombo = Description.Create 'After this line we are setting up the mandatory properties to the above created Variable

EdPartCombo("window id").value = "1001"
EdPartCombo("nativeclass").value="Edit"
EdPartCombo("location").value="0"

and i put this code just before using the "EdPartCombo" in my script for the first time. So while executing the script when

QTP finds the above code it creats the Object and assigns the described properties to the same and uses this object in the script execution.

Friday, 1 December 2006

Hats off to India (specially to Media)


The body of Major Manish Pitambare, who was shot dead at Anantnag, was cremated with full military honours at Thane on Wednesday.

On Tuesday a news swept across all the news channels 'Sanjay Datt relieved by the court'. 'Sirf Munna Not a bhai' '13 saal ka vanvaas khatam' 'alhough found guilty for possession of armory, Sanjay can breath sigh of relief as all the TADA charges against him are withdrawn'

And then many experts like Salman khan saying 'He is a good person. We knew he will come out clean' Mr. Big B 'Datt family and our family have relations for years he's a good kid. He is like elder brother to abhishek'. His sister priya Datt 'we can sleep well tonight.it's a great relief'

In other news, Parliament was mad at Indian team for performing bad; Greg chapel said something ...; Bomb scare in gorakhpoor express; and Shah Rukh Khan replaces Big B in KBC and Sonia asked PM to consider reducing petroleum prices (I wonder who's the PM .anyways that is not the topic so leave it.) But most of the emphasis was given on Sanjay Datt's "phoenix like" comeback from the ashes of terrorist charges.

Surfing through the channels, one news on BBC startled me, it read, Hisbul Mujahidin's Most wanted terrorist 'Sohel Faisal' killed in anantnag, India. Indian Major leading the operation lost his life in the process. Four others are injured.

It was past midnight, I started visiting the Indian channels, the ones who are 'Sabse TEZ', but Sanjubaba was still ruling. They were telling How Sanjubaba pleaded to the court saying 'I am the sole bread earner for my family' 'I have a daughter who is studying in US who will look after her'. And then they showed how sanjubaba was not wearing his lucky blue shirt while he was hearing the verdict. Also how he went to every temple and prayed for last some months. A suspect in Mumbai bomb blasts, convicted under armory act...was being made into a hero.

Sure Sanjubaba has a daughter; sure sanjubaba did not do any terrorist thing as in bombing some place or hijacking an airplane etc. Possessing an AK47 is considered too elementary in terrorist community and also one who possesses an AK47 has a right to possess a pistol so that again is not such a big crime; Sure sanjubaba went to all the temples; Sure he did a lot of gandhigiri but then..., people. please read on...



Major Manish H Pitambare got the information from his sources about the terrorists' whereabouts. Wasting no time he attacked the camp killed the Hisbul mujahidin's suprimo and in the process lost his life... To the bullets fired from an AK47..



He has a wife and a daughter (just like sanjubaba), age ...18 months.



Major Manish never said 'I have a daughter' .before he took the decision to attack the terrorist hide out in the darkest of nights?

He never thought about having a family and he being the bread earner



No news channel covered this since they were too busy hyping a former drug addict, an actor in real and reel life, a suspect who's linked to bomb blasts which killed hundreds. Their aim was to show how he defied the TADA charges and they were so successful that his conviction in possession of armory had no meaning. They also concluded that his parents in heaven must be happy and proud of him..

Parents of Major Pitambare are still on this earth and they have to live rest of their lives without their beloved son. His daughter won't ever see her papa again.

Definition of a Star has changed Major. it really has. So sanjubaba always has a gun in every one of his movies then in real life if he has an AK47 then what's the big deal we are used to see him with some ammunition without it he's just a 49yr old hero so he did it for us...so that we feel normal;



Even if one of the bullets from one of such AK47's took a Real Star's life ...



but sir bole toh ... tension nahi leneka. Aapun ko thoda bura laga. Apun pure din aapke baarein mein socha. Sach bataun kya aapun dukhi matlab ki senty ho gaya isliye ye likha.



Baaki sanjubaba...bole toh. congrats.aapko salmaan bhai ne kya certificate diya hai .ekdum raaapchik. kal jab unka case (haan woich hiran ki shikar wala) aaye toh aap bhi aisaich bolna unke baarein mein. Abhi aaj paper mein aaya ki woh parliament mein 'lagey raho munnabhai' dikhane wale ..us din dekhna bhai.. pure parliament mein sab saarein sansad honge. koi walk out nahi karega par bhai uska koi gurantee nahi hai kya pata ...agar hamare sansad indian cricket team ke selection pe lad padein?...... Kya bhaai point hain naa ? AAre haan apun ko yaad aaya ..woh sansad pe hamla karnewala koi afzal tha ..use abhi fasi hui .ya nahi hui ...jaane do apun ko kya.. kuch log marein ... sansad ko bachatein hue .but bhai unki daughters toh india mein hich sikhti hain naa aapke jaise amerika mein nahi toh tension nahi leneka...



Sorry major, wo kya hai naa logon ko shudh hindi samztich nahi aajkal bole toh logon ka hriday parivartan hone ke liye aisahich likhna padta hai. But major... ab ye kaise hoga aaapun ko nahi pata log boley saala lagey raho dekhke puri janta ab change hoegi koi rastein mein nahi thukega ... koi zhut nahi bolega koi kisi ko pareshaan nahi karega desh mein gandhigiri aayegi.. par major apun ko doubt hai... pata hain kyon ?

... rang de basanti aayi thi tab bhi log aisehich kuch toh bolein they.



Finally Sir, to my generation there is no greater hero than one who laid his life in the name of this great nation. Hence Sir, I salute you. You are the real Star, Vande mataram.