Hi,
I had a look at Watsup and winGuiAuto a while ago and was interested in using it.
I found the non object oriented way of working difficult.
Around the same time I was working on a testing application (not automation) where I was querying many attributes of windows.
I wrote an automation wrapper and built up the code I was using for testing.
I can make this available (as of now I have absolutely no web presence so I could email it - or post it to someone else's server). The zip if around 200kb.
Requirements:
ctypes http://starship.python.net/crew/theller/ctypes/
Sendkeys
http://www.rutherfurd.net/python/sendkeys/index.html
(Optional) PIL http://www.pythonware.com/products/pil/index.htm
(Optional) elementtree
http://effbot.org/downloads/
Some of the main things that I wanted to avoid were:
- explicit waits (or waiting when necessary)
- having to read the dialog first (some automation testing langauges)
- localization unfriendlyness (as I work in localization mainly) (Not Implemented fully yet)
I am still looking for a name - I am using pywinauto as a temporary one for now.
This is the first time I would have ever released anything so please be gentle.
Here is an example of driving notepad - on my laptop it takes about 1.6 seconds.
---------- :< -----------------------
import application
app = application.Application()
app._start(ur"c:\windows\system32\notepad.exe")
app.Notepad.MenuSelect("File->PageSetup")
# ----- Page Setup Dialog ----
# Select the 4th combobox item
app.PageSetupDlg.ComboBox1.Select(4)
# Select the 'Letter' combobox item
app.PageSetupDlg.ComboBox1.Select("Letter")
# ----- Next Page Setup Dialog ----
app.PageSetupDlg.Printer.Click()
app.PageSetupDlg.Network.Click()
# ----- Connect To Printer Dialog ----
# Select a checkbox
app.ConnectToPrinter.ExpandByDef.Check()
# Uncheck it again - but use Click this time!
app.ConnectToPrinter.ExpandByDef.Click
()
app.ConnectToPrinter.OK.Click()
# ----- 2nd Page Setup Dialog again ----
app.PageSetupDlg2.Properties.Click()
# ----- Document Properties Dialog ----
docProps = app._window(title_re = ".*Document Properties")
# Two ways of selecting tabs
docProps.TabCtrl.Select(2)
docProps.TabCtrl.Select("Layout")
# click some Radio buttons
docProps.RotatedLandscape.Click()
docProps.BackToFront.Click()
docProps.FlipOnShortEdge.Click()
docProps.Portrait.Click()
docProps._None.Click() # need to disambiguate from keyword None
docProps.FrontToBack.Click()
# open the Advanced options dialog in two steps
advbutton = docProps.Advanced
advbutton.Click()
# ----- Advanced Options Dialog ----
# close the 4 windows
app._window(title_re = ".* Advanced Options").Ok.Click()
# ----- Document Properties Dialog again ----
docProps.Cancel.Click()
# ----- 2nd Page Setup Dialog again ----
app.PageSetupDlg2.OK.Click()
# ----- Page Setup Dialog ----
app.PageSetupDlg.Ok.Click
()
# type some text
app.Notepad.Edit.SetText(u"I am typing säme text to Notepad\r\n\r\nAnd then I am going to quit")
# the following shows that Sendtext does not accept accented characters - but does allow 'control' characters
#app.Notepad.Edit.TypeKeys(u"{END}{ENTER}SendText döés not süppôrt àcceñted characters", with_spaces = True)
# exit notepad
app.Notepad.MenuSelect("File->Exit")
app.Notepad.No.Click
()
---------- :< -----------------------
Future areas for development:
- Allow saving a dialog and using it as a reference on localised software (so you would run first on English and then you would be able to use the same script on translated software as English)
- Allow non text controls (comboboxes, listboxes to be referenced by closest Static above and to the left of the control)
Thanks
Mark