more capybara stuff
This commit is contained in:
parent
5fb8609dfe
commit
7192c46c1b
|
@ -8,6 +8,12 @@ def find_attribute(name, value = nil)
|
|||
attribute
|
||||
end
|
||||
|
||||
def dont_find_attribute(name, value = nil, &block)
|
||||
dont_find_wrap("attribute #{name}") do
|
||||
find_attribute(name, value, &block)
|
||||
end
|
||||
end
|
||||
|
||||
def has_attribute?(name, value)
|
||||
attribute = find_attribute(name)
|
||||
|
||||
|
@ -28,7 +34,11 @@ def set_input(name, value)
|
|||
|
||||
case input.tag_name.downcase
|
||||
when 'select'
|
||||
input.find("option[value='#{value}']").select_option
|
||||
begin
|
||||
input.find("option[value='#{value}']").select_option
|
||||
rescue Capybara::ElementNotFound
|
||||
input.find("option[text()='#{value}']").select_option
|
||||
end
|
||||
else
|
||||
input.set(value)
|
||||
end
|
||||
|
@ -60,14 +70,20 @@ module Capybara
|
|||
end
|
||||
end
|
||||
|
||||
def dont_find(search)
|
||||
find(search)
|
||||
def dont_find_wrap(search)
|
||||
yield
|
||||
|
||||
raise Capybara::ElementFound.new(search)
|
||||
rescue Capybara::ElementNotFound
|
||||
true
|
||||
end
|
||||
|
||||
def dont_find(search)
|
||||
dont_find_wrap(search) do
|
||||
find(search)
|
||||
end
|
||||
end
|
||||
|
||||
def dont_find_object(object)
|
||||
dont_find("[data-id='#{object.id}']")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue