mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Rename node methods which conflic with session methods
This commit is contained in:
parent
afb7dc724c
commit
02d86ac992
6 changed files with 14 additions and 14 deletions
|
@ -25,14 +25,14 @@ class Capybara::Driver::Celerity < Capybara::Driver::Base
|
|||
node.set(value)
|
||||
end
|
||||
|
||||
def select(option)
|
||||
def select_option(option)
|
||||
node.select(option)
|
||||
rescue
|
||||
options = all(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
|
||||
raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
|
||||
end
|
||||
|
||||
def unselect(option)
|
||||
def unselect_option(option)
|
||||
unless node.multiple?
|
||||
raise Capybara::UnselectNotAllowed, "Cannot unselect option '#{option}' from single select box."
|
||||
end
|
||||
|
|
|
@ -26,11 +26,11 @@ module Capybara
|
|||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def select(option)
|
||||
def select_option(option)
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def unselect(option)
|
||||
def unselect_option(option)
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
|
|||
end
|
||||
end
|
||||
|
||||
def select(option)
|
||||
def select_option(option)
|
||||
if node['multiple'] != 'multiple'
|
||||
node.xpath(".//option[@selected]").each { |node| node.remove_attribute("selected") }
|
||||
end
|
||||
|
@ -65,7 +65,7 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
|
|||
end
|
||||
end
|
||||
|
||||
def unselect(option)
|
||||
def unselect_option(option)
|
||||
if node['multiple'] != 'multiple'
|
||||
raise Capybara::UnselectNotAllowed, "Cannot unselect option '#{option}' from single select box."
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
|
|||
end
|
||||
end
|
||||
|
||||
def select(option)
|
||||
def select_option(option)
|
||||
option_node = node.find_element(:xpath, ".//option[normalize-space(text())=#{Capybara::XPath.escape(option)}]") || node.find_element(:xpath, ".//option[contains(.,#{Capybara::XPath.escape(option)})]")
|
||||
option_node.select
|
||||
rescue
|
||||
|
@ -43,7 +43,7 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
|
|||
raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
|
||||
end
|
||||
|
||||
def unselect(option)
|
||||
def unselect_option(option)
|
||||
if node['multiple'] != 'multiple'
|
||||
raise Capybara::UnselectNotAllowed, "Cannot unselect option '#{option}' from single select box."
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@ module Capybara
|
|||
def_delegator :driver, :body
|
||||
def_delegator :driver, :source
|
||||
|
||||
def click(locator)
|
||||
def click_link_or_button(locator)
|
||||
msg = "no link or button '#{locator}' found"
|
||||
locate(:xpath, XPath.link(locator).button(locator), msg).click
|
||||
end
|
||||
|
@ -85,12 +85,12 @@ module Capybara
|
|||
|
||||
def select(value, options={})
|
||||
msg = "cannot select option, no select box with id, name, or label '#{options[:from]}' found"
|
||||
locate(:xpath, XPath.select(options[:from]), msg).select(value)
|
||||
locate(:xpath, XPath.select(options[:from]), msg).select_option(value)
|
||||
end
|
||||
|
||||
def unselect(value, options={})
|
||||
msg = "cannot unselect option, no select box with id, name, or label '#{options[:from]}' found"
|
||||
locate(:xpath, XPath.select(options[:from]), msg).unselect(value)
|
||||
locate(:xpath, XPath.select(options[:from]), msg).unselect_option(value)
|
||||
end
|
||||
|
||||
def attach_file(locator, path)
|
||||
|
|
|
@ -2,13 +2,13 @@ shared_examples_for "click" do
|
|||
describe '#click' do
|
||||
it "should click on a link" do
|
||||
@session.visit('/with_html')
|
||||
@session.click('labore')
|
||||
@session.click_link_or_button('labore')
|
||||
@session.body.should include('Bar')
|
||||
end
|
||||
|
||||
it "should click on a button" do
|
||||
@session.visit('/form')
|
||||
@session.click('awe123')
|
||||
@session.click_link_or_button('awe123')
|
||||
extract_results(@session)['first_name'].should == 'John'
|
||||
end
|
||||
|
||||
|
@ -16,7 +16,7 @@ shared_examples_for "click" do
|
|||
it "should raise an error" do
|
||||
@session.visit('/with_html')
|
||||
running do
|
||||
@session.click('does not exist')
|
||||
@session.click_link_or_button('does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue