Windows Calculator application on Windows 7

277 views
Skip to first unread message

ShilpaChanda

unread,
Jun 8, 2010, 4:42:05 PM6/8/10
to QTP eLearn Team
Hi Friends,

I am new to this group. I am using Windows 7 and trying to work with
Calculator application . I tried with the following changes to record
the script

New Test->Record->on the WebTab Selected the RadioButton "Record and
Run test on any open browser"->on Windows Application Tab selected the
RadioButton Record and Run Only->Seleced the "+" button and added the
calculator path from the C drive i.e. C:\Windows\system32\calc.exe-
>clicked OK->Clicked Apply->clicked ok.

After this when I tried performing the operation 8*2 on the calculator
and the script generated by QTP is :

Window("Calculator").WinButton("Button").Click
Window("Calculator").WinButton("Button_2").Click
Window("Calculator").WinButton("Button_3").Click
Window("Calculator").WinButton("Button_4").Click
Window("Calculator").Close

Please could any one help me why the script did not dispaly the
WinButton("8").Click,
WinButton("*").Click,WinButton("2").Click,WinButton("=").Click in the
1st,2nd,3rd,4th lines.

Any help is appreciated.

Thanks,
Shilpa.

Karthik QTP

unread,
Jun 8, 2010, 5:35:27 PM6/8/10
to QTP eLearn Team
Shilpa - The reason is
1. Windows 7 calculator was designed differently.
2. QTP identifies the object differently too.
3. Alternate, Instead of recording add each object and change the name
for that object to what you desire ... like 1,2,3,4 etc.
4. Also the winedit field may be a prob during GetROProperty ... we
can find work arounds

ShilpaChanda

unread,
Jun 8, 2010, 8:21:24 PM6/8/10
to QTP eLearn Team
Thanks Karthik
> > Shilpa.- Hide quoted text -
>
> - Show quoted text -

ShilpaChanda

unread,
Jun 9, 2010, 3:05:01 PM6/9/10
to QTP eLearn Team
Hi Karthik,

I tried to capture the result from the calculator application but did
not find the EDIT field .Is there any other way to capture the result.

Also, when I tried to make use of systemutil.Run"calc.exe" in the
script and run the application I get 2 calculators opened up bcoz I
pasted the calc path before recoding the script.So if I want to make
use of Systemutil.Run what changes do I need to make.

Thanks,
Shilpa.

On Jun 8, 5:35 pm, Karthik QTP <qtp.ele...@gmail.com> wrote:

Karthik QTP

unread,
Jun 10, 2010, 11:50:45 AM6/10/10
to QTP eLearn Team
Open only 1 calc through the script. Take it out from Record and Run
settings.

What is the error with Edit field? We might need to use DP just in
case .... we will cover this in the classes.

Karthik QTP

unread,
Jun 10, 2010, 12:37:05 PM6/10/10
to QTP eLearn Team
Or try to work with http://www.friendlycanadian.com/applications/CALC.HTM

instead of the windows calc ...

Meera

unread,
Jun 10, 2010, 2:07:39 PM6/10/10
to Karthik QTP, QTP eLearn Team
Hi Karthik,
 
I did add all the calculator objects individually and was able to run a simple test. I tried to run the same code which you showed in the class for calc2 in my system. But it gave me the below error. can you please let me know what should I do here.
 
Cannot find the "9" object's parent "Calc" (class Window). Verify that parent properties match an object currently displayed in your application.
Line (6): "Window("Calc").WinButton("9").Click".
Tip: If the objects in your application have changed, the Maintenance Run Mode can
help you identify and update your steps and/or the objects in your repository.
 
Thank you
Meera
--
Thanks and Regards
Meera
860-830-7017

Karthik QTP

unread,
Jun 10, 2010, 2:17:35 PM6/10/10
to Meera, QTP eLearn Team
PLEASE create your own Object Repository and VB Script code. I generated my code in Windows XP and if you want to run it on a diff OS version or QTP version, QTP may not recognize objects currently. 
--
Karthik
qtp.e...@gmail.com
Call: 314 827 5272

