Download file - Save As dialogue box in Control Tower

custom-action
samples
#1

How can I get the xpath of the Save As dialogue box, to enter the path of the download when downloading a file in Control Tower?
I’m looking for a way to download the files (zip files) in a specific path or be able to set the default path specially when running in Control Tower. The solution in kb doesn’t work in Control Tower.

Thanks,
Somayeh

#2

Hi @ssoleimani the dialogue box is not a part of the website, so it cannot be reached through XPath.
Is it actually a part of the Windows OS, so it can be automated using Enter Keystrokes and Mouse actions.

Note that if you have this option disabled in the Studio, you will need to switch to the window before using any actions in it.
image

#3

Thanks for your response. Any sample code/ pseudo code is appreciated.

Best,
Somayeh

#4

And one other issue is unfortunately when I tried the desired website automatically, it doesn’t show the dialogue box; after clicking the download button it downloaded automatically without popup the dialogue box Save As in Chrome or kind of footer notification in Internet Explorer, it just starts downloading the file in the default folder (c:/ user/ Download …).

#5

Hi @ssoleimani,

Have you tried checking the option in Chrome Advanced Settings as shown below image,

Enabling this option will invoke Save As dialogue box whenever you click any download link and then you can perform insert keystrokes by entering your desired path and save files to that location.

Even it works executing in Control Tower for me if this option is enabled.

Please let me know if it works :slight_smile:

1 Like
#6

@ssoleimani if you right-click on the link or document you need to save, does it open the context menu with an option Save As or Save Link As, etc?

#7

Hi aravindhan_mr, Thanks for your response. The Save As dialogue box appears when I normally click on the download button but the problem I asked help for is it doesn’t show-up when run automatically. This setting is already active.
Thanks,
Somayeh

#8

Hi ashapkina,
Thanks for your response. I tried it; when I right click on the download button there is an option to Save As but it doesn’t save the file.zip that I expected. it just want to save file.html and this doesn’t work for saving the file.
Best,
Somayeh

#9

Try using this solution

#10

Hi @ashapkina,

Actually I think you have given the same conception of what i have given in above reply.

Though you shared for Firefox Browser :slight_smile:

1 Like
#11

Yes, it is the same :slightly_smiling_face:
I just thought it was worth mentioning that one needs to add the actions to change the settings at the beginning of the script as it opens a new browser instance every time.

1 Like
#12

Hi @ssoleimani,

Could you please try with the Custom Action with “DownloadFileOnAgent” script?

If you could get Url path using Xpath in script or Mouse Right Click action and get the “Copy Link Address” and try it in script.

@CustomScriptAction()

def customScript() {
	downloadFileOnAgent('http://www.africau.edu/images/default/sample.pdf', 'C:/Users/rr327591/Pictures/new-file.pdf');
}

Screenshots.zip (97.8 KB)

This works for me even in Control Tower successfully.

Thanks for the response :slight_smile:

1 Like
#13

Thanks so much for your response, actually I tried this before but the problem is this download button uses dynamic url that created with a post API method, so I cannot get the URL :confused:
I checked the other options You and ashapkina suggested, although it is set in my chrome’s setting to “Ask where to save each file before downloading” but when it runs by selenium this option is not active. I’m trying to open a new window/ tab to make this active but I have some difficulties and it doesn’t work yet. I cannot get the xpath of the settings’ button, so I came with this solution that works in a not automated chrome; searching for ‘Ask where to save each file before downloading’ and then hit Tab 3 times then press enter, but this doesn’t work in selenium.
This is the code I’m using:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
	<robotics-flow>
		<robot name="webDriver" driver="chrome" close-on-completion="false" start-in-private="false">
			<script><![CDATA[ 
				import groovy.json.*;
				import java.util.concurrent.TimeUnit;
				import org.openqa.selenium.support.ui.Select;
				import org.apache.commons.lang.RandomStringUtils;
				import org.openqa.selenium.By;
				import org.openqa.selenium.support.ui.ExpectedConditions;	
				import selenium.webdriver.*;
				import org.openqa.selenium.WebDriver;
				import org.openqa.selenium.chrome.*;
				//import org.openqa.selenium.Keys;
																			
				def browserDriver =  webDriver.getWrappedObject();
				
				//browserDriver.manage().window().maximize();
				
				def waitobj  = new WebDriverWait(browserDriver, 1000);
				open("http://google.com");
				timeouts().implicitlyWait(10, TimeUnit.SECONDS);
				open("chrome://settings/");
				timeouts().implicitlyWait(10, TimeUnit.SECONDS);
				
				sendKeys('Ask where to save each file before downloading');
				
				pressTab();
				pressTab();
				pressTab();
				pressEnter();
			]]></script>
		
		</robot>
	</robotics-flow>
    <export include-original-data="true"></export>

</config>
#14

Hi @ssoleimani,

Here is the sample your same script with some delay is doing the trick and i tried its working.

script.txt (1.3 KB)

Please let me know if it works.

Thanks for your response :slight_smile:

1 Like
#15

Hi @aravindhan_mr,

Awesome! Thank YOU so much, yes your tricks worked well!

Now when I press the download button, the Save As dialogue box shows up. The only problem is I don’t know where to address to save the file in Control Tower that I could be able to retrieve it later. And why the dialogue box doesn’t do anything after I enter an address for saving the file; I tested in WorkFusion Studio like below, it just shows the dialogue box and remains there:
.
.
.// chrome settings to ask where download the file
.
.
waitobj.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=‘lnkDownload’]")));

browserDriver.findElement(By.xpath(’//*[@id=“lnkDownload”]’)).sendKeys(Keys.SPACE);
pressEnter(); // shows the ‘Save As’ dialogue box
sleep(4000);
def path = “C:/_temp/file.zip”;
sendKeys(path);
sleep(3000);
pressEnter();
timeouts().implicitlyWait(10, TimeUnit.SECONDS);

Thanks again for your help.
Best,
Somayeh

1 Like
#16

Hi @ssoleimani,

You are most Welcome :slight_smile: