Forums

ChromeDriver Download Directory (selenium)

I'm doing a task with selenium but I can't find downloaded file or change de download directory, Tried adding "chrome_options.add_experimental_option( "prefs", { "download.default_directory": "/home/consorciosdigital/tasks" })" but still no success, the file works perfect, I added a ss on the final of it and it finishes without any error, but I can't find the file.

Could you post the exact code that you're using to create your Chrome webdriver object?

enter code here

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_experimental_option( "prefs", { "download.default_directory": "/home/consorciosdigital/tasks" })
driver = webdriver.Chrome(options=chrome_options)

All perfect indented, I see fine on preview but when I send it shows broke, but on file its perfect indented. As I found in another topics.

There needs to be non-indented text followed by an empty line for the indentation to be respected.

Regarding your issue -- are you sure that the file is being actually obtained? Is it expected to be downloaded by clicking on a button, for example? Maybe you could add some extra logging to the task to ensure that all elements that are used are being located correctly?

Yes, the download is expected by clicking a button, I took 2 SS I before the click and one after the click , on the after SS you can see the button was clicked (green border on the icon) , I tried to add a time.sleep with 120, and with 500 seconds, the result is the same, I can't find any file. (notice the file is less then 1mb).

Also I can see my storage getting sized, Exemple it was 580mb taken and after I run the script it went to 583mb, but the file is not in the folder that I used, and I Can't find it.

Before SS https://photos.app.goo.gl/pRVZw98D5J9rjVaGA After SS https://photos.app.goo.gl/gYtgW9ooS8QTfXk66

OK, so it sounds like it is downloading it somewhere, given that your storage used is going up, but it's not going to the directory that you're telling it to download files to.

Perhaps a good first step would be to try to find out where it is putting it. If you run this bash command:

du -hs /tmp ~/.[!.]* ~/* | sort -h

...then it will give you a report on which directories are using up disk space, so you can run it once, then run your script, then run it again, and see which directories are getting bigger. Then let us know which one that is, and perhaps we can make some suggestions.

Did the test, with the cmd sizes didn't changed, but as you can see my storage is getting bigger ( perhaps its going to somewhere that I don't have access )

Cmd Before: https://photos.app.goo.gl/DuE3w9aRU6GhDCjd9 Cmd After (exact the same) https://photos.app.goo.gl/xU6xW6tj5LjgQEuj8

Storage Size Before: https://photos.app.goo.gl/aSsNJP98k1xxgzSB7 Storage Size After: https://photos.app.goo.gl/qrv4FWGkvaRjDyQS8

That's really strange! I agree, the numbers from the command are the same before and after.

Could you try again, but this time using this bash command:

du -sk /tmp ~ /var/www | sort -h

...both before and after? That will shorten the output (there will just be one line for your home directory), it will add on /var/www, which is the only other location where your code has write access, and it will also express disk usage in kilobytes, which should make it easier to see where stuff is being written.

Did, there was no difference again, but it File Storage counter didn't changed in the dashboard also (as before).

Screnshoot

Also I tried to SS the chrome download pages and its totally empty.

driver.get("chrome://downloads/")

Could you give us a snippet of code that we could use to fully reproduce your problem? (If you do not want to post it on the open forum you could send it to support@pythonanywhere.com)

Ofc, just sent it from thiago@consorcios.digital, with full code.

OK, let's continue our conversation there.

For those who gets same problem: I was using older system image (fishnchips) just updated to newer (glastonbury) and everything worked perfectly. thx to PythonAnywhere staff

Change System Image