Module: LapisLazuli::WorldModule::Browser

Extended by:
ClassMethods
Includes:
Config, Error, Logging, Proxy
Included in:
LapisLazuli
Defined in:
lib/lapis_lazuli/world/browser.rb

Overview

Module managing a browser instance

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from ClassMethods

browser_module, browser_modules

Methods included from Proxy

#has_proxy?, #proxy

Methods included from Logging

#log

Methods included from Config

#add_config_from_file, #config, #current_env, #env, #env_or_config, #get_config_from_file, #has_config?, #has_env?, #has_env_or_config?, #init, #load_config, #metadata, #var_from_env

Methods included from Config::ClassMethods

#add_config, #config_file, #config_file=, #config_files

Methods included from Error

#error, #start_debugger

Instance Method Details

#browser(*args) ⇒ Object

Get the current main browser



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/lapis_lazuli/world/browser.rb', line 50

def browser(*args)
  b = Runtime.instance.set_if(self, :browser) do
    # Add LL to the arguments for the browser
    LapisLazuli::Browser.set_world(self)

    # Create & return a new browser object
    brow = LapisLazuli::Browser.new(*args)

     = Runtime.instance.get(:metadata)
    if 
      .set(
        "browser",
        {
          "name" => brow.driver.capabilities[:browser_name],
          "version" => brow.driver.capabilities[:browser_version] || brow.driver.capabilities[:version],
          "platform" => brow.driver.capabilities[:platform_name] || brow.driver.capabilities[:platform],
        }
      )
    end

    sessionid = brow.driver.capabilities["webdriver.remote.sessionid"]

    if !sessionid.nil?
      .set("sessionid", sessionid)
    end

    brow
  end

  if not b.is_open?
    b.start
  end

  return b
end

#has_browser?Boolean

Checks if there is a browser started

Returns:

  • (Boolean)


43
44
45
46
# File 'lib/lapis_lazuli/world/browser.rb', line 43

def has_browser?
  b = Runtime.instance.get :browser
  return (not b.nil? and b.is_open?)
end