autoit 实现文件下载 脚本

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.10.2
 Author:         xiaoseng
 Name:           downfile
 OS:             Win7
 Browser:        IE8.0
 script Function:
        Template AutoIt script.

#ce ----------------------------------------------------------------------------
Dim  $path ="c:test.rar" , $Title="文件下载"
  if FileExists($path) then
         FileDelete($path)
   EndIf
                        sleep(4000);
                        WinWait($Title);
            WinActivate($Title);
                        sleep(4000);
            ControlClick($Title, "","[CLASS:Button; INSTANCE:2]");
                        sleep(4000);
                        $Title="另存为"
                        WinWait($Title);
                        WinActivate($Title);
                        sleep(4000);
                        ControlSetText($Title, "", "[CLASS:Edit; INSTANCE:1]", $path);
                        sleep(4000);
                        ControlClick($Title, "","[CLASS:Button; INSTANCE:1]");
                        sleep(4000);
                        $Title="下载完毕"
                        WinWait($Title);
                        sleep(4000);
            WinActivate($Title);
                        sleep(4000);
            ControlClick($Title, "","[CLASS:Button; INSTANCE:4]");
                        sleep(4000);
首先我通selenium将执行该下载操作,会到弹出“文件下载”框,然后我们调用autoit的脚本
这时,我们将selenium脚本暂停一段时间,这段时间用于完成文件下载的时间,(这个时间不太好估算),也可以通过判断下载文件是否大小 是否正常判断文件是否下载成功,文件下载完成后在接着执行selenium脚本.


对于autoit脚本处理返回具体根据实际情况设计,判断下载是否完成。上面只供参考。
上面脚本在win7  ie8下可以运行,实际情况大家可以在调试。xp系统是不能运行的。需要单独在去处理。


相关标签:


评论: