Skip to content

Instantly share code, notes, and snippets.

@DylanLacey
Last active October 4, 2017 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DylanLacey/ecbd364ad28f612547510494d858d0dc to your computer and use it in GitHub Desktop.
Save DylanLacey/ecbd364ad28f612547510494d858d0dc to your computer and use it in GitHub Desktop.
Marionette Doesn't Like Expiry
## In a sane ruby environment, `rackup app.rb -p 9292`
class App
def self.call(env)
puts "Request Occured"
request = Rack::Request.new(env)
s,h,b = gen_response request
response = Rack::Response.new b, s, h
response.set_cookie("foo", {:value => "bar", :path => "/", :expires => Time.now+24*60*60})
return response
end
def self.gen_response request
case request.request_method
when 'GET'
[200, {"Content-Type" => "text/html"}, [content]]
else
[404, {}, ["Did you get lost?"]]
end
end
def self.content
content = %{<!doctype html><html>
<head></head>
<body>
<h1>Hi There, lovely to see you</h1>
</body>
</html>
}
end
end
source "https://www.rubygems.org"
gem "selenium-webdriver"
## Have in a directory with Gemfile.
## Run `gem install bundler && bundle install` beforehand.
## Start a Marionette-enabled Selenium Server and change server_url to match (line 8).
## Then run this script with `bundle exec ruby test_script.rb`.
require "selenium/webdriver"
def server_url
"http://localhost:4444/wd/hub"
end
def caps
caps = Selenium::WebDriver::Remote::Capabilities.firefox marionette: true
end
driver = Selenium::WebDriver.for :remote, :url => server_url, :desired_capabilities => caps
driver.navigate.to "http://localhost:9292"
driver.find_element :tag_name, "h1"
driver.manage.all_cookies.each do |cookie|
puts cookie if cookie[:name].eql? "foo"
end
driver.quit
@aldaris
Copy link

aldaris commented Oct 4, 2017

I'm getting this error on mac:

$ ruby2.4 test_script.rb
test_script.rb: end of file reached (EOFError)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment