Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 从web下载文件并将其放入TestComplete的存储中_Unit Testing_Testing_Testcomplete - Fatal编程技术网

Unit testing 从web下载文件并将其放入TestComplete的存储中

Unit testing 从web下载文件并将其放入TestComplete的存储中,unit-testing,testing,testcomplete,Unit Testing,Testing,Testcomplete,我使用的是TestComplete7。我正在编写一个测试,从web下载文件,并将下载的文件放入存储区。我正在使用C++脚本来实现这一点。但我有问题。我不知道如何用它的URL在C++脚本中下载文件。谁能给我一些建议吗 function Test(){ // Specify the names of the source and destination files var strFileURL = "http://www.automatedqa.com/file to get"; var

我使用的是TestComplete7。我正在编写一个测试,从web下载文件,并将下载的文件放入存储区。我正在使用C++脚本来实现这一点。但我有问题。我不知道如何用它的URL在C++脚本中下载文件。谁能给我一些建议吗

function Test(){
// Specify the names of the source and destination files 
  var strFileURL = "http://www.automatedqa.com/file to get"; 
  var strHDLocation = "c:\\temp\\filename"; 
  // Download the file 
  var objHTTP = new ActiveXObject("MSXML2.XMLHTTP"); 
  objHTTP.open("GET", strFileURL, false); 
  objHTTP.send(); 
  while((objHTTP.readyState != 4) && (objHTTP.readyState != 'complete')) {  
    Delay(100); 
  } 
  if (200 != objHTTP.Status) { 
    Log.Error("The " + strFileURL + " file was not found." + " The returned status is " + objHTTP.Status);
    return; 
  } 
  var objADOStream = new ActiveXObject("ADODB.Stream"); 
  objADOStream.Open(); 
  objADOStream.Type = 1; //adTypeBinary 
  objADOStream.Write(objHTTP.ResponseBody); 
  objADOStream.Position = 0;    //Set the stream position to the start 
  var objFSO = new ActiveXObject("Scripting.FileSystemObject"); 
  if (objFSO.FileExists(strHDLocation)) objFSO.DeleteFile(strHDLocation) 
  objADOStream.SaveToFile(strHDLocation); 
  objADOStream.Close(); 
  Files.Add(strHDLocation); 
}