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.



42
43
44
# File 'lib/selenium/webdriver/common/bridge_helper.rb', line 42

def element_id_from(id)
  id['ELEMENT'] || 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.



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

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'] = Regexp.last_match(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.



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/selenium/webdriver/common/bridge_helper.rb', line 29

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