class RegressyCommon::DriverCreator

Public Class Methods

new(capability) click to toggle source
# File lib/regressy_common/driver_creator.rb, line 5
def initialize(capability)
  @capability = capability
end

Public Instance Methods

create_driver() click to toggle source
# File lib/regressy_common/driver_creator.rb, line 9
def create_driver
  if @capability && !@capability.is_local?
    create_driver_remote
  else
    create_driver_local
  end
end

Protected Instance Methods

create_driver_local() click to toggle source
# File lib/regressy_common/driver_creator.rb, line 23
def create_driver_local
  Selenium::WebDriver.for(
    local_browser_name,
    url: selenium_hub_url,
    http_client: http_client,
    options: options_chrome,
  )
end
create_driver_remote() click to toggle source
# File lib/regressy_common/driver_creator.rb, line 37
def create_driver_remote
  (@capability.is_smartphone?)? driver_remote_appium : driver_remote_selenium
end
driver_remote_appium() click to toggle source
# File lib/regressy_common/driver_creator.rb, line 41
def driver_remote_appium
  Appium::Driver.new(
    {
      'caps' => @capability.caps,
      'appium_lib' => {
        server_url: selenium_hub_url,
      },
    },
    true,
  ).start_driver
end
driver_remote_selenium() click to toggle source
# File lib/regressy_common/driver_creator.rb, line 53
def driver_remote_selenium
  Selenium::WebDriver.for(
    :remote,
    url: selenium_hub_url,
    desired_capabilities: @capability.caps,
    http_client: http_client,
  )
end
http_client() click to toggle source
# File lib/regressy_common/driver_creator.rb, line 62
def http_client
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.read_timeout = read_timeout_value
  client
end
local_browser_name() click to toggle source
# File lib/regressy_common/driver_creator.rb, line 32
def local_browser_name
  browser_name = @capability && @capability.caps["browserName"]
  (browser_name)? browser_name.to_sym : :chrome
end
options_chrome() click to toggle source
# File lib/regressy_common/driver_creator.rb, line 68
def options_chrome
  options = Selenium::WebDriver::Chrome::Options.new
  options.add_option(:w3c, false)
  options
end
read_timeout_value() click to toggle source
# File lib/regressy_common/driver_creator.rb, line 19
def read_timeout_value
  140
end
selenium_hub_url() click to toggle source
# File lib/regressy_common/driver_creator.rb, line 74
def selenium_hub_url
  %(http://selenium-hub:4444/wd/hub)
end