Skip to content

Instantly share code, notes, and snippets.

View abotalov's full-sized avatar

Andrei Botalov abotalov

View GitHub Profile
require 'capybara'
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
session = Capybara::Session.new(:selenium, app)
session.visit("/")
session.find('input[name=test]').set(false)
puts session.find('input[name=test]').value # returns 'on', regardless of whether true or false was set at previous row
@abotalov
abotalov / test.rb
Last active December 17, 2015 13:10
require 'capybara'
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
session = Capybara::Session.new(:selenium, app)
session.visit("/")
session.select("Alaska", :from => "last_address_used[state]") # works OK
__END__
@abotalov
abotalov / test.rb
Last active December 17, 2015 10:49
require 'capybara'
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
session = Capybara::Session.new(:selenium, app)
session.visit("/")
session.select("52", :from => "answer_sheet_test_prep_number") # element is selected properly
__END__
@abotalov
abotalov / test.rb
Last active December 17, 2015 07:09
Possible bug in Capybara
require 'capybara'
require 'capybara-webkit'
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
Capybara.ignore_hidden_elements = true
session = Capybara::Session.new(:selenium, app)
session.visit("/")
@abotalov
abotalov / test.feature
Last active December 12, 2015 04:49
Feature that shows Cucumber's syntax
Feature: Test feature
Background:
Given I do something
Scenario: Test Scenario
Given I do something
When I do something
Then I do something
And I do something
<form accept-charset="UTF-8" action="/submissions/1/reviews/4" class="simple_form edit_review" id="edit_review_4" method="post" novalidate="novalidate" name="edit_review_4">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="&#10003;">
<input name="_method" type="hidden" value="put"><input name="authenticity_token" type="hidden" value="gJ/KKAodeIJD8PPnRNeN4GaGb/yqvUDHrsnl9LqLP/c=">
</div>
<div class="input integer optional">
<label class="integer optional control-label" for="review_rating">Rating</label><input class="numeric integer optional" id="review_rating" name="review[rating]" step="1" type="number" value="33">
</div>
@abotalov
abotalov / test.html
Created January 25, 2013 20:51
Simple script to post answer for http://stackoverflow.com/q/14527556/841064
<table>
<tr>
<td>Sara</td>
<td>2.3</td>
<td>4.3</td>
</tr>
<tr>
<td>Mike</td>
<td>4.5</td>
<td>1.1</td>
module Summary
extend Helper
def self.check_block(block_name)
# do something
end
end
@abotalov
abotalov / shipping_costs.feature
Created December 30, 2012 18:29
https://gist.github.com/4414243. It can be expressed with even less words. Less words => less time to read
Feature: Shipping costs
Scenario Outline: Calculate GST status and shipping rate
Given the customer <is> from Australia
When the customer buys <how_much>
Then the customer <GST_or_free_shipping>
Examples:
| is | how_much | GST_or_free_shipping |
| is | something | pays GST |
@abotalov
abotalov / shipping_costs.feature
Last active December 10, 2015 09:28
See https://gist.github.com/4414198. It can be expressed with less words
Feature: Shipping costs
Scenario Outline: Paying GST
Given the customer <is> from Australia
When the customer buys something
Then the customer <pays> GST
Examples:
| is | pays |
| is | pays |