seri seri

unread,
Aug 10, 2010, 8:43:39 AM8/10/10
to Karthik QTP, QTP Elearn Google Group
Hi Karthik,
 
Thank you for reply.
 
I have tried the link you give for on Calc.HTM.it works ok as per your Calc 1, capture the value. However, it will be like the way working in gmail ( Day1), not current application within my local computer.
 
In the below message I read the reason you write to Shilpa.
My question-->WINDOW 7 is not a good platform for QTP practices then?
if it is true, do I have to switch to other OS?
 
i hope not. because it will create lots of Chaos.
 
I have tried below code , thanks to Shilpa for code (SystemUtil.Run "calc.exe") , 
I also change those winButton name to 1,2, 3, _,+ etc as per your instructions.
 
 it works but cannot perform "add object to Local" function.
as QTP cannot read the calculator , but only 'Window' object.
so it is not Window calculator in the Screen of Object Slection - Add Repository , but Window : window ( as per attachment, would you please have a look?).
 
VBScripts :
----------------
'Window("Start menu").WinButton("All Programs").Click
'Window("Start menu").WinTreeView("SysTreeView32").Select "Programs Folder and Fast Items;Accessories"
'Window("Start menu").WinTreeView("SysTreeView32").Select "Programs Folder and Fast Items;Accessories;Calculator"
SystemUtil.Run "calc.exe"
Window("Calc").WinButton("8").Click
Wait 2
Window("Calc").WinButton("+").Click
Wait 2
Window("Calc").WinButton("1").Click
Wait 2
Window("Calc").WinButton("=").Click
Wait 2
Window("Calc").Close
-------------------------------------------------
Do you have better solution for CALC application be able to read by Window 7 in QTP practices?
I have go thru today Day 4 exercise, but unable to  do " Add objects to Local "

Thank you
 
Regards,
 
Kakinang99
 
On Tue, Aug 10, 2010 at 10:05 AM, Kakinang99 <seri...@gmail.com> wrote:

Or try to work with http://www.friendlycanadian.com/applications/CALC.HTM

instead of the windows calc ...



---------- Forwarded message ----------
From: Karthik QTP <qtp.ele...@gmail.com>
Date: Jun 9, 7:35 am
Subject: Windows Calculator application on Windows 7
To: QTP eLearn Team


Shilpa - The reason is
1. Windows 7calculatorwas designed differently.

2. QTP identifies the object differently too.
3. Alternate, Instead of recording add each object and change the name
for that object to what you desire ... like 1,2,3,4 etc.
4. Also the winedit field may be a prob during GetROProperty ... we
can find work arounds

On Jun 8, 1:42 pm, ShilpaChanda <shilpacha...@gmail.com> wrote:



> Hi Friends,

> I am new to this group. I am using Windows 7 and trying to work with
>Calculatorapplication . I tried with the following changes to record

> the script

> New Test->Record->on the WebTab Selected the RadioButton "Record and
> Run test on any open browser"->on Windows Application Tab selected the
> RadioButton Record and Run Only->Seleced the "+" button and added the
>calculatorpath from the C drive i.e. C:\Windows\system32\calc.exe-


> >clicked OK->Clicked Apply->clicked ok.

> After this when I tried performing the operation 8*2 on thecalculator
> and the script generated by QTP is :

> Window("Calculator").WinButton("Button").Click
> Window("Calculator").WinButton("Button_2").Click
> Window("Calculator").WinButton("Button_3").Click
> Window("Calculator").WinButton("Button_4").Click
> Window("Calculator").Close

> Please could any one help me why the script did not dispaly the
> WinButton("8").Click,
> WinButton("*").Click,WinButton("2").Click,WinButton("=").Click in the
> 1st,2nd,3rd,4th lines.

> Any help is appreciated.

> Thanks,
Add Objects to Local screen shot.docx
Reply all
Reply to author
Forward
0 new messages