mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Raise an error when scope not found on page
This commit is contained in:
parent
6e55c86a13
commit
15a713114b
2 changed files with 8 additions and 0 deletions
|
@ -80,6 +80,7 @@ class Webcat::Session
|
||||||
end
|
end
|
||||||
|
|
||||||
def within(scope)
|
def within(scope)
|
||||||
|
raise Webcat::ElementNotFound, "scope '#{scope}' not found on page" if find(scope).empty?
|
||||||
scopes.push(scope)
|
scopes.push(scope)
|
||||||
yield
|
yield
|
||||||
scopes.pop
|
scopes.pop
|
||||||
|
|
|
@ -482,6 +482,13 @@ shared_examples_for "session" do
|
||||||
@session.body.should include('Hello world')
|
@session.body.should include('Hello world')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should raise an error if the scope is not found on the page" do
|
||||||
|
running {
|
||||||
|
@session.within("//div[@id='doesnotexist']") do
|
||||||
|
end
|
||||||
|
}.should raise_error(Webcat::ElementNotFound)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with forms" do
|
context "with forms" do
|
||||||
|
|
Loading…
Reference in a new issue