Change download folder and file name on chromedriver
Moderators: Dorian (MJT support), JRL
Change download folder and file name on chromedriver
Good morning,
I have a routine where a file is downloaded and imported into another.
Can I determine where the file is going to be saved and what name it should be at the time of download?
I'm using chromedriver.
Today it saves in the default folder of chromedriver (Downloads) with a default name I move and rename to perform the import and this does not work well, always the problem.
Can I download it in the right place with the right name?
Thanks
I have a routine where a file is downloaded and imported into another.
Can I determine where the file is going to be saved and what name it should be at the time of download?
I'm using chromedriver.
Today it saves in the default folder of chromedriver (Downloads) with a default name I move and rename to perform the import and this does not work well, always the problem.
Can I download it in the right place with the right name?
Thanks
- Dorian (MJT support)
- Automation Wizard
- Posts: 1386
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Change download folder and file name on chromedriver
I was experimenting with this a little while ago, and didn't manage to find a way. There are some great mind here though, and some of those have delved quite deeply into ChromeDriver options.
I'd be doing it the same way you already are unless someone finds a way to do it. The question in the meantime is, how can we make the method you're using more reliable? What seems to be happening?
I'd be doing it the same way you already are unless someone finds a way to do it. The question in the meantime is, how can we make the method you're using more reliable? What seems to be happening?
Yes, we have a Custom Scripting Service. Message me or go here
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Change download folder and file name on chromedriver
I think you need to tap into some of the experimental options to change that. As far as I've been able to tell it's not possible from the MS commands. But that being said, can't you just monitor the download directory and get the files from there and then move them to wherever you want?
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Change download folder and file name on chromedriver
The file name can be changed using JavaScript. Just add a <a> with href to the file and add the name using the download attribute to specify the file name:
Just click (using either JS or some MS command) and it will be downloaded as filename.123
Code: Select all
<a href="https://url.domain/file.abc" download="filename.123">
Re: Change download folder and file name on chromedriver
I didn't know about these experimental functions, I will research.
My script downloads the file in the Download folder and in the sequence it takes this file and moves it to the folder where the other routine does the import. The problem is that sometimes the site where he downloads the bug or gets slow and takes a long time to release the download and the script tries to move the file but it is not available yet and proceeds to the next step.
My routine clicks on a form button that already has a post and returns the file download.
Thanks
Code: Select all
I think you need to tap into some of the experimental options to change that.
As far as I've been able to tell it's not possible from the MS commands. But that being said,
can't you just monitor the download directory and get the files from there and then move them to
wherever you want?
Code: Select all
<a href="https://url.domain/file.abc" download="filename.123">
Thanks
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Change download folder and file name on chromedriver
Then you can add the download attribute to have it renamed to whatever you filename you want.
Changing the download path will not help you with the problem of slow and interrupted downloads.
I suggest you add some check within your script which look for a new file, and it is still not a fully downloaded file wait/loop back and do another check. If it falls X number of times you take care of that in a new routine. If the check is ok you carry on.
Changing the download path will not help you with the problem of slow and interrupted downloads.
I suggest you add some check within your script which look for a new file, and it is still not a fully downloaded file wait/loop back and do another check. If it falls X number of times you take care of that in a new routine. If the check is ok you carry on.
Re: Change download folder and file name on chromedriver
The routine is on a remote computer and when I need to make any adjustments I access the remote desktop and make the adjustments.
I realized that the download is only performed when I have the remote desktop open. When I close the remote the routine continues to be executed but the file is not downloaded.
How my routine works:
I have a master routine that includes subroutines.
At the end of each collection at the supplier, he registers the name of the download file in the bank.
The problem is that the file is not being downloaded when the remote desktop is closed.
Now be in doubt what to do.
Thanks
I realized that the download is only performed when I have the remote desktop open. When I close the remote the routine continues to be executed but the file is not downloaded.
How my routine works:
I have a master routine that includes subroutines.
Code: Select all
Let>CHROMEDRIVER_EXE=C:\chromedriver\chromedriver.exe
ChromeStart>Chrome
// CHECK IF YOU HAVE SOMETHING TO BE IMPORTED
Include>%SCRIPT_DIR%\collect.scp
// PO_TOTAL VARIABLE CREATED IN COLLECT.SCP WITH THE RESULT OF THE IMPORT CONSULTATION
Wait>2
IF>(PO_TOTAL <> 0) AND (PO_TOTAL <> )
// LOG IN TO THE SUPPLIER SYSTEM OF THE FILE TO BE IMPORTED
Include>%SCRIPT_DIR%\LOGIN.scp
// IF THERE IS STILL A FILE TO BE IMPORTED
While>PO_TOTAL>0
// DOWNLOAD SUPPLIER FILE
Include>%SCRIPT_DIR%\down_supplier.scp
// MOVE THE DOWNLOAD FOLDER FILE TO THE IMPORT LOCATION
Include>%SCRIPT_DIR%\MOVE_FILE.scp
//IMPORTS THE FILE TO THE LOCAL SYSTEM
Include>%SCRIPT_DIR%\IMPORT_FILE.scp
// CHECK IF THERE IS ANY MORE FILES TO BE COLLECTED FROM THE SUPPLIER
include>%SCRIPT_DIR%\collect.scp
ENDWHILE
ENDIF
Include>%SCRIPT_DIR%\LOGOUT.scp
ChromeQuit>Chrome
The problem is that the file is not being downloaded when the remote desktop is closed.
Now be in doubt what to do.
Thanks
- Dorian (MJT support)
- Automation Wizard
- Posts: 1386
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Change download folder and file name on chromedriver
This might help : https://help.mjtnet.com/article/30-why- ... es-session
Yes, we have a Custom Scripting Service. Message me or go here
Re: Change download folder and file name on chromedriver
It makes perfect sense for my problem.
Strange that this routine has been running for over 1 year and started to present this problem a few weeks ago.
Is there any configuration to fix this problem with Winsta0?
Thanks
Strange that this routine has been running for over 1 year and started to present this problem a few weeks ago.
Is there any configuration to fix this problem with Winsta0?
Thanks
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Change download folder and file name on chromedriver
This is one of the reasons I turned to Teamviewer. Price is fair and the service is great.