How to handle IE Download dialog with VB Script?

How to automatically save a file in a specific location using VB Script?

or How can I upload a file to a specific location in IE without interacting with the download dialog?

Ultimately, I need to automatically save the file to a specific location from IE.

Thanks.

0
source share
2 answers

What we do for file dialogs with our selenium tests is to use AutoIt , a free scripting tool that creates executable files that interact with the object model of Windows components - including file save dialogs.

, script, , , VBScript .

script, excel, , .

WinWait("File Download", "", 60)
WinActivate("File Download")
IF WinActive("File Download") Then
    Sleep (500)
    SendKeepActive ("File Download")
    Send("!s")
    WinWait("Save As")
    WinActivate("Save As")
    Sleep (500)
    SendKeepActive ("Save As")
    If $CMDLine[0] > 0 Then
        Send($CMDLine[1])
    ELSE
        Send("C:\Windows\Temp\latestAutotestExport.xls")
    ENDIF
    Send("!s")
    Sleep (500)
    If WinActive("Save As") Then
        WinActivate("Save As")
        Sleep (500)
        SendKeepActive ("Save As")
        Send("!y")
        Sleep (15000)
    EndIf
    If WinActive("Download complete") Then
        WinClose("Download complete")
    EndIf
    WinClose("Blank Page - Windows Internet Explorer")
Else
    WinActivate("Microsoft Office Excel")
    IF WinActive("Microsoft Office Excel") Then
        Send("y")
    EndIf
    Sleep(500)
    Send("{F12}")
    If $CMDLine[0] > 0 Then
        Send($CMDLine[1])
    ELSE
        Send("C:\Windows\Temp\latestAutotestExport.xls")
    ENDIF
    Send("!s")
    Send("y")
    Send("!y")
    Send("!y")
    Sleep(5000)
    ProcessClose("EXCEL.EXE")
    Sleep(5000)
    WinClose("Blank Page - Windows Internet Explorer provided by Yahoo!")
EndIF
+2

Internet Explorer . . . ? , .

-1

Source: https://habr.com/ru/post/1703410/


All Articles