Using AutoIt to automate the manual dialogs tests

91 views
Skip to first unread message

Robert Spielmann

unread,
Sep 25, 2010, 12:20:42 PM9/25/10
to robotframework-devel
Hi all,

I played around with AutoIt yesterday, because I wanted to automate
the required clicks for the dialogs tests. I've written a script that
works pretty well with those tests. I'll paste the script at the end
of the message, it seems like I cannot attach files here.

Anyway - there's a small problem with AutoIt that I haven't figured
out yet. It seems that AutoIt exits at some point or doesn't determine
that the required window is now present. If I start the AutoIt script
and then immediately launch the dialogs acceptance tests, everything
works just fine. But, if I start the AutoIt script and then the entire
acceptance test suite, the AutoIt script doesn't react to the Tk
dialog that pops up a couple of minutes later. Anyone have any
experience with such issues?

Also, I had some trouble actually clicking the buttons etc. with
AutoIt. Using the discovery tool on the dialogs causes the dialogs to
disappear, so I had to send simulated TAB- and SPACE-keystrokes. This
is why the script (see below) looks a little stupid :)

I'm thinking about a way of incorporating this AutoIt magic with the
acceptance test suite, because doing so would enable any developer to
run the full set of acceptance tests without the need to perform the
manual steps for the dialogs tests. If you have suggestions, feel free
- I'd be happy about a little discussion on this.

Cheers
Robert

Here comes the AutoIt script. Note that, funny enough, for the Pause
Execution keyword I *WAS* able to use the normal ControlClick
function.

$title = "Robot Framework"

PauseExecution()
ExecuteManualStep()
GetValueFromUserPasses()
GetValueFromUserFails()
GetSelectionFromUserPasses()
GetSelectionFromUserFails()

Func PauseExecution()
getWindow($title)
ControlClick($title, "OK", 2)
EndFunc

Func ExecuteManualStep()
getWindow($title)
Send("{TAB}{SPACE}")

getWindow($title)
Send("{TAB 2}{SPACE}")

getWindow($title)
Send("{TAB}{SPACE}")
EndFunc

Func GetValueFromUserPasses()
getWindow($title)
Send("value")
Send("{TAB}{SPACE}")
EndFunc

Func GetValueFromUserFails()
getWindow($title)
Send("{TAB 2}{SPACE}")
EndFunc

Func GetSelectionFromUserPasses()
getWindow("Select one option")
Send("{DOWN 3}{TAB}{SPACE}")
EndFunc

Func GetSelectionFromUserFails()
getWindow("Select one option")
Send("{TAB 2}{SPACE}")
EndFunc

Func getWindow($theTitle)
WinWait($theTitle)
WinActivate($theTitle)
EndFunc

Pekka Klärck

unread,
Sep 26, 2010, 6:17:02 AM9/26/10
to spielman...@googlemail.com, robotframework-devel
2010/9/25 Robert Spielmann <spielman...@googlemail.com>:

>
> I'm thinking about a way of incorporating this AutoIt magic with the
> acceptance test suite, because doing so would enable any developer to
> run the full set of acceptance tests without the need to perform the
> manual steps for the dialogs tests. If you have suggestions, feel free
> - I'd be happy about a little discussion on this.

First of all, have you noticed you can exclude these tests with
`--exclude manual`?

Automating the Dialogs library tests would obviously be even better
than excluding them, but doing that on all the supported platforms
would be quite a big task. Adding support for Windows + Python
combination would be a good start, so if you are interested in doing
that go ahead. This automation should not prevent running those tests
manually without extra dependencies, though.

Btw, did you investigate using AutoItLibrary for this?

Cheers,
.peke

Robert Spielmann

unread,
Sep 26, 2010, 6:57:32 AM9/26/10
to Pekka Klärck, robotframework-devel
Hi Pekka,

2010/9/26 Pekka Klärck <pe...@iki.fi> wrote:
First of all, have you noticed you can exclude these tests with
`--exclude manual`?

Yeah, that's what I used to do for an unattended full test run.
 
Automating the Dialogs library tests would obviously be even better
than excluding them, but doing that on all the supported platforms
would be quite a big task. Adding support for Windows + Python
combination would be a good start, so if you are interested in doing
that go ahead. This automation should not prevent running those tests
manually without extra dependencies, though.

I think there are two possible ways of doing this:

a) just provide the AutoIt script along with the tests and leave it up to the one running the tests to start the script. In CI, given it is done on a Windows machine with graphical output, the AutoIt script could be launched as a distinct build step before the tests are started. One could also wrap the test test run in a batch or python script. This way, you wouldn't have to touch the tests at all.

b) integrate with the test suite in a flexible way, which means: determine if AutoIt is available, and if it is, launch the script as soon as the dialogs test suite starts.

I'll play with it a little and see if I can find a good way to implement something.


Btw, did you investigate using AutoItLibrary for this?

That shall be my next step, because it might make the integration easier - having AutoItLibrary on the system doesn't require an extra AutoIt installation and it's then also fully integrated into the regular python module mechanisms.

Have a nice day :-)

Cheers
Robert

Reply all
Reply to author
Forward
0 new messages