QTP 通过URL地址下载文件到本地
来源:互联网 发布:win10 手写笔软件 编辑:程序博客网 时间:2024/05/22 14:28
While automation, you may come to situations where you need to need to download a file on clicking a link. This generally involves a lot of User Interface (GUI)overhead like syncing the download box, clicking the buttons, managing the Save As box, etc. This many a time causes sync issues. Moreover, we end up automating something that is not at all needed to be automated or tested. In this situation, all you need is a code snippet in Visual Basic for Quick Test Professional that automatically downloads the file in the background without the need of any GUI appearances. You just need to provide the download link and the file path in your system. The function "funcDownloadFile" below takes the file path and the download link as parameters in String and performs the download in the background. You just need to capture the download URL from the potential download link and call this function and you will find the download completed at the specified path.
The function supports authenticated downloads and proxy settings. The function is based onADODB STREAM object and WinHTTP API from Microsoft.
Sub utilDownloadFile(strFilePath, strURL) Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1") 'WinHttpReq.SetProxy HTTPREQUEST_PROXYSETTING_PROXY, "xxx.xxx.xxx.xxx:zzzz" 'Required only if your internet routes through a proxy. Not required in 90% cases. 'You can ignore this line for first attempt but add it if your download is hindered, X is IP and Z is Port temp = WinHttpReq.Open("POST", strURL, false) 'WinHttpReq.SetCredentials "Username", "Password", HTTPREQUEST_SETCREDENTIALS_FOR_SERVER 'Required only if the file download server required authentication. Not required in 90% cases. Change Username and Password wuth actuals. WinHttpReq.Send() WinHttpReq.WaitForResponse strResult = WinHttpReq.ResponseBody Set oStream = createobject("Adodb.Stream") Const adTypeBinary = 1 Const adSaveCreateOverWrite = 2 oStream.type = adTypeBinary oStream.open oStream.write strResult oStream.savetofile strFilePath, adSaveCreateOverWriteEnd Sub
- QTP 通过URL地址下载文件到本地
- 根据url地址下载文件到本地,返回本地文件地址
- java 通过下载地址下载到本地
- 通过图片URL下载图片到本地
- 通过网络Url下载图片并下载到本地相册
- J2ME通过URL访问XML文件并下载XML到本地
- JAVA通过访问页面中的URL实现Http文件下载到本地
- java 通过url下载文件到浏览
- 服务器通过浏览器下载文件到本地
- java根据图片的url地址下载图片到本地
- java WEB项目通过url下载图片到本地
- Java 通过URL地址下载文本内容到本地文件中
- URL文件地址下载
- 通过url下载文件
- 通过url下载文件
- 通过URL下载文件
- 通过URL下载文件
- 下载文件到本地
- 连通图的割点、割边 连通图的割点、割边(桥)、块、缩点,有向图的强连通分量
- 看的比较新鲜的vim的使用说明 vi( ....这个用法不错。转来了
- 编制一个三角函数表(0°~90°)
- 【博弈】poj 2960 S-Nim
- Andoird Overview
- QTP 通过URL地址下载文件到本地
- javasrcpt写一个简单的计算器
- android调用系统(相机)的图片,并且返回
- android AlarmService
- Unix编年体通史
- Apache Karaf
- HEVC Intra流程
- 记录用户在网站上的逗留时间
- Linux操作系统下MySQL数据库的使用方法