Module: OnlyofficeWebdriverWrapper::FirefoxHelper

Included in:
WebDriver
Defined in:
lib/onlyoffice_webdriver_wrapper/helpers/firefox_helper.rb

Overview

Module for working with firefox

Instance Method Summary collapse

Instance Method Details

#firefox_serviceSelenium::WebDriver::Firefox::Service

Returns Instance of Firefox Service object.

Returns:

  • (Selenium::WebDriver::Firefox::Service)

    Instance of Firefox Service object



7
8
9
10
# File 'lib/onlyoffice_webdriver_wrapper/helpers/firefox_helper.rb', line 7

def firefox_service
  geckodriver = File.join(File.dirname(__FILE__), 'bin/geckodriver')
  @firefox_service ||= Selenium::WebDriver::Firefox::Service.new(path: geckodriver)
end

#start_firefox_driverWebdriver::Firefox

Returns firefox webdriver.

Returns:

  • (Webdriver::Firefox)

    firefox webdriver



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/onlyoffice_webdriver_wrapper/helpers/firefox_helper.rb', line 13

def start_firefox_driver
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile['browser.download.folderList'] = 2
  profile['browser.helperApps.neverAsk.saveToDisk'] = read_firefox_files_to_save
  profile['browser.download.dir'] = @download_directory
  profile['browser.download.manager.showWhenStarting'] = false
  profile['dom.disable_window_move_resize'] = false
  options = Selenium::WebDriver::Firefox::Options.new(profile: profile)
  driver = Selenium::WebDriver.for :firefox, service: firefox_service, options: options
  if headless.running?
    driver.manage.window.size = Selenium::WebDriver::Dimension.new(headless.resolution_x,
                                                                   headless.resolution_y)
  end
  driver
end