Download a file in IE using Selenium

后端 未结 6 1447
忘掉有多难
忘掉有多难 2020-12-06 08:35

OK, so I am trying to export a file using Selenium. My browser is IE. When I click on the export button a native windows dialogue box comes up.

Image of the pop up

6条回答
  •  余生分开走
    2020-12-06 08:55

    I used AutoIt and it works in windows 10. Refer to the below AutoIt script :

    Sleep(9000);
    Local $hIE = WinGetHandle("[Class:IEFrame]");
    Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]");
    If WinExists($hIE,"") Then
            WinActivate($hIE,"");
            ControlSend($hIE ,"",$hCtrl,"{F6}");
            Sleep(1500);
            ControlSend($hIE ,"",$hCtrl,"{TAB}");
            Sleep(1500);
            ControlSend($hIE ,"",$hCtrl,"{ENTER}");
        EndIf
    Sleep(5000);
    If WinExists($hIE,"") Then
            WinActivate($hIE,"");
            ControlSend($hIE ,"",$hCtrl,"{F6}");
            Sleep(1500);
            ControlSend($hIE ,"",$hCtrl,"{TAB}");
            Sleep(1500);
            ControlSend($hIE ,"",$hCtrl,"{TAB}");
            Sleep(1500);
            ControlSend($hIE ,"",$hCtrl,"{TAB}");
            Sleep(1500);
            ControlSend($hIE ,"",$hCtrl,"{ENTER}");
    EndIf
    Sleep(5000);
    

    It clicks the save button and also closes the next alert.

    Please adjust Sleep() accordingly.

提交回复
热议问题