473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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

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
7 5436
"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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Greg Hurlman | last post by:
I've got what I'm sure is a very simple problem. In an ASP page, I am trying to write out 4 fields from a recordset in succession: Response.Write rs("LastName") Response.Write rs("Suffix")...
2
by: Mohammed | last post by:
when I add new nods to the tree and it has Hscroll bar the scroll bar goes down and the focuse goes to the first node shown in the down part of the tree how can I get the scroll bar goes up and get...
4
by: Lloyd Dupont | last post by:
I created a ============== public class LangModule : IHttpModule { public void Dispose() {} public void Init(HttpApplication application) { HttpContext context = application.Context;...
2
by: domtam | last post by:
Hi there. My goal is to write a windows service that can act as HTTP Request server. How can I do that? I know that I can use ASP.NET to develop a web site to achieve this purpose, i.e....
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
4
by: Seok Bee | last post by:
Dear Experts, I have created a script to extract the Event Logs from the system into an excel sheet. The logs are separated into 2 worksheets (Application Log and System Log). After this excel...
8
by: Mike Silva | last post by:
Hello all, I'm a longtime programmer (embedded with a smattering of desktop stuff as well) who knows very little about web programming. Right now I am developing the prototype of a multi-user...
7
by: duli | last post by:
Hi: I would like recommendations for books (in any language, not necessarily C++, C, python) which have walkthroughs for developing a big software project ? So starting from inception, problem...
5
by: =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?= | last post by:
I'm sorry, but I've read your code a couple of times and just don't see where the Form1 is initialized. Form1 also sounds like a class name, and this would be how you could do some form operations...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.