0

I am trying to download a file with selenium/python and later read from that file.

When I use non remote driver as below, it downloads file and all is gucci

def initialize():
     global instance
     chrome_options = webdriver.ChromeOptions()
     prefs = {'download.default_directory':'/Users/dusandev/Desktop/StreamFlowWebTests/reporting/wallets'}
     chrome_options.add_experimental_option('prefs', prefs)
     instance = webdriver.Chrome(chrome_options=chrome_options)
     instance.implicitly_wait(2)
     return instance

However, when I use remote driver, it fails with and does not download the file.

def initialize():
     global instance
     chrome_options = webdriver.ChromeOptions()
     prefs = {'download.default_directory':'/Users/dusandev/Desktop/StreamFlowWebTests/reporting/wallets'}
     chrome_options.add_experimental_option('prefs', prefs)
     instance = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.CHROME, options=chrome_options)
     instance.implicitly_wait(2)
     return instance

The error is following:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/dusandev/Desktop/StreamFlowWebTests/reporting/wallets/solflare-backup.txt'

I also tried to make folder writable with adding rw to the end of the folder like this

{'download.default_directory':'/Users/dusandev/Desktop/StreamFlowWebTests/reporting/wallets:rw'}

That did not work as well.

Do you have any idea? Thank you in advance

DZR
  • 195
  • 1
  • 2
  • 12

1 Answers1

1

The download directory you're specifying needs to be a directory on the remote server. Selenium doesn't provide a way to fetch downloads through a remote. If you have access, you can scp it from the server.

How to download a file using the remote selenium webdriver?

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30