From 15a713114b2170e78c932f9498d5c5c93b44fbe3 Mon Sep 17 00:00:00 2001 From: Theo Hultberg and Jonas Nicklas Date: Mon, 16 Nov 2009 20:13:57 +0100 Subject: [PATCH] Raise an error when scope not found on page --- lib/webcat/session.rb | 1 + spec/session_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/webcat/session.rb b/lib/webcat/session.rb index a8a3af5e..da7909a4 100644 --- a/lib/webcat/session.rb +++ b/lib/webcat/session.rb @@ -80,6 +80,7 @@ class Webcat::Session end def within(scope) + raise Webcat::ElementNotFound, "scope '#{scope}' not found on page" if find(scope).empty? scopes.push(scope) yield scopes.pop diff --git a/spec/session_spec.rb b/spec/session_spec.rb index 10ace932..42a57ab0 100644 --- a/spec/session_spec.rb +++ b/spec/session_spec.rb @@ -482,6 +482,13 @@ shared_examples_for "session" do @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