mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Merging Andrea's hidden elements branch with some changes
Interacting with hidden elements shouldn't raise errors when ignore_hidden_elements is false ignore_hidden_elements is false by default Merge remote branch 'remogatto/interact_with_visible_only' Conflicts: lib/capybara.rb lib/capybara/session.rb spec/drivers_spec.rb spec/dsl/choose_spec.rb spec/dsl/click_button_spec.rb spec/dsl/click_link_spec.rb spec/dsl/click_spec.rb spec/dsl/fill_in_spec.rb spec/dsl/locate_spec.rb spec/dsl/select_spec.rb spec/dsl/uncheck_spec.rb spec/views/with_html.erb
This commit is contained in:
commit
cbe2f07331
8 changed files with 43 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
.DS_Store
|
||||
pkg
|
||||
*~
|
||||
spec.opts
|
||||
|
||||
|
|
|
@ -10,11 +10,20 @@ module Capybara
|
|||
class OptionNotFound < ElementNotFound; end
|
||||
class NotSupportedByDriverError < CapybaraError; end
|
||||
class TimeoutError < CapybaraError; end
|
||||
class LocateHiddenElementError < CapybaraError; end
|
||||
class InfiniteRedirectError < TimeoutError; end
|
||||
|
||||
class << self
|
||||
attr_accessor :debug, :asset_root, :app_host, :run_server
|
||||
attr_accessor :default_selector, :default_wait_time
|
||||
attr_accessor :default_selector, :default_wait_time, :ignore_hidden_elements
|
||||
|
||||
def default_selector
|
||||
@default_selector ||= :xpath
|
||||
end
|
||||
|
||||
def default_wait_time
|
||||
@default_wait_time ||= 2
|
||||
end
|
||||
|
||||
def log(message)
|
||||
puts "[capybara] #{message}" if debug
|
||||
|
@ -40,3 +49,4 @@ end
|
|||
Capybara.run_server = true
|
||||
Capybara.default_selector = :xpath
|
||||
Capybara.default_wait_time = 2
|
||||
Capybara.ignore_hidden_elements = false
|
||||
|
|
|
@ -56,7 +56,7 @@ module Capybara
|
|||
end
|
||||
|
||||
def click_link(locator)
|
||||
msg = "no link with title, id or containing text / image with alternative text like '#{locator}' found"
|
||||
msg = "no link with title, id or text '#{locator}' found"
|
||||
locate(:xpath, XPath.link(locator), msg).click
|
||||
end
|
||||
|
||||
|
|
|
@ -25,4 +25,4 @@ module CheckSpec
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -126,6 +126,14 @@ shared_examples_for "click_button" do
|
|||
@session.click_button('click_me_123')
|
||||
extract_results(@session)['first_name'].should == 'John'
|
||||
end
|
||||
|
||||
it "should serialize and send GET forms" do
|
||||
@session.visit('/form')
|
||||
@session.click_button('med')
|
||||
@results = extract_results(@session)
|
||||
@results['middle_name'].should == 'Darren'
|
||||
@results['foo'].should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "with value given on a button defined by <button> tag" do
|
||||
|
|
|
@ -17,11 +17,5 @@ shared_examples_for "uncheck" do
|
|||
extract_results(@session)['pets'].should include('dog')
|
||||
extract_results(@session)['pets'].should_not include('hamster')
|
||||
end
|
||||
|
||||
context "with a locator that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
running { @session.uncheck('does not exist') }.should raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<h1>Form</h1>
|
||||
|
||||
<form action="/form" method="post">
|
||||
|
||||
<div style="display:none;">
|
||||
<label for="form_first_name_hidden">
|
||||
First Name
|
||||
<input type="text" name="form[first_name]" value="John" id="form_first_name_hidden"/>
|
||||
</label>
|
||||
<button type="submit" id="hidden_button" value="click_me">Hidden button</button>
|
||||
<input type="checkbox" id="hidden_unchecked_checkbox"/>
|
||||
<input type="checkbox" id="hidden_checked_checkbox" checked="checked"/>
|
||||
<label for="hidden_form_locale">Locale</label>
|
||||
<select name="form[locale]" id="hidden_form_locale">
|
||||
<option value="sv">Swedish</option>
|
||||
<option selected="selected" value="en">English</option>
|
||||
<option value="fi">Finish</option>
|
||||
<option value="no">Norwegian</option>
|
||||
</select>
|
||||
<input type="radio" value="male" id="hidden_gender_male"/>
|
||||
<input type="file" id="hidden_form_upload"/>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<label for="form_first_name">
|
||||
First Name
|
||||
|
|
|
@ -32,4 +32,5 @@
|
|||
|
||||
<div id="hidden" style="display:none;">
|
||||
<div id="hidden_via_ancestor">Inside element with hidden ancestor</div>
|
||||
<a href="/with_simple_html" title="awesome title" class="simple">hidden link</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue