Last active
October 4, 2017 09:14
-
-
Save DylanLacey/ecbd364ad28f612547510494d858d0dc to your computer and use it in GitHub Desktop.
Marionette Doesn't Like Expiry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://www.rubygems.org" | |
gem "selenium-webdriver" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting this error on mac: