Save Downloaded File

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
 
(8 intermediate revisions by one user not shown)
Line 1: Line 1:
 
This command is part of the [[Browser Commands|Browser Command]]. Save Downloaded File downloads files that have been downloaded to the browser. The command allows you to designate where you would like to save the file to what you would like to call the file.
 
This command is part of the [[Browser Commands|Browser Command]]. Save Downloaded File downloads files that have been downloaded to the browser. The command allows you to designate where you would like to save the file to what you would like to call the file.
  
'''File To Save To:''' The file path where the downloaded file will be save to. The file path must include a file name and extension (such as C:\Users\Desktop\Miscellaneous\myfile.wav)
+
'''File To Save To:''' The file path where the downloaded file will be save to. The file path must include a file name and an extension such as C:\Users\Desktop\Miscellaneous\myfile.wav)
  
 +
In this case, we use the [[Special Folder]] function set to the Desktop with a file name and extension. This means that no matter what computer the script is run on, the file will be save to the Desktop.
 +
 +
The script is inside an [[Establish]] command for testing purposes. For more information about the [[Establish]] command, please see [[Log Commands|here]]
  
  
 
== Example ==
 
== Example ==
 
<pre>
 
<pre>
navigate("http://www.thinkbroadband.com/download.html", "Wait")
+
establish("Save Downloaded File Check",$comparison(#check,"= Equals","True"),"No") {
wait(5)
+
    navigate("https://www.briandunning.com/sample-data/us-500.zip","Wait")
click(<href="http://ipv4.download.thinkbroadband.com/5MB.zip">, "Left Click", "No")
+
    wait(2)
save downloaded file("{$special folder("Desktop")}/5MB.zip")
+
    set(#random,$rand(1,600),"Global")
 +
    save downloaded file("{$special folder("Desktop")}/{#random}.zip")
 +
    set(#check,$file exists("{$special folder("Desktop")}/{#random}.zip"),"Global")
 +
}
 +
 
 
</pre>
 
</pre>
  
Running the script will click the link labeled "80" next to "IPv4 Port:", which downloads the file to the browser. The save downloaded file command then saves the file to the chosen location.
 
  
[[File:savedownloadedfile.png]]
+
Running the script will click the download button, which downloads the file to the browser. The save downloaded file command then saves the file to the chosen location.
 +
 
 +
 
 +
[[File:sdfest.jpg]]
 +
 
 +
 
 +
== Important Tips ==
 +
 
 +
If you encounter a dialog box after you click the download button, simply add a wait command after the Save Downloaded File command
 +
 
 +
<pre>
 +
navigate("https://code.google.com/p/epub-samples/downloads/detail?name=kusamakura-japanese-vertical-writing-20121124.epub&can=2&q=", "Wait")
 +
wait(3)
 +
click(<alt="Download">, "Left Click", "No")
 +
save downloaded file("{$special folder("Desktop")}/writing.zip")
 +
wait(3)
 +
</pre>
 +
 
 +
 
 +
Also add a navigate command after the wait command that goes to the same url to refresh the browser:
 +
 
 +
 
 +
<pre>
 +
navigate("https://code.google.com/p/epub-samples/downloads/detail?name=kusamakura-japanese-vertical-writing-20121124.epub&can=2&q=", "Wait")
 +
wait(3)
 +
click(<alt="Download">, "Left Click", "No")
 +
save downloaded file("{$special folder("Desktop")}/writing.zip")
 +
wait(3)
 +
navigate("https://code.google.com/p/epub-samples/downloads/detail?name=kusamakura-japanese-vertical-writing-20121124.epub&can=2&q=", "Wait")
 +
</pre>

Latest revision as of 14:13, 31 August 2015

This command is part of the Browser Command. Save Downloaded File downloads files that have been downloaded to the browser. The command allows you to designate where you would like to save the file to what you would like to call the file.

File To Save To: The file path where the downloaded file will be save to. The file path must include a file name and an extension such as C:\Users\Desktop\Miscellaneous\myfile.wav)

In this case, we use the Special Folder function set to the Desktop with a file name and extension. This means that no matter what computer the script is run on, the file will be save to the Desktop.

The script is inside an Establish command for testing purposes. For more information about the Establish command, please see here


[edit] Example

establish("Save Downloaded File Check",$comparison(#check,"= Equals","True"),"No") {
    navigate("https://www.briandunning.com/sample-data/us-500.zip","Wait")
    wait(2)
    set(#random,$rand(1,600),"Global")
    save downloaded file("{$special folder("Desktop")}/{#random}.zip")
    set(#check,$file exists("{$special folder("Desktop")}/{#random}.zip"),"Global")
}


Running the script will click the download button, which downloads the file to the browser. The save downloaded file command then saves the file to the chosen location.


Sdfest.jpg


[edit] Important Tips

If you encounter a dialog box after you click the download button, simply add a wait command after the Save Downloaded File command

navigate("https://code.google.com/p/epub-samples/downloads/detail?name=kusamakura-japanese-vertical-writing-20121124.epub&can=2&q=", "Wait")
wait(3)
click(<alt="Download">, "Left Click", "No")
save downloaded file("{$special folder("Desktop")}/writing.zip")
wait(3)


Also add a navigate command after the wait command that goes to the same url to refresh the browser:


navigate("https://code.google.com/p/epub-samples/downloads/detail?name=kusamakura-japanese-vertical-writing-20121124.epub&can=2&q=", "Wait")
wait(3)
click(<alt="Download">, "Left Click", "No")
save downloaded file("{$special folder("Desktop")}/writing.zip")
wait(3)
navigate("https://code.google.com/p/epub-samples/downloads/detail?name=kusamakura-japanese-vertical-writing-20121124.epub&can=2&q=", "Wait")
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox