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.



27
28
29
# File 'lib/selenium/webdriver/common/bridge_helper.rb', line 27

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



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

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.



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

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