473,796 Members | 2,875 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5471
"vinthan" <sv****@gmail.c omwrote in message
news:11******** **************@ v33g2000cwv.goo glegroups.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.Cl oseClick() or app,Print.OK.Cl ick() is not working

my code goes like that
app=application .Application()
qi = app.window_(tit le_re = ".*arcMap.* ")
qi.TypeKeys("%F P")
app,Print.OK.Cl ick()

the last line of code is not working same thing with file open to
qi.TypeKeys("%F O") create popup window "open" but
app,Open.Filena me.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.c omwrote in message
news:11******** **************@ v33g2000cwv.goo glegroups.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.Cl oseClick() or app,Print.OK.Cl ick() is not working

my code goes like that
app=application .Application()
qi = app.window_(tit le_re = ".*arcMap.* ")
qi.TypeKeys("%F P")
app,Print.OK.Cl ick()

the last line of code is not working same thing with file open to
qi.TypeKeys("%F O") create popup window "open" but
app,Open.Filena me.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.c omwrote in message
news:11******** **************@ v33g2000cwv.goo glegroups.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.Cl ick() 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\te st1.py", line 10, in -toplevel-
app.Print.Ok.Cl oseClick()
File "c:\python24\py winauto\pywinau to\application. py", line 237, in
__getattr__
ctrls = _resolve_contro l(
File "c:\python24\py winauto\pywinau to\application. py", line 854, in
_resolve_contro l
ctrl = _get_ctrl(crite ria)
File "c:\python24\py winauto\pywinau to\application. py", line 622, in
_get_ctrl
dialog = controls.WrapHa ndle(
File "c:\python24\py winauto\pywinau to\findwindows. py", line 62, in
find_window
windows = find_windows(** kwargs)
File "c:\python24\py winauto\pywinau to\findwindows. py", line 177, in
find_windows
windows = findbestmatch.f ind_best_contro l_matches(
File "c:\python24\py winauto\pywinau to\findbestmatc h.py", line 483, in
find_best_contr ol_matches
raise MatchError(item s = name_control_ma p.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
- \\\\RemoteTrans parent Windows Client']'

This is the code
import sys
import time
import application
app = application.App lication()
qi=app.window_( title_re = ".*ArcView. *")
time.sleep(2)
qi.TypeKeys("%F P")
time.sleep(2)

app.Print.Ok.Cl oseClick()
Dennis Lee Bieber wrote:
On 14 Jan 2007 21:11:35 -0800, "vithi" <vi*****@hotmai l.comdeclaimed
the following in comp.lang.pytho n:

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_(tit le_re = ".*arcMap.* ")
qi.TypeKeys("%F P")
app,Print.OK.Cl ick()
And what is that last line supposed to be doing. "app,anythi ng" 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.Cl ick()
^ period, not
Jan 15 '07 #5
Dennis,
I am sorry that was a typing error. I try like that
app.Print.OK.Cl ick() 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\te st1.py", line 10, in -toplevel-
app.Print.Ok.Cl oseClick()
File "c:\python24\py winauto\pywinau to\application. py", line 237, in
__getattr__
ctrls = _resolve_contro l(
File "c:\python24\py winauto\pywinau to\application. py", line 854, in
_resolve_contro l
ctrl = _get_ctrl(crite ria)
File "c:\python24\py winauto\pywinau to\application. py", line 622, in
_get_ctrl
dialog = controls.WrapHa ndle(
File "c:\python24\py winauto\pywinau to\findwindows. py", line 62, in
find_window
windows = find_windows(** kwargs)
File "c:\python24\py winauto\pywinau to\findwindows. py", line 177, in
find_windows
windows = findbestmatch.f ind_best_contro l_matches(
File "c:\python24\py winauto\pywinau to\findbestmatc h.py", line 483, in
find_best_contr ol_matches
raise MatchError(item s = name_control_ma p.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
- \\\\RemoteTrans parent Windows Client']'

This is the code
import sys
import time
import application
app = application.App lication()
qi=app.window_( title_re = ".*ArcView. *")
time.sleep(2)
qi.TypeKeys("%F P")
time.sleep(2)

app.Print.Ok.Cl oseClick()
Dennis Lee Bieber wrote:
On 14 Jan 2007 21:11:35 -0800, "vithi" <vi*****@hotmai l.comdeclaimed
the following in comp.lang.pytho n:

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_(tit le_re = ".*arcMap.* ")
qi.TypeKeys("%F P")
app,Print.OK.Cl ick()
And what is that last line supposed to be doing. "app,anythi ng" 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.Cl ick()
^ 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.C lick() 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.pytho n (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
- \\\\RemoteTrans parent Windows Client']'

This is the code
import sys
import time
import application
app = application.App lication()
qi=app.window_( title_re = ".*ArcView. *")
time.sleep(2)
qi.TypeKeys("%F P")
time.sleep(2)

app.Print.Ok.Cl oseClick()

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_(tit le_re = "Print - .*").Ok.CloseCl ick()

Someone also was wondering why they do not have to call
Application.Sta rt() or Application.Con nect() 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
2912
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") Response.Write rs("FirstName") Response.Write rs("MiddleInitial") All fields are populated and are single terms. I would expect "LastNameSuffixFirstNameMiddleInitial" ("UserIIITestA" in my test record) to
2
1043
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 the focuse at the very first node of the tree
4
2743
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; HttpCookie lc = context.Request.Cookies;
2
2684
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. receive HTTP request. However, I'd like it to exist in the form of a "Windows Service".
15
4645
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 communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
4
7288
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 file being created, it will be sent out via email to the list of recipients. I run the script on my notebook (also developed on th same machine) it works fine. However, when I copy all the programs into the server which running on Windows 2000...
8
1723
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 application in MSVC++, but I think it would make more sense to redo the app as a web application (which I know almost nothing about, remember). From poking around I see that PHP is a fairly mainstream candidate for me to consider. Now, I will...
7
2028
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 definition, design, coding and final delivery on a single theme or application. Most of the code I have written and books that I have read deal with toy programs and I am looking for something a bit more comprehensive. For example, maybe a...
5
2365
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 in vb6, but not in .Net. This would explain why the messagebox works, as it is not instantiated, but called statically as you did in your code. I think you need this where your MsgBox is called: dim ui as New Form1() ui.txt_rec.Text =...
0
9679
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9527
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10453
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10172
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.