Module: Selenium::WebDriver::DriverExtensions::HasFileDownloads Private

Included in:
Remote::Driver
Defined in:
rb/lib/selenium/webdriver/common/driver_extensions/has_file_downloads.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#delete_downloadable_filesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



49
50
51
52
53
# File 'rb/lib/selenium/webdriver/common/driver_extensions/has_file_downloads.rb', line 49

def delete_downloadable_files
  verify_enabled

  @bridge.delete_downloadable_files
end

#download_file(file_name, target_directory) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'rb/lib/selenium/webdriver/common/driver_extensions/has_file_downloads.rb', line 30

def download_file(file_name, target_directory)
  verify_enabled

  response = @bridge.download_file(file_name)
  contents = response['contents']

  File.open("#{file_name}.zip", 'wb') { |f| f << Base64.decode64(contents) }
  target_directory += '/' unless target_directory.end_with?('/')
  FileUtils.mkdir_p(target_directory)

  begin
    Zip::File.open("#{file_name}.zip") do |zip|
      zip.each { |entry| zip.extract(entry, "#{target_directory}#{file_name}") }
    end
  ensure
    FileUtils.rm_f("#{file_name}.zip")
  end
end

#downloadable_filesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
# File 'rb/lib/selenium/webdriver/common/driver_extensions/has_file_downloads.rb', line 24

def downloadable_files
  verify_enabled

  @bridge.downloadable_files['names']
end