Class: Capybara::Selenium::Driver

Inherits:
Object
  • Object
show all
Defined in:
lib/kimurai/capybara_ext/selenium/driver.rb

Instance Method Summary collapse

Instance Method Details

#clear_cookiesObject



21
22
23
# File 'lib/kimurai/capybara_ext/selenium/driver.rb', line 21

def clear_cookies
  browser.manage.delete_all_cookies
end

#get_cookiesObject



4
5
6
# File 'lib/kimurai/capybara_ext/selenium/driver.rb', line 4

def get_cookies
  browser.manage.all_cookies
end

#pidObject



27
28
29
# File 'lib/kimurai/capybara_ext/selenium/driver.rb', line 27

def pid
  @pid ||= `lsof -i tcp:#{port} -t`.strip.to_i
end

#portObject



31
32
33
# File 'lib/kimurai/capybara_ext/selenium/driver.rb', line 31

def port
  @port ||= browser.send(:bridge).instance_variable_get("@http").instance_variable_get("@server_url").port
end


8
9
10
11
12
13
# File 'lib/kimurai/capybara_ext/selenium/driver.rb', line 8

def set_cookie(name, value, options = {})
  options[:name]  ||= name
  options[:value] ||= value

  browser.manage.add_cookie(options)
end

#set_cookies(cookies) ⇒ Object



15
16
17
18
19
# File 'lib/kimurai/capybara_ext/selenium/driver.rb', line 15

def set_cookies(cookies)
  cookies.each do |cookie|
    set_cookie(cookie[:name], cookie[:value], cookie)
  end
end