Deep Patel: 2012

Wednesday, December 26, 2012

Running a PASSPORT Emulator macro using a Visual Basic Application(Excel Macro)


Title
Running a PASSPORT Emulator macro using a Visual Basic Application(Excel Macro)

Product
PASSPORT PC TO HOST

Emulation Types
SCO ANSI, Wyse 60, TN3270, TN5250, VT

Issue
Need to run a PASSPORT Macro from a Visual Basic Application.

Please see the following sample macro below:

Sub runmacro_zam()
    navigateto "C:\progra~1\passport\login.zam"
End Sub

Sub runmacro_zmc()
    navigateto "C:\progra~1\passport\login.zmc"
End Sub

Sub navigateto(macroname)
    Dim objSys
    Dim objSess
   
    Set objSys = CreateObject("PASSPORT.System")
    Set objSess = objSys.ActiveSession
   
    ' Assume you already have a PASSPORT session running
    objSess.navigateto macroname
End Sub

' You can use this too, but it will not work with a .zmc macro
Sub runmacro()
    Dim WshShell
   
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Exec ("C:\progra~1\passport\passatmr.exe /A 0 0 c:\progra~1\passport\login.zam")
End Sub

Thursday, December 13, 2012

Excel 2003 Datasheet not getting imported in QTP 10 Datatable

Recently faced issue,
"Excel 2003 Datasheet not getting imported in QTP 10 Datatable"

Environment Conditions:
- QTP 10
- Excel 2003/2007/2010 with no Excel Addins installed(Addins like Data Classification tools)
- Win XP/7
- File Format of Data Sheet (.xls or 97-2003)


Drilling Down...
Tried many things...
checking compatibility mode of Excel workbook, column headers, etc. Nothing worked.

Finally I tried data row by data row.
Created a new excel with same headers, just went on adding set of rows and finally drilled down to row which had the problem.

Root Cause:

The data in the column contained n-Dash instead of Hyphen
n-Dash being UNICODE character occupies more space and then hyphen(an ASCII).

Now when the total character size of cells containing Unicode characters increases beyond a certain limit(not sure about the limit but this is what I got from the set of execution I performed), QTP is not able to import any sheet of that Excel Workbook.

The difference can be seen below. n-dash in 1st row and hyphen in 2nd.






Solution: Replace all n-Dash by Hyphen

Try this if you too are facing a similar problem. Hope it helps...

Cheers....

Tuesday, May 8, 2012

Manzil bhi uski thi...

Manzil bhi uski thi rasta bhi uska tha,
Musafir bhi unke the aur kafila bhi uska tha,

Saath saath chalne ki soch bhi uski thi,
Phir rasta badal ne ka faisla bhi uska tha,

Hathon me haath lekar hame hasane ki kasam bhi uski thi,
Phir hamari aankho me aansuo ka silsila bhi uska tha,

Mohabbat ki khwahish to hamari thi,
Par dil tod ne ka iraada uska tha,

Aaj tanha hai to dil ye sochta hai,
Duniya to uski thi par kya khuda bhi uska tha???

via SMS

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