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