By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,715 Members | 748 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,715 IT Pros & Developers. It's quick & easy.

How to write code to get focuse the application which is open from server

P: n/a
hi,
I am new to python. I have to write test cases in python. An
application is open in the desk top ( application writen in .Net) I
have to write code to get focuse the application and click on the link
which in the one side and it will load the map on the other and I have
to check map is loaded. Any one tell me how do I use Dispatch or any
other method to write a code.

Jan 7 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"vinthan" <sv****@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
hi,
I am new to python. I have to write test cases in python. An
application is open in the desk top ( application writen in .Net) I
have to write code to get focuse the application and click on the link
which in the one side and it will load the map on the other and I have
to check map is loaded. Any one tell me how do I use Dispatch or any
other method to write a code.
If you are running on Windows, look into pywinauto
(http://www.openqa.org/pywinauto/).

I have successfully used it to interact with a Flash animation running
within an IE browser.

I also had to inspect the graphics displayed by the Flash animation, for
this I used PIL (http://www.pythonware.com/products/pil/).

Good luck,
-- Paul
Jan 7 '07 #2

P: n/a
Hi Paul,
Since your reply I try to use pywinauto. I was able to get the control
of a window that is a good news but it is not working for sub window
this main window create.(popup windows)
eg) File -print will open print window but the code is not
clicking print button. I try several combination
app,Print.OK.CloseClick() or app,Print.OK.Click() is not working

my code goes like that
app=application.Application()
qi = app.window_(title_re = ".*arcMap.*")
qi.TypeKeys("%FP")
app,Print.OK.Click()

the last line of code is not working same thing with file open to
qi.TypeKeys("%FO") create popup window "open" but
app,Open.Filename.SetEditText("test1,txt") is not working any help to
overcome to this problem (Here the "Print" , "Open" are windows title I
am using without any undestanding why I am using. Any help?

Paul McGuire wrote:
"vinthan" <sv****@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
hi,
I am new to python. I have to write test cases in python. An
application is open in the desk top ( application writen in .Net) I
have to write code to get focuse the application and click on the link
which in the one side and it will load the map on the other and I have
to check map is loaded. Any one tell me how do I use Dispatch or any
other method to write a code.
If you are running on Windows, look into pywinauto
(http://www.openqa.org/pywinauto/).

I have successfully used it to interact with a Flash animation running
within an IE browser.

I also had to inspect the graphics displayed by the Flash animation, for
this I used PIL (http://www.pythonware.com/products/pil/).

Good luck,
-- Paul
Jan 15 '07 #3

P: n/a
Hi Paul,
Since your reply I try to use pywinauto. I was able to get the control
of a window that is a good news but it is not working for sub window
this main window create.(popup windows)
eg) File -print will open print window but the code is not
clicking print button. I try several combination
app,Print.OK.CloseClick() or app,Print.OK.Click() is not working

my code goes like that
app=application.Application()
qi = app.window_(title_re = ".*arcMap.*")
qi.TypeKeys("%FP")
app,Print.OK.Click()

the last line of code is not working same thing with file open to
qi.TypeKeys("%FO") create popup window "open" but
app,Open.Filename.SetEditText("test1,txt") is not working any help to
overcome to this problem (Here the "Print" , "Open" are windows title I
am using without any undestanding why I am using. Any help?

Paul McGuire wrote:
"vinthan" <sv****@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
hi,
I am new to python. I have to write test cases in python. An
application is open in the desk top ( application writen in .Net) I
have to write code to get focuse the application and click on the link
which in the one side and it will load the map on the other and I have
to check map is loaded. Any one tell me how do I use Dispatch or any
other method to write a code.
If you are running on Windows, look into pywinauto
(http://www.openqa.org/pywinauto/).

I have successfully used it to interact with a Flash animation running
within an IE browser.

I also had to inspect the graphics displayed by the Flash animation, for
this I used PIL (http://www.pythonware.com/products/pil/).

Good luck,
-- Paul
Jan 15 '07 #4

P: n/a
Dennis,
I am sorry that was a typing error. I try like that
app.Print.OK.Click() but it was not working. The printer window was not
IdentifiedIs their any method I can use to achive the same goal. How
the window title was used as class name?. Could you please help me to
solve this problem.
thanks
this is the error meassage

Traceback (most recent call last):
File "C:\Python24\test1.py", line 10, in -toplevel-
app.Print.Ok.CloseClick()
File "c:\python24\pywinauto\pywinauto\application.p y", line 237, in
__getattr__
ctrls = _resolve_control(
File "c:\python24\pywinauto\pywinauto\application.p y", line 854, in
_resolve_control
ctrl = _get_ctrl(criteria)
File "c:\python24\pywinauto\pywinauto\application.p y", line 622, in
_get_ctrl
dialog = controls.WrapHandle(
File "c:\python24\pywinauto\pywinauto\findwindows.p y", line 62, in
find_window
windows = find_windows(**kwargs)
File "c:\python24\pywinauto\pywinauto\findwindows.p y", line 177, in
find_windows
windows = findbestmatch.find_best_control_matches(
File "c:\python24\pywinauto\pywinauto\findbestmatch.py" , line 483, in
find_best_control_matches
raise MatchError(items = name_control_map.keys(), tofind =
search_text)
MatchError: Could not find 'Print' in '['', u'Transparent Windows
Client0', u'Transparent Windows Client2', u'Transparent Windows
Client1', u'Print - \\\\Remote', u'Transparent Windows Client', u'Print
- \\\\RemoteTransparent Windows Client']'

This is the code
import sys
import time
import application
app = application.Application()
qi=app.window_(title_re = ".*ArcView.*")
time.sleep(2)
qi.TypeKeys("%FP")
time.sleep(2)

app.Print.Ok.CloseClick()
Dennis Lee Bieber wrote:
On 14 Jan 2007 21:11:35 -0800, "vithi" <vi*****@hotmail.comdeclaimed
the following in comp.lang.python:

my code goes like that

"goes like"? Don't type similarities from memory -- cut&paste the
actual code (or, preferably, a stripped down version that you've
actually run) that shows the behavior in question.
app=application.Application()
qi = app.window_(title_re = ".*arcMap.*")
qi.TypeKeys("%FP")
app,Print.OK.Click()
And what is that last line supposed to be doing. "app,anything" is
two separate objects: an application object, and something called Print
with an attribute called OK which itself has a method called Click

I suspect, at a minimum, that last line is supposed to be

app.Print.OK.Click()
^ period, not
Jan 15 '07 #5

P: n/a
Dennis,
I am sorry that was a typing error. I try like that
app.Print.OK.Click() but it was not working. The printer window was not
IdentifiedIs their any method I can use to achive the same goal. How
the window title was used as class name?. Could you please help me to
solve this problem.
thanks
this is the error meassage

Traceback (most recent call last):
File "C:\Python24\test1.py", line 10, in -toplevel-
app.Print.Ok.CloseClick()
File "c:\python24\pywinauto\pywinauto\application.p y", line 237, in
__getattr__
ctrls = _resolve_control(
File "c:\python24\pywinauto\pywinauto\application.p y", line 854, in
_resolve_control
ctrl = _get_ctrl(criteria)
File "c:\python24\pywinauto\pywinauto\application.p y", line 622, in
_get_ctrl
dialog = controls.WrapHandle(
File "c:\python24\pywinauto\pywinauto\findwindows.p y", line 62, in
find_window
windows = find_windows(**kwargs)
File "c:\python24\pywinauto\pywinauto\findwindows.p y", line 177, in
find_windows
windows = findbestmatch.find_best_control_matches(
File "c:\python24\pywinauto\pywinauto\findbestmatch.py" , line 483, in
find_best_control_matches
raise MatchError(items = name_control_map.keys(), tofind =
search_text)
MatchError: Could not find 'Print' in '['', u'Transparent Windows
Client0', u'Transparent Windows Client2', u'Transparent Windows
Client1', u'Print - \\\\Remote', u'Transparent Windows Client', u'Print
- \\\\RemoteTransparent Windows Client']'

This is the code
import sys
import time
import application
app = application.Application()
qi=app.window_(title_re = ".*ArcView.*")
time.sleep(2)
qi.TypeKeys("%FP")
time.sleep(2)

app.Print.Ok.CloseClick()
Dennis Lee Bieber wrote:
On 14 Jan 2007 21:11:35 -0800, "vithi" <vi*****@hotmail.comdeclaimed
the following in comp.lang.python:

my code goes like that

"goes like"? Don't type similarities from memory -- cut&paste the
actual code (or, preferably, a stripped down version that you've
actually run) that shows the behavior in question.
app=application.Application()
qi = app.window_(title_re = ".*arcMap.*")
qi.TypeKeys("%FP")
app,Print.OK.Click()
And what is that last line supposed to be doing. "app,anything" is
two separate objects: an application object, and something called Print
with an attribute called OK which itself has a method called Click

I suspect, at a minimum, that last line is supposed to be

app.Print.OK.Click()
^ period, not
Jan 15 '07 #6

P: n/a
At Monday 15/1/2007 15:53, vithi wrote:
>I am sorry that was a typing error. I try like that
app.Print.OK.Click() but it was not working. The printer window was not
IdentifiedIs their any method I can use to achive the same goal. How
the window title was used as class name?. Could you please help me to
solve this problem.
app.Print looks for a window whose title contains the word "Print"
(does it exist?), inside, looks for a control with "OK" (presumably a
button), and sends it a mouse click event.
There is a forum specific for pywinauto questions - see its homepage.
--
Gabriel Genellina
Softlab SRL


__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Jan 15 '07 #7

P: n/a
Hi,

There are better places to find me then on comp.lang.python (just too
much traffic for me)
pywinauto forums: http://forums.openqa.org/forum.jspa?forumID=15
or subscribe pywinauto mailing list:
https://lists.sourceforge.net/lists/...ywinauto-users
vithi wrote:
<SNIP>
MatchError: Could not find 'Print' in '['', u'Transparent Windows
Client0', u'Transparent Windows Client2', u'Transparent Windows
Client1', u'Print - \\\\Remote', u'Transparent Windows Client', u'Print
- \\\\RemoteTransparent Windows Client']'

This is the code
import sys
import time
import application
app = application.Application()
qi=app.window_(title_re = ".*ArcView.*")
time.sleep(2)
qi.TypeKeys("%FP")
time.sleep(2)

app.Print.Ok.CloseClick()

My guess is that problem above is that teh title of the window is
u"Print - \\Remote", and "Print" is not enough information for
pywinauto to go on.

I suggest you replace the last line with one of the following...
app.PrintRemote.Ok.CloseClick()
app.window_(title_re = "Print - .*").Ok.CloseClick()

Someone also was wondering why they do not have to call
Application.Start() or Application.Connect() explicitly - that is
because the first call to app.window_() will initialize the application
appropriately. The reason for this is that most usages ended up being
a) Connect to a window with specific title, then use that window in the
next line - so I was trying to avoid duplication.

Thanks
Mark

Jan 18 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.