Skip to content

Commit

Permalink
Raise an error when scope not found on page
Browse files Browse the repository at this point in the history
  • Loading branch information
Theo Hultberg and Jonas Nicklas authored and jnicklas committed Nov 16, 2009
1 parent 6e55c86 commit 15a7131
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/webcat/session.rb
Expand Up @@ -80,6 +80,7 @@ def has_css?(path, options={})
end

def within(scope)
raise Webcat::ElementNotFound, "scope '#{scope}' not found on page" if find(scope).empty?
scopes.push(scope)
yield
scopes.pop
Expand Down
7 changes: 7 additions & 0 deletions spec/session_spec.rb
Expand Up @@ -482,6 +482,13 @@ def extract_results(session)
@session.body.should include('Hello world')
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

context "with forms" do
Expand Down

0 comments on commit 15a7131

Please sign in to comment.