Merge branch 'master' of git://github.com/brynary/webrat
This commit is contained in:
commit
956b43d72c
|
@ -9,6 +9,9 @@
|
||||||
* Added support for field_labeled_locators ending in non word characters
|
* Added support for field_labeled_locators ending in non word characters
|
||||||
lh 148 (Zach Dennis)
|
lh 148 (Zach Dennis)
|
||||||
* Filled in tests on click link lh 195 (diabolo)
|
* Filled in tests on click link lh 195 (diabolo)
|
||||||
|
* Added current_url to selenium session lh 215 (Luke Amdor)
|
||||||
|
* Added silence spec to selenium lh 238 (Martin Gamsjaeger aka snusnu)
|
||||||
|
* Added ability to configure the browser startup timeout for selenium lh 242 (Mike Gaffney)
|
||||||
|
|
||||||
== 0.4.4 / 2009-04-06
|
== 0.4.4 / 2009-04-06
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,9 @@ module Webrat
|
||||||
|
|
||||||
# Set the key that Selenium uses to determine the browser running. Default *firefox
|
# Set the key that Selenium uses to determine the browser running. Default *firefox
|
||||||
attr_accessor :selenium_browser_key
|
attr_accessor :selenium_browser_key
|
||||||
|
|
||||||
|
# Set the timeout for waiting for the browser process to start
|
||||||
|
attr_accessor :selenium_browser_startup_timeout
|
||||||
|
|
||||||
# How many redirects to the same URL should be halted as an infinite redirect
|
# How many redirects to the same URL should be halted as an infinite redirect
|
||||||
# loop? Defaults to 10
|
# loop? Defaults to 10
|
||||||
|
@ -68,6 +71,7 @@ module Webrat
|
||||||
self.selenium_server_port = 4444
|
self.selenium_server_port = 4444
|
||||||
self.infinite_redirect_limit = 10
|
self.infinite_redirect_limit = 10
|
||||||
self.selenium_browser_key = '*firefox'
|
self.selenium_browser_key = '*firefox'
|
||||||
|
self.selenium_browser_startup_timeout = 5
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_with_nokogiri? #:nodoc:
|
def parse_with_nokogiri? #:nodoc:
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
require "webrat"
|
require "webrat"
|
||||||
gem "selenium-client", ">=1.2.14"
|
gem "selenium-client", ">=1.2.14"
|
||||||
require "selenium/client"
|
require "selenium/client"
|
||||||
|
|
||||||
|
# active_support already defines silence_stream, no need to do that again if it's already present.
|
||||||
|
# http://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/kernel/reporting.rb
|
||||||
|
unless Kernel.respond_to?(:silence_stream)
|
||||||
|
require "webrat/selenium/silence_stream"
|
||||||
|
end
|
||||||
|
|
||||||
require "webrat/selenium/selenium_session"
|
require "webrat/selenium/selenium_session"
|
||||||
require "webrat/selenium/matchers"
|
require "webrat/selenium/matchers"
|
||||||
require "webrat/core_extensions/tcp_socket"
|
require "webrat/core_extensions/tcp_socket"
|
||||||
|
|
|
@ -2,6 +2,8 @@ module Webrat
|
||||||
module Selenium
|
module Selenium
|
||||||
|
|
||||||
class ApplicationServer
|
class ApplicationServer
|
||||||
|
|
||||||
|
include Webrat::Selenium::SilenceStream
|
||||||
|
|
||||||
def self.boot
|
def self.boot
|
||||||
case Webrat.configuration.application_framework
|
case Webrat.configuration.application_framework
|
||||||
|
|
|
@ -2,6 +2,8 @@ module Webrat
|
||||||
module Selenium
|
module Selenium
|
||||||
|
|
||||||
class SeleniumRCServer
|
class SeleniumRCServer
|
||||||
|
|
||||||
|
include Webrat::Selenium::SilenceStream
|
||||||
|
|
||||||
def self.boot
|
def self.boot
|
||||||
new.boot
|
new.boot
|
||||||
|
@ -30,7 +32,9 @@ module Webrat
|
||||||
def remote_control
|
def remote_control
|
||||||
return @remote_control if @remote_control
|
return @remote_control if @remote_control
|
||||||
|
|
||||||
@remote_control = ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0", Webrat.configuration.selenium_server_port, 5)
|
@remote_control = ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0",
|
||||||
|
Webrat.configuration.selenium_server_port,
|
||||||
|
Webrat.configuration.selenium_browser_startup_timeout)
|
||||||
@remote_control.jar_file = jar_path
|
@remote_control.jar_file = jar_path
|
||||||
|
|
||||||
return @remote_control
|
return @remote_control
|
||||||
|
|
|
@ -22,6 +22,7 @@ module Webrat
|
||||||
|
|
||||||
class SeleniumSession
|
class SeleniumSession
|
||||||
include Webrat::SaveAndOpenPage
|
include Webrat::SaveAndOpenPage
|
||||||
|
include Webrat::Selenium::SilenceStream
|
||||||
|
|
||||||
def initialize(*args) # :nodoc:
|
def initialize(*args) # :nodoc:
|
||||||
end
|
end
|
||||||
|
@ -55,6 +56,10 @@ module Webrat
|
||||||
selenium.get_html_source
|
selenium.get_html_source
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_url
|
||||||
|
selenium.location
|
||||||
|
end
|
||||||
|
|
||||||
def click_button(button_text_or_regexp = nil, options = {})
|
def click_button(button_text_or_regexp = nil, options = {})
|
||||||
if button_text_or_regexp.is_a?(Hash) && options == {}
|
if button_text_or_regexp.is_a?(Hash) && options == {}
|
||||||
pattern, options = nil, button_text_or_regexp
|
pattern, options = nil, button_text_or_regexp
|
||||||
|
@ -182,15 +187,6 @@ module Webrat
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def silence_stream(stream)
|
|
||||||
old_stream = stream.dup
|
|
||||||
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
|
||||||
stream.sync = true
|
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
stream.reopen(old_stream)
|
|
||||||
end
|
|
||||||
|
|
||||||
def setup #:nodoc:
|
def setup #:nodoc:
|
||||||
Webrat::Selenium::SeleniumRCServer.boot
|
Webrat::Selenium::SeleniumRCServer.boot
|
||||||
Webrat::Selenium::ApplicationServer.boot
|
Webrat::Selenium::ApplicationServer.boot
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
module Webrat
|
||||||
|
module Selenium
|
||||||
|
module SilenceStream
|
||||||
|
def silence_stream(stream)
|
||||||
|
old_stream = stream.dup
|
||||||
|
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
||||||
|
stream.sync = true
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
stream.reopen(old_stream)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,6 +10,7 @@ class WebratTest < ActionController::IntegrationTest
|
||||||
test "should visit pages" do
|
test "should visit pages" do
|
||||||
visit root_path
|
visit root_path
|
||||||
assert_contain("Webrat Form")
|
assert_contain("Webrat Form")
|
||||||
|
assert URI.parse(current_url).path, root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should submit forms" do
|
test "should submit forms" do
|
||||||
|
|
|
@ -92,6 +92,15 @@ describe Webrat::Configuration do
|
||||||
it 'should default selenium browser key to *firefox' do
|
it 'should default selenium browser key to *firefox' do
|
||||||
@config.selenium_browser_key.should == '*firefox'
|
@config.selenium_browser_key.should == '*firefox'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should default selenium browser startup timeout to 5 seconds' do
|
||||||
|
@config.selenium_browser_startup_timeout.should == 5
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should allow overriding of the browser startup timeout' do
|
||||||
|
@config.selenium_browser_startup_timeout = 10
|
||||||
|
@config.selenium_browser_startup_timeout.should == 10
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue