Skip to main content
Formatting
Source Link
Bharat Mane
  • 6.8k
  • 11
  • 41
  • 69

The trick to handle any dialogs is to use external tools like AutoIT to deal with the Upload dialog, download Dialog, and NTLM Authentication dialogs. Please note that this solution is intended only for users ecexutingexecuting the scripts in Windows environment.

Using AutoIT you can write a simple script to get hold of the Save Dialog, this script can be then converted into aan executable program with command line arguments to invoke it any timeanytime from the program.

  1. downloadDownload autoIT tool.
  2. Save the below mentioned-mentioned script to a save_dialog.au3save_dialog.au3 file in the system.
  3. Open "Compile Script to .exe""Compile Script to .exe" program from AutoIT setup Directory.
  4. mention the path to save_dialog.au3save_dialog.au3 and mention the path and name where you want to save .exe file. (lets say c:\save_ie_file.exec:\save_ie_file.exe)
  5. if you are using Java to write your automation code, use below lines of your code just before you click "downlaod"download link" or expect a download dialog.

The trick to handle any dialogs is to use external tools like AutoIT to deal with the Upload dialog, download Dialog and NTLM Authentication dialogs. Please note that this solution is intended only for users ecexuting the scripts in Windows environment.

Using AutoIT you can write a simple script to get hold of the Save Dialog, this script can be then converted into a executable program with command line arguments to invoke it any time from program.

  1. download autoIT tool.
  2. Save the below mentioned script to a save_dialog.au3 file in system.
  3. Open "Compile Script to .exe" program from AutoIT setup Directory.
  4. mention the path to save_dialog.au3 and mention the path and name where you want to save .exe file. (lets say c:\save_ie_file.exe)
  5. if you are using Java to write your automation code, use below lines of your code just before you click "downlaod link" or expect a download dialog.

The trick to handle any dialogs is to use external tools like AutoIT to deal with the Upload dialog, download Dialog, and NTLM Authentication dialogs. Please note that this solution is intended only for users executing the scripts in Windows environment.

Using AutoIT you can write a simple script to get hold of the Save Dialog, this script can be then converted into an executable program with command line arguments to invoke it anytime from the program.

  1. Download autoIT tool.
  2. Save the below-mentioned script to a save_dialog.au3 file in the system.
  3. Open "Compile Script to .exe" program from AutoIT setup Directory.
  4. mention the path to save_dialog.au3 and mention the path and name where you want to save .exe file. (lets say c:\save_ie_file.exe)
  5. if you are using Java to write your automation code, use below lines of your code just before you click "download link" or expect a download dialog.
Add a disclaimer stating that the blog I am pointing to is not mine,
Source Link

save_dialog.au3 code blatantly Copied from here DISCLAIMER... I am not the author of that blog pointed in this answer:

save_dialog.au3 code blatantly Copied from here:

save_dialog.au3 code blatantly Copied from here DISCLAIMER... I am not the author of that blog pointed in this answer:

Source Link

The trick to handle any dialogs is to use external tools like AutoIT to deal with the Upload dialog, download Dialog and NTLM Authentication dialogs. Please note that this solution is intended only for users ecexuting the scripts in Windows environment.

Using AutoIT you can write a simple script to get hold of the Save Dialog, this script can be then converted into a executable program with command line arguments to invoke it any time from program.

Following below steps should solve your issue.

  1. download autoIT tool.
  2. Save the below mentioned script to a save_dialog.au3 file in system.
  3. Open "Compile Script to .exe" program from AutoIT setup Directory.
  4. mention the path to save_dialog.au3 and mention the path and name where you want to save .exe file. (lets say c:\save_ie_file.exe)
  5. if you are using Java to write your automation code, use below lines of your code just before you click "downlaod link" or expect a download dialog.

  String[] dialog =  new String[]{ "C:\\save_ie_file.exe","Save to...","Save", "C:\\selenium_downloads\\" }; // path to exe, dialog title, save/cancel/run, path to save file.
  Process pp1 = Runtime.getRuntime().exec(dialog); // run the executable to wait for download link and process
  selenium.click("id=download_link"); // code to click on download link
  pp1.destroy(); // kill the process looking to download

save_dialog.au3 code blatantly Copied from here:

 
    AutoItSetOption("WinTitleMatchMode","2") ; set the select mode to select using substring

    if $CmdLine[0] < 2 then
    ; Arguments are not enough
    msgbox(0,"Error","Supply all the arguments, Dialog title,Run/Save/Cancel and Path to save(optional)")
    Exit
    EndIf

    ; wait Until dialog box appears
    WinWait($CmdLine[1]) ; match the window with substring
    $title = WinGetTitle($CmdLine[1]) ; retrives whole window title
    WinActivate($title)

    If (StringCompare($CmdLine[2],"Run",0) = 0) Then
    WinActivate($title)
    ControlClick($title,"","Button1")
    EndIf

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

    WinWaitActive($title)
    ControlClick($title,"","Button2")
    ; Wait for the new dialogbox to open
    Sleep(2)
    WinWait("Save")
    $title = WinGetTitle("Save")
    ;$title = WinGetTitle("[active]")
    if($CmdLine[0] = 2) Then
    ;click on the save button
    WinWaitActive($title)
    ControlClick($title,"","Button2")
    Else
    ;Set path and save file
    WinWaitActive($title)
    ControlSetText($title,"","Edit1",$CmdLine[3])
    ControlClick($title,"","Button2")
    EndIf

    EndIf

    If (StringCompare($CmdLine[2],"Cancel",0) = 0) Then
    WinWaitActive($title)
    ControlClick($title,"","Button3")
    EndIf