Module: Selenium::WebDriver::BridgeHelper

Included in:
Remote::Bridge
Defined in:
lib/selenium/webdriver/bridge_helper.rb

Overview

Shared across bridges

Instance Method Summary collapse

Instance Method Details

#element_id_from(id) ⇒ Object



24
25
26
# File 'lib/selenium/webdriver/bridge_helper.rb', line 24

def element_id_from(id)
  id['ELEMENT']
end


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/selenium/webdriver/bridge_helper.rb', line 28

def parse_cookie_string(str)
  result = {
    'name'    => '',
    'value'   => '',
    'domain'  => '',
    'path'    => '',
    'expires' => '',
    'secure'  => false
  }

  str.split(";").each do |attribute|
    if attribute.include? "="
      key, value = attribute.strip.split("=", 2)
      if result['name'].empty?
        result['name']  = key
        result['value'] = value
      elsif key == 'domain' && value.strip =~ /^\.(.+)/
        result['domain'] = $1
      elsif key && value
        result[key] = value
      end
    elsif attribute == "secure"
      result['secure'] = true
    end

    unless [nil, "", "0"].include?(result['expires'])
      # firefox stores expiry as number of seconds
      result['expires'] = Time.at(result['expires'].to_i)
    end
  end

  result
end

#unwrap_script_result(arg) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/selenium/webdriver/bridge_helper.rb', line 12

def unwrap_script_result(arg)
  if arg.kind_of?(Array)
    arg.map { |e| unwrap_script_result(e) }
  else
    if arg.kind_of?(Hash) && arg.member?("ELEMENT")
      Element.new self, element_id_from(arg)
    else
      arg
    end
  end
end