Module: Selenium::WebDriver::BridgeHelper Private

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

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Shared across bridges

Instance Method Summary collapse

Instance Method Details

#element_id_from(id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
# File 'lib/selenium/webdriver/common/bridge_helper.rb', line 46

def element_id_from(id)
  id['ELEMENT'] or id['element-6066-11e4-a52e-4f735466cecf']
end

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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
# File 'lib/selenium/webdriver/common/bridge_helper.rb', line 50

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/selenium/webdriver/common/bridge_helper.rb', line 31

def unwrap_script_result(arg)
  case arg
  when Array
    arg.map { |e| unwrap_script_result(e) }
  when Hash
    if id = element_id_from(arg)
      Element.new self, id
    else
      arg.each { |k, v| arg[k] = unwrap_script_result(v) }
    end
  else
    arg
  end
end