Module: OnlyofficeWebdriverWrapper::WebdriverHelper
- Included in:
- WebDriver
- Defined in:
- lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_helper.rb
Overview
Some additional methods for webdriver
Instance Method Summary collapse
-
#cleanup_download_folder ⇒ Nothing
Perform safe cleanup of download folder.
-
#download(file_url) ⇒ String
Download temp file and return it location.
-
#system_screenshot(file_name) ⇒ String
Make screenshot by system methods Works only on Linux.
Instance Method Details
#cleanup_download_folder ⇒ Nothing
Perform safe cleanup of download folder
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_helper.rb', line 30 def cleanup_download_folder return unless Dir.exist?(@download_directory) if @download_directory.start_with?(Dir.tmpdir) FileUtils.remove_dir(@download_directory) else OnlyofficeLoggerHelper.log("Download directory #{@download_directory} is not at tmp dir. " \ 'It will be not deleted') end end |
#download(file_url) ⇒ String
Download temp file and return it location
20 21 22 23 24 25 26 |
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_helper.rb', line 20 def download(file_url) data = URI.parse(file_url).open.read file = Tempfile.new('onlyoffice-downloaded-file') file.write(data.force_encoding('UTF-8')) file.close file.path end |
#system_screenshot(file_name) ⇒ String
Make screenshot by system methods Works only on Linux
13 14 15 |
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_helper.rb', line 13 def system_screenshot(file_name) `import -window root #{file_name}` end |