Controlling Dialogs such as File Download and SaveAs -working for use with SeleniumRC/Python

1,215 views
Skip to first unread message

Calfdog

unread,
Dec 21, 2009, 4:54:58 PM12/21/09
to Selenium Users
I noticed that dialog control was non existent for IE.
So I took it it on to see if I can get it working.

After a 3 day poking around I have been able to control dialogs such
as File Download and SaveAs by using the pyWinAuto, winGuiAuto,
SendKeys, Win32Gui and Win32con.

I am putting together a class file that will make this much easier to
do. I will post this once it is done or you can email me for the file.

The History for those who want to try it now:

The biggest challege was why it was clicking on the controls but
nothing was happening.
I could highlight the control and do a ClickInput on the File Download
dialog but it appears
something was missing since the Save As dialog never launched

It was a bit tricky to figure out but it is really pretty easy to do
once you have the right combination. The first part you need all the
steps but the second you may be able to cut the steps done using
pyWinAuto.

Here is a brief synopsis.

########### To click on the Save Button of the File Download Dialog

# Use PyWinAuto to perform a ClickInput()
app.FileDownload.Button2.ClickInput()

# Get a Handle to the File Download dialog using winGuiAuto.py
hwnd = winGuiAuto.findTopWindow(wantedText="File Download")

# Do a Mouse up and Mouse down (The sleep time is important)
win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, 0)
time.sleep(2)
win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, 0)

SendKeys.SendKeys("""{ENTER}""")

########### To click on the Save Button of the Save As Dialog

# Use PyWinAuto to perform a ClickInput()
app.SaveAs.Save.ClickInput()

# Get a Handle to the Save As dialog using winGuiAuto.py
hwnd = winGuiAuto.findTopWindow(wantedText="Save As")

# Do a Mouse up and Mouse down (The sleep time is important)
win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, 0)
time.sleep(2)
win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, 0)

SendKeys.SendKeys("""{ENTER}""")

Santiago Suarez Ordoñez

unread,
Dec 22, 2009, 11:34:51 PM12/22/09
to selenium-users
Nice info Calfdog. Thanks fro sharing. Let's hope Selenium 2.0 covers
this lack of functionality soon.

Santi

2009/12/21 Calfdog <bob...@hotmail.com>:

> --
>
> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.
>
>
>

Emmanuel

unread,
Dec 27, 2009, 5:12:24 AM12/27/09
to seleniu...@googlegroups.com
Has anybody been able to do something similar on linux?

ivans083

unread,
Feb 18, 2010, 2:15:30 PM2/18/10
to Selenium Users
Calfdog,

How did you call pywinauto from Selenium? My guess is that you were
running selenium RC and had some .py scripts you called via a system
call? is this correct?

Thanks,

Ivan.-

On 21 dic 2009, 22:54, Calfdog <bobm...@hotmail.com> wrote:
> I noticed that dialog control was non existent for IE.
> So I took it it on to see if I can get it working.
>
> After a 3 day poking around  I have been able to control dialogs such

> as File Download and SaveAs by using thepyWinAuto, winGuiAuto,


> SendKeys, Win32Gui and Win32con.
>
> I am putting together a class file that will make this much easier to
> do. I will post this once it is done or you can email me for the file.
>
> The History for those who want to try it now:
>
> The biggest challege was why it was clicking on the controls but
> nothing was happening.
> I could highlight the control and do a ClickInput on the File Download
> dialog but it appears
> something was missing since the Save As dialog never launched
>
> It was a bit tricky to figure out but it is really pretty easy to do
> once you have the right combination.  The first part you need all the
> steps but the second you may be able to cut the steps done usingpyWinAuto.
>
> Here is a brief synopsis.
>
> ########### To click on the Save Button of the File Download Dialog
>

> # UsePyWinAutoto perform a ClickInput()


> app.FileDownload.Button2.ClickInput()
>
> # Get a Handle to the File Download dialog using winGuiAuto.py
> hwnd = winGuiAuto.findTopWindow(wantedText="File Download")
>
> # Do a Mouse up and Mouse down (The sleep time is important)
> win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, 0)
> time.sleep(2)
> win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, 0)
>
> SendKeys.SendKeys("""{ENTER}""")
>
> ###########  To click on the Save Button of the Save As Dialog
>

> # UsePyWinAutoto perform a ClickInput()

Reply all
Reply to author
Forward
0 new messages