From 22f8727114fe7c93c867e98edc3351de36fe16c1 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 16 Dec 2009 15:16:52 +0100 Subject: [PATCH] return current_url for application (webdriver, culerity) --- lib/capybara/driver/base.rb | 4 ++++ lib/capybara/driver/culerity_driver.rb | 4 ++++ lib/capybara/driver/selenium_driver.rb | 4 ++++ lib/capybara/dsl.rb | 2 +- lib/capybara/session.rb | 4 ++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/capybara/driver/base.rb b/lib/capybara/driver/base.rb index ae551959..0cd078d1 100644 --- a/lib/capybara/driver/base.rb +++ b/lib/capybara/driver/base.rb @@ -1,4 +1,8 @@ class Capybara::Driver::Base + def current_url + raise "Not implemented" + end + def visit(path) raise "Not implemented" end diff --git a/lib/capybara/driver/culerity_driver.rb b/lib/capybara/driver/culerity_driver.rb index 9157a9f2..33152fd1 100644 --- a/lib/capybara/driver/culerity_driver.rb +++ b/lib/capybara/driver/culerity_driver.rb @@ -65,6 +65,10 @@ class Capybara::Driver::Culerity < Capybara::Driver::Base browser.html end + def current_url + browser.url + end + def find(selector) browser.elements_by_xpath(selector).map { |node| Node.new(self, node) } end diff --git a/lib/capybara/driver/selenium_driver.rb b/lib/capybara/driver/selenium_driver.rb index 5c65f8fe..b0f78a4b 100644 --- a/lib/capybara/driver/selenium_driver.rb +++ b/lib/capybara/driver/selenium_driver.rb @@ -76,6 +76,10 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base driver.page_source end + def current_url + driver.current_url + end + def find(selector) driver.find_elements(:xpath, selector).map { |node| Node.new(self, node) } end diff --git a/lib/capybara/dsl.rb b/lib/capybara/dsl.rb index 3703607c..962227e8 100644 --- a/lib/capybara/dsl.rb +++ b/lib/capybara/dsl.rb @@ -47,7 +47,7 @@ module Capybara end SESSION_METHODS = [ - :visit, :body, :click_link, :click_button, :drag, :fill_in, :choose, :has_xpath?, :has_css?, + :visit, :current_url, :body, :click_link, :click_button, :drag, :fill_in, :choose, :has_xpath?, :has_css?, :check, :uncheck, :attach_file, :select, :has_content?, :within, :within_fieldset, :within_table, :save_and_open_page, :find, :find_field, :find_link, :find_button, :field_labeled, :all, :wait_for, :evaluate_script, :click, :click_element diff --git a/lib/capybara/session.rb b/lib/capybara/session.rb index 213570d7..f74d6cdf 100644 --- a/lib/capybara/session.rb +++ b/lib/capybara/session.rb @@ -21,6 +21,10 @@ module Capybara end end + def current_url + driver.current_url + end + def visit(path) driver.visit(path) end