2010-07-10 00:20:32 +00:00
|
|
|
module Capybara
|
|
|
|
class Node
|
|
|
|
module Matchers
|
|
|
|
def has_xpath?(path, options={})
|
|
|
|
wait_conditionally_until do
|
|
|
|
results = all(:xpath, path, options)
|
|
|
|
|
|
|
|
if options[:count]
|
|
|
|
results.size == options[:count]
|
|
|
|
else
|
|
|
|
results.size > 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue Capybara::TimeoutError
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_xpath?(path, options={})
|
|
|
|
wait_conditionally_until do
|
|
|
|
results = all(:xpath, path, options)
|
|
|
|
|
|
|
|
if options[:count]
|
|
|
|
results.size != options[:count]
|
|
|
|
else
|
|
|
|
results.empty?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue Capybara::TimeoutError
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_css?(path, options={})
|
2010-08-14 16:35:46 +00:00
|
|
|
has_xpath?(XPath::HTML.from_css(path), options)
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_css?(path, options={})
|
2010-08-14 16:35:46 +00:00
|
|
|
has_no_xpath?(XPath::HTML.from_css(path), options)
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_content?(content)
|
2010-08-14 16:35:46 +00:00
|
|
|
has_xpath?(XPath::HTML.content(content))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_content?(content)
|
2010-08-14 16:35:46 +00:00
|
|
|
has_no_xpath?(XPath::HTML.content(content))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_link?(locator)
|
2010-08-14 16:35:46 +00:00
|
|
|
has_xpath?(XPath::HTML.link(locator))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_link?(locator)
|
2010-08-14 16:35:46 +00:00
|
|
|
has_no_xpath?(XPath::HTML.link(locator))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_button?(locator)
|
2010-08-14 16:35:46 +00:00
|
|
|
has_xpath?(XPath::HTML.button(locator))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_button?(locator)
|
2010-08-14 16:35:46 +00:00
|
|
|
has_no_xpath?(XPath::HTML.button(locator))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_field?(locator, options={})
|
2010-08-14 16:35:46 +00:00
|
|
|
has_xpath?(XPath::HTML.field(locator, options))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_field?(locator, options={})
|
2010-08-14 16:35:46 +00:00
|
|
|
has_no_xpath?(XPath::HTML.field(locator, options))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_checked_field?(locator)
|
2010-08-14 16:35:46 +00:00
|
|
|
has_xpath?(XPath::HTML.field(locator, :checked => true))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_unchecked_field?(locator)
|
2010-08-14 16:35:46 +00:00
|
|
|
has_xpath?(XPath::HTML.field(locator, :unchecked => true))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_select?(locator, options={})
|
2010-08-14 16:35:46 +00:00
|
|
|
has_xpath?(XPath::HTML.select(locator, options))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_select?(locator, options={})
|
2010-08-14 16:35:46 +00:00
|
|
|
has_no_xpath?(XPath::HTML.select(locator, options))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_table?(locator, options={})
|
2010-08-14 16:35:46 +00:00
|
|
|
has_xpath?(XPath::HTML.table(locator, options))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_table?(locator, options={})
|
2010-08-14 16:35:46 +00:00
|
|
|
has_no_xpath?(XPath::HTML.table(locator, options))
|
2010-07-10 00:20:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|