Selenium default download directory settings is not working in Ubuntu 20.4 - files are not saved

Tags:

Answer: 1

14 hours ago

I have this simple test script, which was working before, but it is not now after upgrading from Ubuntu 18.04 to Ubuntu 20.4

from selenium import webdriver
import os, time

WorkDir = "/tmp/test/"
FileName = "mitmdump"
WebServer = "http://localhost:8000/"
options = webdriver.ChromeOptions()
preferences = {"download.default_directory": WorkDir , 
    "download.prompt_for_download": False,
}
options.add_experimental_option("prefs", preferences)
driver = webdriver.Chrome(options=options)
driver.get(str(WebServer) + str(FileName))

while not os.path.exists(str(WorkDir) + "/" + str(FileName)):
    print("waiting for file download to finish")
    time.sleep(3)

When I turn download.prompt_for_download to True I can see previously downloaded files by this code, however I can't see the files when I look into the /tmp/test using standard terminal or File manager.

Cause of this behavior is that Chromium is installed in snap which contains sandboxed filesystem.

Question is how to run this test?

Added by: Hassan Muller

Answer: 2

18 hours ago

I was able to solve the issue by following steps to install chromium from debian in Chromium without snap.

Problem is that Chrome version there is 83, while version in snap is 86 and I would like to test in latest version of course. Although for this case it is probably not important, it may be important for different things.

Is there different, better way?

Added by: Betty Zboncak

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9