Class: Maze::Client::Selenium::BitBarClient

Inherits:
BaseClient
  • Object
show all
Defined in:
lib/maze/client/selenium/bb_client.rb

Instance Method Summary collapse

Instance Method Details

#log_run_outroObject



31
32
33
34
35
36
37
38
# File 'lib/maze/client/selenium/bb_client.rb', line 31

def log_run_outro
  api_client = BitBarApiClient.new(Maze.config.access_key)

  $logger.info 'Selenium session created:'
  id = Maze.driver.session_id
  link = api_client.get_device_session_ui_link(id)
  $logger.info Maze::Loggers::LogUtil.linkify link, 'BitBar session(s)' if link
end

#start_sessionObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/maze/client/selenium/bb_client.rb', line 5

def start_session
  config = Maze.config
  capabilities = ::Selenium::WebDriver::Remote::Capabilities.new
  capabilities['bitbar_apiKey'] = config.access_key
  browsers = YAML.safe_load(File.read("#{__dir__}/bb_browsers.yml"))
  capabilities.merge! BitBarClientUtils.dashboard_capabilities
  capabilities['version'] = config.browser_version unless config.browser_version.nil?
  capabilities.merge! browsers[config.browser]
  capabilities.merge! JSON.parse(config.capabilities_option)
  capabilities['bitbar:options']['testTimeout'] = 900
  config.capabilities = capabilities

  if Maze::Client::BitBarClientUtils.use_local_tunnel?
    capabilities['bitbar_apiKey'] = config.access_key
    Maze::Client::BitBarClientUtils.start_local_tunnel config.sb_local,
                                                       config.username,
                                                       config.access_key
  end

  selenium_url = Maze.config.selenium_server_url

  $logger.trace "Starting Selenium driver with capabilities: #{config.capabilities.to_json}"
  Maze.driver = Maze::Driver::Browser.new :remote, selenium_url, config.capabilities
  Maze.driver.start_driver
end

#stop_sessionObject



40
41
42
43
44
45
# File 'lib/maze/client/selenium/bb_client.rb', line 40

def stop_session
  super
  if Maze::Client::BitBarClientUtils.use_local_tunnel?
    Maze::Client::BitBarClientUtils.stop_local_tunnel
  end
end