Deep Patel

Thursday, March 1, 2012

Right click on disabled (or any other object) in QTP

I recently faced a problem on one of the Java Tables.

The table as such was disabled(freezed!).
Which can be enabled by right clicking and selecting "unfreeze"

QTP internally doesn't perform operations on disabled objects so it gave me errors when I used

Browser("SwingSet demo").Page("SwingSet demo").JavaApplet("SwingSetApplet").JavaTable("Inter-cell spacing:").ClickCell 2, "Last Name", "RIGHT", "SHIFT"

QTP gives "Object Disabled" message box.

To get over this I used "Mercury.DeviceReplay" object.

Device level replay simulates mouse or key operations exactly as if they occur on the mouse or keyboard drivers. When a mouse action is simulated on device replay, the mouse pointer moves on the screen to the point where the action is to be performed during the test run.

Script Snippet Start

Set objRightClickMenu = CreateObject("Mercury.DeviceReplay")
objRightClickMenu.MouseClick intX, intY, 2
Set objRightClickMenu = nothing

Script Snippet End

Here intX and intY are absolute co ordinates where you want to perform the click.

Tuesday, February 28, 2012

Indians are Engineers at Heart!

The title comes from the commentary on ESPN Cricinfo during todays exciting match between India and Sri Lanka at Bellerive Oval, Australia.

The commentators were awesome throughout. Posting some comments i liked...

"Indians are Engineers..."
when Gambhir and Sachin were getting over Kulasekara and Mahroof


It looked like Gambhir and Kohli were slowing down a bit and the commentator said it...:D
take that Dhoni...



and when Gambhir was out he again said it...:D





Indian team is like rocket...
when boundaries flowed...



Tell the Americans...
we are world champions...





Brief summary of the match:

The Indian skipper had won the toss and decided to bowl first.
Sri Lanka dominated with the batting when the set a target of 321 for India.
India had to make this score in 40 overs to get a bonus point.
Considering the recent games and Sri Lanka's form, it looked like India would struggle to make it upto 321, but thanks to the awesome start given by The God! and Viru; the fluent batting by Gauti; and a match winning innings by Virat Kohli; the Indian team made it in just 36.4 overs.

It was a do or die for team India!
and we made it...we still have a hope to be in the finals. All depends on the match at Melbourne on 2nd March.

Screenshots taken from ESPN Cricifo

Monday, February 27, 2012

QTP Random Number Generation - RandomNumber.Value vs Rnd and Randomize

Recently I was facing a problem in generating Random numbers using QTP.

I started with QTP's inbuilt RandomNumber.Value(upperlimit,lowerlimit)

and the result was:

It would generate random numbers for that instance of QTP. But once QTP is restarted it will generate same numbers in same sequence. Example is shown in the images below.

The QTP always starts the Random Number Generation from the same number. To elaborate, QTP's Random Number function gets initialized with the same number(the seed) every time QTP's instance is created.

So for better performance we can use vb's Rnd function with call to Randomize. Call to Randomize initializes the Rnd function with a new seed value every time(this is based on the system time).
If Randomize is not used, Rnd uses the same number as a seed the first time it is called.
Hence it will generate the same value everytime the function is called.


Below are the results of all the cases. The execution 1 and execution 2 are of separate QTP instances.

Using QTP’s RandomNumber.Value(a,b) function.



Using vb’s Rnd function with Randomize.
This will generate random numbers every time!


Using vb’s Rnd function without Randomize.


Wondering what would happen on using Randomize with QTP's RandomNumber.Value(a,b) !!
Here are the results...

For more on Rnd Function follow check this link


For more on Randomize Function follow check this link

Tuesday, January 10, 2012

Can you define Love?

Before you can grow up, you must fall in love three times.



Once, you must fall in love with your best friend, ruining your friendship forever. This will teach you who your true friends are, and the fine line between friendship and more.

Once you must fall in love with someone you believe is perfect. You will learn that no one is perfect, and that you should never be treated as anything less than you deserve.

And once, you must fall in love with someone that is exactly like you. This will teach you about who you are, and who you want to be.

And when you’re through with all that, you learn that the people who care about you the most are the ones that you hurt, and the ones that hurt you are the ones that needed you the most.

But most of all, you learn that love is only a concept and is not something that can be defined, it is different to each and every person on this earth, knowing that everyone wants to be loved.....!!!!! :)

via @Nignesh Patel

Sunday, September 25, 2011

Thursday, September 22, 2011

Jaane kab hum itne bade ho gaye...

Kabhi pehli baar school jaane mai darr lagta tha,
Aaj milte hi dost ban jaate hai...

Kabhi maa-paapa ki baat sachi lagti thi,
Aaj unhi ko har pal jhuth bolte hai...

Pariyon ki kahaani ki jagah aaj kal raat ko phone pe "gf/bf"(replaced "dosto") ki baate sunna zyada acha lagta hai...

Pehle 1st aane ke liye pure saal padhte the,
Aaj paas hone ko taraste hai...

Cartoons ki jagah ab reality shows acche lagte hain...

Kabhi choti si chot lagne pe itna rote the,
Aaj Dil tut jaata hai fir bhi sambhal jaate hain...

Pehle dost bas saath khelne tak yaad rehte the,
Aaj wahi dost jaan se zyada pyaare lagte hain...

Ek din tha jab pal me ladna pal me manana to roz ka kaam tha,
Aaj jo ek baar juda hue to fir gehre rishte tak kho jaate hain...

Sach me zindagi ne bahut kuch sikha diya,
Jaane kab hume itna bada bana diya...

via Dips(SMS)