Jump to content
Sign in to follow this  
KumarDinesh

Firefox - File Popup handling using AutoIT

Recommended Posts

KumarDinesh

Hello,

I need to handle the firefox file popup using AUTO IT. I need your valuable advice to solve this issue. Below is the script code

; set the select mode to select using substring

AutoItSetOption("WinTitleMatchMode","2")

ControlCommand ( "Opening", "Save", "&Save", "Check" )

; wait until dialog box appears

WinWait($CmdLine[1]) ; match the window with substring

$title = WinGetTitle($CmdLine[1]) ; retrives whole window title

WinActive($title);

; if user choose to save file

If (StringCompare($CmdLine[2],"Save",0) = 0) Then

WinActivate($title)

WinWaitActive($title)

Sleep(10)

; If firefox is set to save the file on some specif location without asking to user.

; It will be save after this point.

Send("{DOWN}")

Send("{ENTER}")

;If Dialog appear prompting for Path to save

WinWait("Enter name")

$title = WinGetTitle("Enter name")

If WinExists($title) Then

;Set path and save file

WinActivate($title)

WinWaitActive($title)

ControlSetText($title, "", "Edit1", $CmdLine[3])

ControlClick($title, "", "Button2")

EndIf

WinWait("Downloads")

If WinExists("Downloads") Then

$title = WinGetTitle("Downloads")

WinActivate($title)

WinWaitActive($title)

Send("{ESCAPE}")

EndIf

Else

;Firefox is configured to save file at specific location

Exit

EndIf

; do not save the file

If (StringCompare("Cancel","Cancel",0) = 0) Then

WinWaitActive($title)

Send("{ESCAPE}")

EndIf

This script finds the window by checking the title "Opening" and then it presses the "DOWN" and "ENTER" key so that it will select the Save option. The problem is, sometimes "Save" radio button is selected by default... when i run the script, it is going to the "Open" radio button.

Is there someway to find the selected radio button before pressing the "Down" key?

Note: i have attached the screen shot also in this thread.

Thanks in advance

- Dineshkumar

Issue i am facing is,

post-70716-0-17825500-1330679209_thumb.j

Share this post


Link to post
Share on other sites
dara

instead of sending down key followed by enter, send alt+s key followed by enter

Share this post


Link to post
Share on other sites
SUTHARI

Hi there,

I am totally new for AutoIT, Even I have installed it in my computer and trying to download pdf from firefox using selenium vba script.

I have seen one exe code like below i tried it, saveas this text in notepad as exe file and used this path in selenium vba like Runtime.getRuntime().exec("C:Program FilesAutoIt3Examplesdownloadbill.exe") but stil am getting error object required, could you please let me know the perfect code to use to download pdf from firefox using selenium vba.

; set the select mode to select using substring
AutoItSetOption("WinTitleMatchMode","2")
ControlCommand ( "Opening", "Save", "&Save", "Check" )
; wait until dialog box appears
WinWait($CmdLine[1]) ; match the window with substring
$title = WinGetTitle($CmdLine[1]) ; retrives whole window title
WinActive($title);

; if user choose to save file
If (StringCompare($CmdLine[2],"Save",0) = 0) Then

WinActivate($title)
WinWaitActive($title)
Sleep(10)

; If firefox is set to save the file on some specif location without asking to user.
; It will be save after this point.

Send("{DOWN}")
Send("{alt + S}")

;If Dialog appear prompting for Path to save
WinWait("Enter name")
$title = WinGetTitle("Enter name")
If WinExists($title) Then
;Set path and save file
WinActivate($title)
WinWaitActive($title)
ControlSetText($title, "", "Edit1", $CmdLine[3])
ControlClick($title, "", "Button2")
EndIf

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×