re-created documentation and fixed UnicodeEncoding errors
This commit is contained in:
parent
70e54e9aa4
commit
5fc66f74fd
@ -1,6 +1,7 @@
|
||||
0.3.5 Moved to Metaclass control wrapping
|
||||
------------------------------------------------------------------
|
||||
24-May-2006
|
||||
|
||||
* Moved to a metaclass implementation of control finding. This
|
||||
removes some cyclic importing that had to be worked around and
|
||||
other then metaclass magic makes the code a bit simpler.
|
||||
|
@ -4,6 +4,14 @@ Getting Started
|
||||
|
||||
Once you have installed pywinauto - how do you get going?
|
||||
|
||||
Sit back and have a look at a little movie
|
||||
-------------------------------------------
|
||||
|
||||
Jeff Winkler has created a nice screencast of using pywinauto, you
|
||||
can see it at :
|
||||
|
||||
http://www.showmedo.com/videoPage?name=UsingpyWinAutoToControlAWindowsApplication
|
||||
|
||||
|
||||
Look at the examples
|
||||
--------------------
|
||||
@ -13,65 +21,100 @@ The following examples are included:
|
||||
language of product that they were programmed for. All examples have
|
||||
been programmed for English Software except where highlighted.
|
||||
|
||||
mspaint.py Control MSPaint
|
||||
notepad_fast.py Use fast timing settings to control Notepad
|
||||
notepad_slow.py Use slow timing settings to control Notepad
|
||||
notepad_item.py Use item rather then attribute access to control Notepad.
|
||||
``mspaint.py`` Control MSPaint
|
||||
``notepad_fast.py`` Use fast timing settings to control Notepad
|
||||
``notepad_slow.py`` Use slow timing settings to control Notepad
|
||||
``notepad_item.py`` Use item rather then attribute access to control Notepad.
|
||||
|
||||
MiscExamples.py Show some exceptions and how to get control identifiers.
|
||||
``MiscExamples.py`` Show some exceptions and how to get control identifiers.
|
||||
|
||||
SaveFromInternetExplorer.py Save a Web Page from Internet Explorer
|
||||
SaveFromFirefox.py Save a Web Page from Firefox.
|
||||
``SaveFromInternetExplorer.py`` Save a Web Page from Internet Explorer
|
||||
``SaveFromFirefox.py`` Save a Web Page from Firefox.
|
||||
|
||||
get_winrar_info.py Example of how to do multilingual automation.
|
||||
``get_winrar_info.py`` Example of how to do multilingual automation.
|
||||
This is not an ideal example (works on French, Czech and German WinRar)
|
||||
|
||||
ForteAgentSample.py Example of dealing with a complex application that
|
||||
``ForteAgentSample.py`` Example of dealing with a complex application that
|
||||
is quite dynamic and gives different dialogs often when starting.
|
||||
|
||||
windowmediaplayer.py Just another example - deals with check boxes in a
|
||||
``windowmediaplayer.py`` Just another example - deals with check boxes in a
|
||||
ListView.
|
||||
|
||||
test_sakura.py Two examples of automating a Japanase product.
|
||||
test_sakura2.py
|
||||
``test_sakura.py`` Two examples of automating a Japanase product.
|
||||
``test_sakura2.py``
|
||||
|
||||
Automate notepad at the command line
|
||||
-------------------------------------
|
||||
|
||||
Please find below a sample run
|
||||
Please find below a sample run ::
|
||||
|
||||
C:\>python
|
||||
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
|
||||
Type "help", "copyright", "credits" or "license" for more information.
|
||||
(1) >>> from pywinauto import application
|
||||
(2) >>> app = application.Application()
|
||||
(3) >>> app.Start_("Notepad.exe")
|
||||
<pywinauto.application.Application object at 0x00AE0990>
|
||||
(4) >>> app.Notepad.DrawOutline()
|
||||
(5) >>> app.Notepad.MenuSelect("Edit -> Replace")
|
||||
(6) >>> app.Replace.PrintControlIdentifiers()
|
||||
Control Identifiers:
|
||||
Static - 'Fi&nd what:' (L1018, T159, R1090, B172)
|
||||
'Fi&nd what:' 'Fi&nd what:Static' 'Static' 'Static0' 'Static1'
|
||||
Edit - '' (L1093, T155, R1264, B175)
|
||||
'Edit' 'Edit0' 'Edit1' 'Fi&nd what:Edit'
|
||||
Static - 'Re&place with:' (L1018, T186, R1090, B199)
|
||||
'Re&place with:' 'Re&place with:Static' 'Static2'
|
||||
Edit - '' (L1093, T183, R1264, B203)
|
||||
'Edit2' 'Re&place with:Edit'
|
||||
Button - 'Match &case' (L1020, T245, R1109, B265)
|
||||
'CheckBox2' 'Match &case' 'Match &caseCheckBox'
|
||||
Button - '&Find Next' (L1273, T151, R1348, B174)
|
||||
'&Find Next' '&Find NextButton' 'Button' 'Button0' 'Button1'
|
||||
Button - '&Replace' (L1273, T178, R1348, B201)
|
||||
'&Replace' '&ReplaceButton' 'Button2'
|
||||
Button - 'Replace &All' (L1273, T206, R1348, B229)
|
||||
'Button3' 'Replace &All' 'Replace &AllButton'
|
||||
Button - 'Cancel' (L1273, T233, R1348, B256)
|
||||
'Button4' 'Cancel' 'CancelButton'
|
||||
(7) >>> app.Replace.Cancel.Click()
|
||||
(8) >>> app.Notepad.Edit.TypeKeys("Hi from Python interactive prompt %s" % str(dir()), with_spaces = True)
|
||||
<pywinauto.controls.win32_controls.EditWrapper object at 0x00DDC2D0>
|
||||
(9) >>> app.Notepad.MenuSelect("File -> Exit")
|
||||
(10) >>> app.Notepad.No.Click()
|
||||
>>>
|
||||
|
||||
1. Import the pywinauto.application module (usually the only module you need
|
||||
to import directly)
|
||||
2. Create an Application instance. All access to the application is done
|
||||
through this object.
|
||||
3. We have created an Application instance in step 2 but we did not supply
|
||||
any information on the Windows application it referred to. By using the
|
||||
Start_() method we execute that application and connect it to the
|
||||
Application instance app.
|
||||
4. Draw a green rectangle around the Notepad dialog - so that we know we have
|
||||
the correct window.
|
||||
5. Select the Replace item from the Edit Menu on the Notepad Dialog of the
|
||||
application that app is connected to.
|
||||
This action will make the Replace dialog appear.
|
||||
6. Print the identifiers for the controls on the Replace dialog, for
|
||||
example the 1st edit control on the Replace dialog can be referred to by
|
||||
any of the following identifiers::
|
||||
|
||||
app.Replace.Edit
|
||||
app.Replace.Edit0
|
||||
app.Replace.Edit1
|
||||
app.FindwhatEdit
|
||||
|
||||
The last is the one that gives the user reading the script aftewards the
|
||||
best idea of what the script does.
|
||||
7. Close the Replace dialog. (In a script file it is safer to use CloseClick()
|
||||
rather than Click() because CloseClick() waits a little longer to give windows
|
||||
time to close the dialog.)
|
||||
8. Let's type some text into the Notepad text area. Without the ``with_spaces``
|
||||
argument spaces would not be typed. Please see documentation for SendKeys
|
||||
for this method as it is a thin wrapper around SendKeys.
|
||||
9. Ask to exit Notepad
|
||||
10. We will be asked if we want to save - Click on the "No" button.
|
||||
|
||||
|
||||
. C:\>python
|
||||
. Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
|
||||
. Type "help", "copyright", "credits" or "license" for more information.
|
||||
(1) >>> from pywinauto import application
|
||||
(2) >>> app = application.Application()
|
||||
(3) >>> app.Start_("Notepad.exe")
|
||||
<pywinauto.application.Application object at 0x00AE0990>
|
||||
(4) >>> app.Notepad.DrawOutline()
|
||||
(5) >>> app.Notepad.MenuSelect("Edit -> Replace")
|
||||
(6) >>> app.Replace.PrintControlIdentifiers()
|
||||
. Control Identifiers:
|
||||
. Static - 'Fi&nd what:' (L1018, T159, R1090, B172)
|
||||
. 'Fi&nd what:' 'Fi&nd what:Static' 'Static' 'Static0' 'Static1'
|
||||
. Edit - '' (L1093, T155, R1264, B175)
|
||||
. 'Edit' 'Edit0' 'Edit1' 'Fi&nd what:Edit'
|
||||
. Static - 'Re&place with:' (L1018, T186, R1090, B199)
|
||||
. 'Re&place with:' 'Re&place with:Static' 'Static2'
|
||||
. Edit - '' (L1093, T183, R1264, B203)
|
||||
. 'Edit2' 'Re&place with:Edit'
|
||||
. Button - 'Match &case' (L1020, T245, R1109, B265)
|
||||
. 'CheckBox2' 'Match &case' 'Match &caseCheckBox'
|
||||
. Button - '&Find Next' (L1273, T151, R1348, B174)
|
||||
. '&Find Next' '&Find NextButton' 'Button' 'Button0' 'Button1'
|
||||
. Button - '&Replace' (L1273, T178, R1348, B201)
|
||||
. '&Replace' '&ReplaceButton' 'Button2'
|
||||
. Button - 'Replace &All' (L1273, T206, R1348, B229)
|
||||
. 'Button3' 'Replace &All' 'Replace &AllButton'
|
||||
. Button - 'Cancel' (L1273, T233, R1348, B256)
|
||||
. 'Button4' 'Cancel' 'CancelButton'
|
||||
(7) >>> app.Replace.Cancel.Click()
|
||||
(8) >>> app.Notepad.Edit.TypeKeys("Hi from Python interactive prompt %s" % str(dir()))
|
||||
. <pywinauto.controls.win32_controls.EditWrapper object at 0x00DDC2D0>
|
||||
(9) >>> app.Notepad.MenuSelect("File -> Exit")
|
||||
(10) >>> app.Notepad.No.Click()
|
||||
>>>
|
@ -12,8 +12,10 @@ dialogs and controls.
|
||||
|
||||
Installation
|
||||
------------
|
||||
- Unzip the pywinauto zip file to a folder.
|
||||
- Install the following Python packages
|
||||
- Download pywinauto from https://sourceforge.net/project/showfiles.php?group_id=157379
|
||||
- Unzip the pywinauto zip file to a folder.
|
||||
- Run ``python.exe setup.py install``
|
||||
- Install the following Python packages
|
||||
|
||||
- ctypes http://starship.python.net/crew/theller/ctypes/
|
||||
- Sendkeys http://www.rutherfurd.net/python/sendkeys/index.html
|
||||
@ -27,7 +29,6 @@ Run Python ::
|
||||
>>> app = application.Application.start("notepad.exe")
|
||||
>>> app.notepad.TypeKeys("%FX")
|
||||
|
||||
|
||||
Where to start
|
||||
--------------
|
||||
Look at the examples provided in test_application.py
|
||||
@ -69,28 +70,27 @@ This avoid the user having to use time.sleep or a "WaitForDialog" function.
|
||||
|
||||
Some similar tools for comparison
|
||||
---------------------------------
|
||||
* Python tools
|
||||
* Python tools
|
||||
|
||||
- Watsup
|
||||
- winGuiAuto
|
||||
- Watsup (http://www.tizmoi.net/watsup/intro.html)
|
||||
- winGuiAuto (http://www.brunningonline.net/simon/blog/archives/winGuiAuto.py.html)
|
||||
|
||||
* Other scripting language tools
|
||||
* Other scripting language tools
|
||||
|
||||
- Perl Win32::GuiTest
|
||||
- Ruby GuiTest
|
||||
- others?
|
||||
- Perl Win32::GuiTest (http://erngui.com/prog/perl/guitest/)
|
||||
- Ruby GuiTest (http://raa.ruby-lang.org/list.rhtml?name=win32-guitest)
|
||||
- others (http://opensourcetesting.org/)
|
||||
|
||||
* Other free tools
|
||||
* Other free tools
|
||||
|
||||
- AutoIt
|
||||
- See collection at:
|
||||
- AutoIt (http://www.autoitscript.com/)
|
||||
- See collection at: http://tejasconsulting.com/open-testware/feature/gui-test-driver-survey.html
|
||||
|
||||
* Commercial tools
|
||||
* Commercial tools
|
||||
|
||||
- WinRunner
|
||||
- SilkTest
|
||||
- Visual Test
|
||||
- Many Others
|
||||
- WinRunner (http://www.mercury.com/us/products/quality-center/functional-testing/winrunner/)
|
||||
- SilkTest (http://www.segue.com/products/functional-regressional-testing/silktest.asp)
|
||||
- Many Others (http://www.testingfaqs.org/t-gui.html)
|
||||
|
||||
|
||||
Why write yet another automation tool if there are so many out there?
|
||||
|
@ -1,6 +1,6 @@
|
||||
@echo off
|
||||
|
||||
c:\.temp\pudge\pudge\cli --documents doc_source\index.rst,doc_source\controls_overview.rst,doc_source\howto.rst,history.txt,license.txt,todo.txt --title pywinauto -v -d pywinauto\website -m pywinauto.application,pywinauto.taskbar,pywinauto.clipboard,pywinauto.timings,pywinauto.findbestmatch,pywinauto.findwindows,pywinauto.handleprops,pywinauto.XMLHelpers,pywinauto.controls,pywinauto.tests -t doc_source\template
|
||||
c:\.temp\pudge\pudge\cli --documents doc_source\index.rst,doc_source\controls_overview.rst,doc_source\howto.rst,doc_source\getting_started.rst,history.txt,license.txt,todo.txt --title pywinauto -v -d website -m pywinauto.application,pywinauto.taskbar,pywinauto.clipboard,pywinauto.timings,pywinauto.findbestmatch,pywinauto.findwindows,pywinauto.handleprops,pywinauto.XMLHelpers,pywinauto.controls,pywinauto.tests -t doc_source\template
|
||||
|
||||
|
||||
|
||||
|
@ -586,7 +586,9 @@ class WindowSpecification(object):
|
||||
for ctrl in ctrls_to_print:
|
||||
|
||||
print "%s - '%s' %s"% (
|
||||
ctrl.Class(), ctrl.WindowText(), str(ctrl.Rectangle()))
|
||||
ctrl.Class(),
|
||||
ctrl.WindowText().encode("unicode-escape"),
|
||||
str(ctrl.Rectangle()))
|
||||
|
||||
print "\t",
|
||||
names = control_name_map[ctrl]
|
||||
|
Loading…
Reference in New Issue
Block a user