From 0fe3998f64954bb4c2ee4868f48aa11026986278 Mon Sep 17 00:00:00 2001 From: pivotal Date: Thu, 5 Mar 2009 18:03:39 -0800 Subject: [PATCH 01/17] field_named correctly delegated --- lib/webrat/core/methods.rb | 4 +++- lib/webrat/core/session.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/webrat/core/methods.rb b/lib/webrat/core/methods.rb index 87729bf..e3ce198 100644 --- a/lib/webrat/core/methods.rb +++ b/lib/webrat/core/methods.rb @@ -53,7 +53,9 @@ module Webrat :field_by_xpath, :field_with_id, :selenium, - :simulate, :automate + :simulate, :automate, + :field_named + diff --git a/lib/webrat/core/session.rb b/lib/webrat/core/session.rb index 7bec3df..2d59a93 100644 --- a/lib/webrat/core/session.rb +++ b/lib/webrat/core/session.rb @@ -256,6 +256,7 @@ For example: def_delegators :current_scope, :field_by_xpath def_delegators :current_scope, :field_with_id def_delegators :current_scope, :select_option + def_delegators :current_scope, :field_named private From e0bdab32366fba7f90ed86f1f16f3bd73d62f429 Mon Sep 17 00:00:00 2001 From: "mike.gaffney" Date: Thu, 28 May 2009 18:04:40 -0500 Subject: [PATCH 02/17] [#194 state:resolved] updated history --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index de6283f..31c229b 100644 --- a/History.txt +++ b/History.txt @@ -12,6 +12,7 @@ * 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) + * Added delegation for field_named lh194 (pivotal labs) == 0.4.4 / 2009-04-06 From c3f067b5510fe5d4d9571e9e7bc7372c7937bd21 Mon Sep 17 00:00:00 2001 From: "mike.gaffney" Date: Thu, 28 May 2009 18:05:28 -0500 Subject: [PATCH 03/17] added missing attribution --- History.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/History.txt b/History.txt index 31c229b..d22e374 100644 --- a/History.txt +++ b/History.txt @@ -11,7 +11,7 @@ * 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) + * Added ability to configure the browser startup timeout for selenium lh 242 (Mike Gaffney, Mark Dodwell) * Added delegation for field_named lh194 (pivotal labs) == 0.4.4 / 2009-04-06 From 627913708c563f136f17d7da1b85b961f20f143b Mon Sep 17 00:00:00 2001 From: Larry Diehl Date: Thu, 28 May 2009 22:40:52 -0700 Subject: [PATCH 04/17] Made Selenium Rails integration tests at least runnable, although there are failures. --- lib/webrat/selenium.rb | 8 +------- lib/webrat/selenium/silence_stream.rb | 20 +++++++++++-------- .../rails/test/integration/webrat_test.rb | 18 +++++++++++------ 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/webrat/selenium.rb b/lib/webrat/selenium.rb index 2564645..d47c583 100644 --- a/lib/webrat/selenium.rb +++ b/lib/webrat/selenium.rb @@ -1,13 +1,7 @@ require "webrat" gem "selenium-client", ">=1.2.14" 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/silence_stream" require "webrat/selenium/selenium_session" require "webrat/selenium/matchers" require "webrat/core_extensions/tcp_socket" diff --git a/lib/webrat/selenium/silence_stream.rb b/lib/webrat/selenium/silence_stream.rb index a458306..e1e6c74 100644 --- a/lib/webrat/selenium/silence_stream.rb +++ b/lib/webrat/selenium/silence_stream.rb @@ -1,14 +1,18 @@ 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) + # 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) + 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 -end \ No newline at end of file +end diff --git a/spec/integration/rails/test/integration/webrat_test.rb b/spec/integration/rails/test/integration/webrat_test.rb index b1449ca..f0d51a4 100644 --- a/spec/integration/rails/test/integration/webrat_test.rb +++ b/spec/integration/rails/test/integration/webrat_test.rb @@ -2,9 +2,12 @@ require 'test_helper' class WebratTest < ActionController::IntegrationTest - test "should visit fully qualified urls" do - visit root_url(:host => "chunkybacon.example.com") - assert_equal "chunkybacon", request.subdomains.first + # Firefox raises a security concern under Selenium + unless ENV['WEBRAT_INTEGRATION_MODE'] == 'selenium' + test "should visit fully qualified urls" do + visit root_url(:host => "chunkybacon.example.com") + assert_equal "chunkybacon", request.subdomains.first + end end test "should visit pages" do @@ -68,9 +71,12 @@ class WebratTest < ActionController::IntegrationTest assert_have_selector "h1" end - test "should detect infinite redirects" do - assert_raises Webrat::InfiniteRedirectError do - visit infinite_redirect_path + # Firefox detects and prevents infinite redirects under Selenium + unless ENV['WEBRAT_INTEGRATION_MODE'] == 'selenium' + test "should detect infinite redirects" do + assert_raises Webrat::InfiniteRedirectError do + visit infinite_redirect_path + end end end From 4d05a2cf2b2de34dda0a3e805ab11b60540578df Mon Sep 17 00:00:00 2001 From: Larry Diehl Date: Thu, 28 May 2009 23:23:09 -0700 Subject: [PATCH 05/17] click_link matches anchor id's with Selenium --- .../selenium/location_strategy_javascript/webratlink.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/webrat/selenium/location_strategy_javascript/webratlink.js b/lib/webrat/selenium/location_strategy_javascript/webratlink.js index ad71957..83b5355 100644 --- a/lib/webrat/selenium/location_strategy_javascript/webratlink.js +++ b/lib/webrat/selenium/location_strategy_javascript/webratlink.js @@ -1,6 +1,8 @@ var links = inDocument.getElementsByTagName('a'); var candidateLinks = $A(links).select(function(candidateLink) { - return PatternMatcher.matches(locator, getText(candidateLink)); + var textMatched = PatternMatcher.matches(locator, getText(candidateLink)); + var idMatched = PatternMatcher.matches(locator, candidateLink.id); + return textMatched || idMatched; }); if (candidateLinks.length == 0) { return null; From 846a90e561a086cee072dc0fc135e63197edbc58 Mon Sep 17 00:00:00 2001 From: Josh Lubaway Date: Fri, 29 May 2009 10:42:30 -0700 Subject: [PATCH 06/17] Passing TextField values as plaintext to Mechanize. Mechanize takes input as plaintext and escapes field values on its own. If the values are escaped before they are passed to Mechanize, the values will be escaped twice. These doubly-escaped values will result in incorrect behavior on the server side. --- lib/webrat/core/elements/field.rb | 2 ++ spec/private/core/field_spec.rb | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/webrat/core/elements/field.rb b/lib/webrat/core/elements/field.rb index 7eecc94..c887167 100644 --- a/lib/webrat/core/elements/field.rb +++ b/lib/webrat/core/elements/field.rb @@ -87,6 +87,8 @@ module Webrat parse_rails_request_params("#{name}=#{escaped_value}") when :merb ::Merb::Parse.query("#{name}=#{escaped_value}") + when :mechanize + { name => value } else { name => escaped_value } end diff --git a/spec/private/core/field_spec.rb b/spec/private/core/field_spec.rb index 90b6227..1e7f199 100644 --- a/spec/private/core/field_spec.rb +++ b/spec/private/core/field_spec.rb @@ -66,4 +66,20 @@ module Webrat radio_button.should_not be_checked end end + + describe TextField do + it 'should not escape values in mechanize mode' do + Webrat.configuration.mode = :mechanize + + html = <<-HTML + + + + HTML + + element = Webrat::XML.css_search(Webrat::XML.document(html), 'input').first + text_field = TextField.new(nil, element) + text_field.to_param.should == { 'email' => 'user@example.com' } + end + end end From 6fc6530a6b3a2f3c77300f57172c3a180431c389 Mon Sep 17 00:00:00 2001 From: "mike.gaffney" Date: Fri, 29 May 2009 16:36:46 -0500 Subject: [PATCH 07/17] [#256 state:resolved] Added attribution --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index d22e374..733afc5 100644 --- a/History.txt +++ b/History.txt @@ -13,6 +13,7 @@ * 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, Mark Dodwell) * Added delegation for field_named lh194 (pivotal labs) + * Added fix to keep from escaping field values in mechanize mode lh256 (jish) == 0.4.4 / 2009-04-06 From 73dc59cc293cfa6e343c6f167a352558abb75351 Mon Sep 17 00:00:00 2001 From: Matthias Marschall Date: Wed, 27 May 2009 14:02:09 +0200 Subject: [PATCH 08/17] click_button in selenium works now same as in headless mode --- .../location_strategy_javascript/button.js | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/webrat/selenium/location_strategy_javascript/button.js b/lib/webrat/selenium/location_strategy_javascript/button.js index add1679..1af6900 100644 --- a/lib/webrat/selenium/location_strategy_javascript/button.js +++ b/lib/webrat/selenium/location_strategy_javascript/button.js @@ -1,12 +1,19 @@ if (locator == '*') { return selenium.browserbot.locationStrategies['xpath'].call(this, "//input[@type='submit']", inDocument, inWindow) } +var buttons = inDocument.getElementsByTagName('button'); var inputs = inDocument.getElementsByTagName('input'); -return $A(inputs).find(function(candidate){ - inputType = candidate.getAttribute('type'); - if (inputType == 'submit' || inputType == 'image') { - var buttonText = $F(candidate); - return (PatternMatcher.matches(locator, buttonText)); - } - return false; +var result = $A(inputs).concat($A(buttons)).find(function(candidate){ + var type = candidate.getAttribute('type'); + if (type == 'submit' || type == 'image' || type == 'button') { + var matches_id = PatternMatcher.matches(locator, candidate.id); + var matches_value = PatternMatcher.matches(locator, candidate.value); + var matches_html = PatternMatcher.matches(locator, candidate.innerHTML); + var matches_alt = PatternMatcher.matches(locator, candidate.alt); + if (matches_id || matches_value || matches_html || matches_alt) { + return true; + } + } + return false; }); +return result; From 6cd734aec9c701e0b8db605ba32a895487c6f7ad Mon Sep 17 00:00:00 2001 From: Matthias Marschall Date: Fri, 29 May 2009 10:24:51 +0200 Subject: [PATCH 09/17] made selenium integration tests run applying larrytheliquid's patch: http://github.com/larrytheliquid/webrat/commit/627913708c563f136f17d7da1b85b961f20f143b --- lib/webrat/selenium.rb | 8 +------- lib/webrat/selenium/silence_stream.rb | 20 +++++++++++-------- .../rails/test/integration/webrat_test.rb | 18 +++++++++++------ 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/webrat/selenium.rb b/lib/webrat/selenium.rb index 2564645..d47c583 100644 --- a/lib/webrat/selenium.rb +++ b/lib/webrat/selenium.rb @@ -1,13 +1,7 @@ require "webrat" gem "selenium-client", ">=1.2.14" 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/silence_stream" require "webrat/selenium/selenium_session" require "webrat/selenium/matchers" require "webrat/core_extensions/tcp_socket" diff --git a/lib/webrat/selenium/silence_stream.rb b/lib/webrat/selenium/silence_stream.rb index a458306..f5e54d8 100644 --- a/lib/webrat/selenium/silence_stream.rb +++ b/lib/webrat/selenium/silence_stream.rb @@ -1,14 +1,18 @@ 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 + # 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) + 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 end \ No newline at end of file diff --git a/spec/integration/rails/test/integration/webrat_test.rb b/spec/integration/rails/test/integration/webrat_test.rb index b1449ca..9d858c6 100644 --- a/spec/integration/rails/test/integration/webrat_test.rb +++ b/spec/integration/rails/test/integration/webrat_test.rb @@ -2,9 +2,12 @@ require 'test_helper' class WebratTest < ActionController::IntegrationTest - test "should visit fully qualified urls" do - visit root_url(:host => "chunkybacon.example.com") - assert_equal "chunkybacon", request.subdomains.first + #Firefox raises a security concern under Selenium + unless ENV['WEBRAT_INTEGRATION_MODE'] == 'selenium' + test "should visit fully qualified urls" do + visit root_url(:host => "chunkybacon.example.com") + assert_equal "chunkybacon", request.subdomains.first + end end test "should visit pages" do @@ -68,9 +71,12 @@ class WebratTest < ActionController::IntegrationTest assert_have_selector "h1" end - test "should detect infinite redirects" do - assert_raises Webrat::InfiniteRedirectError do - visit infinite_redirect_path + # Firefox detects and prevents infinite redirects under Selenium + unless ENV['WEBRAT_INTEGRATION_MODE'] == 'selenium' + test "should detect infinite redirects" do + assert_raises Webrat::InfiniteRedirectError do + visit infinite_redirect_path + end end end From 9b85b6d7e04033021a37193f8e7bdb0cd6300a63 Mon Sep 17 00:00:00 2001 From: Matthias Marschall Date: Fri, 29 May 2009 12:07:10 +0200 Subject: [PATCH 10/17] added integration tests for all cases of click_button (by id, by html, by value, by alt for buttons and inputs of types image, button and submit) --- .../app/controllers/webrat_controller.rb | 3 + .../rails/app/views/webrat/buttons.html.erb | 11 +++ spec/integration/rails/config/routes.rb | 1 + .../test/integration/button_click_test.rb | 80 +++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 spec/integration/rails/app/views/webrat/buttons.html.erb create mode 100644 spec/integration/rails/test/integration/button_click_test.rb diff --git a/spec/integration/rails/app/controllers/webrat_controller.rb b/spec/integration/rails/app/controllers/webrat_controller.rb index b117ae8..e9f9ad4 100644 --- a/spec/integration/rails/app/controllers/webrat_controller.rb +++ b/spec/integration/rails/app/controllers/webrat_controller.rb @@ -9,6 +9,9 @@ class WebratController < ApplicationController def form end + def buttons + end + def submit render :text => "OK Test Link Text" end diff --git a/spec/integration/rails/app/views/webrat/buttons.html.erb b/spec/integration/rails/app/views/webrat/buttons.html.erb new file mode 100644 index 0000000..e127059 --- /dev/null +++ b/spec/integration/rails/app/views/webrat/buttons.html.erb @@ -0,0 +1,11 @@ +

Webrat Buttons Form

+ +<% form_tag submit_path do %> + + + + + + + +<% end %> \ No newline at end of file diff --git a/spec/integration/rails/config/routes.rb b/spec/integration/rails/config/routes.rb index ced0b4f..e330d3f 100644 --- a/spec/integration/rails/config/routes.rb +++ b/spec/integration/rails/config/routes.rb @@ -9,6 +9,7 @@ ActionController::Routing::Routes.draw do |map| webrat.redirect_to_show_params "/redirect_to_show_params", :action => "redirect_to_show_params" webrat.show_params "/show_params", :action => "show_params" + webrat.buttons "/buttons", :action => "buttons" webrat.root :action => "form" end end diff --git a/spec/integration/rails/test/integration/button_click_test.rb b/spec/integration/rails/test/integration/button_click_test.rb new file mode 100644 index 0000000..3cd0c6c --- /dev/null +++ b/spec/integration/rails/test/integration/button_click_test.rb @@ -0,0 +1,80 @@ +require 'test_helper' + +class ButtonClickTest < ActionController::IntegrationTest + # + + +<% end %> \ No newline at end of file diff --git a/spec/integration/rails/config/routes.rb b/spec/integration/rails/config/routes.rb index f3a66e6..f08763b 100644 --- a/spec/integration/rails/config/routes.rb +++ b/spec/integration/rails/config/routes.rb @@ -1,4 +1,6 @@ ActionController::Routing::Routes.draw do |map| + map.resource 'links', :only => [:show] + map.resource 'buttons', :only => [:show, :create] map.with_options :controller => "webrat" do |webrat| webrat.submit "/submit", :action => "submit" webrat.internal_redirect "/internal_redirect", :action => "internal_redirect" @@ -9,8 +11,6 @@ ActionController::Routing::Routes.draw do |map| webrat.redirect_to_show_params "/redirect_to_show_params", :action => "redirect_to_show_params" webrat.show_params "/show_params", :action => "show_params" - webrat.buttons "/buttons", :action => "buttons" webrat.root :action => "form" end - map.resource 'links' end diff --git a/spec/integration/rails/test/functional/buttons_controller_test.rb b/spec/integration/rails/test/functional/buttons_controller_test.rb new file mode 100644 index 0000000..e61daec --- /dev/null +++ b/spec/integration/rails/test/functional/buttons_controller_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class ButtonsControllerTest < ActionController::TestCase + # Replace this with your real tests. + test "the truth" do + assert true + end +end From 270460922469777ff0067e84dda0b7c22293fb08 Mon Sep 17 00:00:00 2001 From: "mike.gaffney" Date: Mon, 1 Jun 2009 12:26:37 -0500 Subject: [PATCH 15/17] added clicking link by title in selenium mode --- lib/webrat/selenium/location_strategy_javascript/webratlink.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/webrat/selenium/location_strategy_javascript/webratlink.js b/lib/webrat/selenium/location_strategy_javascript/webratlink.js index 83b5355..2a36308 100644 --- a/lib/webrat/selenium/location_strategy_javascript/webratlink.js +++ b/lib/webrat/selenium/location_strategy_javascript/webratlink.js @@ -2,7 +2,8 @@ var links = inDocument.getElementsByTagName('a'); var candidateLinks = $A(links).select(function(candidateLink) { var textMatched = PatternMatcher.matches(locator, getText(candidateLink)); var idMatched = PatternMatcher.matches(locator, candidateLink.id); - return textMatched || idMatched; + var titleMatched = PatternMatcher.matches(locator, candidateLink.title); + return textMatched || idMatched || titleMatched; }); if (candidateLinks.length == 0) { return null; From bd1655c8e26c9e1d4f86fda2b7c7fa2a7ffc1b16 Mon Sep 17 00:00:00 2001 From: "mike.gaffney" Date: Tue, 2 Jun 2009 17:23:12 -0500 Subject: [PATCH 16/17] [#257 state:awaiting-patch] here is a test proving the issue --- .../app/controllers/fields_controller.rb | 4 ++++ .../rails/app/helpers/fields_helper.rb | 2 ++ .../rails/app/views/fields/show.html.erb | 8 ++++++++ spec/integration/rails/config/routes.rb | 1 + .../functional/buttons_controller_test.rb | 8 -------- .../test/functional/links_controller_test.rb | 8 -------- .../rails/test/integration/fill_in_test.rb | 20 +++++++++++++++++++ 7 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 spec/integration/rails/app/controllers/fields_controller.rb create mode 100644 spec/integration/rails/app/helpers/fields_helper.rb create mode 100644 spec/integration/rails/app/views/fields/show.html.erb delete mode 100644 spec/integration/rails/test/functional/buttons_controller_test.rb delete mode 100644 spec/integration/rails/test/functional/links_controller_test.rb create mode 100644 spec/integration/rails/test/integration/fill_in_test.rb diff --git a/spec/integration/rails/app/controllers/fields_controller.rb b/spec/integration/rails/app/controllers/fields_controller.rb new file mode 100644 index 0000000..454f153 --- /dev/null +++ b/spec/integration/rails/app/controllers/fields_controller.rb @@ -0,0 +1,4 @@ +class FieldsController < ApplicationController + def show + end +end diff --git a/spec/integration/rails/app/helpers/fields_helper.rb b/spec/integration/rails/app/helpers/fields_helper.rb new file mode 100644 index 0000000..3be7aea --- /dev/null +++ b/spec/integration/rails/app/helpers/fields_helper.rb @@ -0,0 +1,2 @@ +module FieldsHelper +end diff --git a/spec/integration/rails/app/views/fields/show.html.erb b/spec/integration/rails/app/views/fields/show.html.erb new file mode 100644 index 0000000..afff7ad --- /dev/null +++ b/spec/integration/rails/app/views/fields/show.html.erb @@ -0,0 +1,8 @@ +

Webrat Fields Page

+

Filling In

+
    +
  • +
  • +
  • +
  • +
\ No newline at end of file diff --git a/spec/integration/rails/config/routes.rb b/spec/integration/rails/config/routes.rb index f08763b..43b55f7 100644 --- a/spec/integration/rails/config/routes.rb +++ b/spec/integration/rails/config/routes.rb @@ -1,6 +1,7 @@ ActionController::Routing::Routes.draw do |map| map.resource 'links', :only => [:show] map.resource 'buttons', :only => [:show, :create] + map.resource 'fields', :only => [:show] map.with_options :controller => "webrat" do |webrat| webrat.submit "/submit", :action => "submit" webrat.internal_redirect "/internal_redirect", :action => "internal_redirect" diff --git a/spec/integration/rails/test/functional/buttons_controller_test.rb b/spec/integration/rails/test/functional/buttons_controller_test.rb deleted file mode 100644 index e61daec..0000000 --- a/spec/integration/rails/test/functional/buttons_controller_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class ButtonsControllerTest < ActionController::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/spec/integration/rails/test/functional/links_controller_test.rb b/spec/integration/rails/test/functional/links_controller_test.rb deleted file mode 100644 index 688ee9f..0000000 --- a/spec/integration/rails/test/functional/links_controller_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class LinksControllerTest < ActionController::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/spec/integration/rails/test/integration/fill_in_test.rb b/spec/integration/rails/test/integration/fill_in_test.rb new file mode 100644 index 0000000..db116d9 --- /dev/null +++ b/spec/integration/rails/test/integration/fill_in_test.rb @@ -0,0 +1,20 @@ +require 'test_helper' + +class FillInTest < ActionController::IntegrationTest + test "should fill in text field by name" do + visit fields_path + fill_in "field_by_name", :with => "value" + end + test "should fill in text field by name, rails naming lh257" do + visit fields_path + fill_in "rails[naming]", :with => "value" + end + test "should fill in text field by id" do + visit fields_path + fill_in "field_by_id", :with => "value" + end + test "should fill in text field by label via id" do + visit fields_path + fill_in "FieldByLabelId", :with => "value" + end +end \ No newline at end of file From f8f254d517c9d63a57559da6917f66210e6aa1ed Mon Sep 17 00:00:00 2001 From: "mike.gaffney" Date: Tue, 2 Jun 2009 17:35:29 -0500 Subject: [PATCH 17/17] [#257 state:resolved] fixed issue with rails encodd fields in webrat --- lib/webrat/selenium/selenium_session.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webrat/selenium/selenium_session.rb b/lib/webrat/selenium/selenium_session.rb index 0130b5e..0fce80b 100644 --- a/lib/webrat/selenium/selenium_session.rb +++ b/lib/webrat/selenium/selenium_session.rb @@ -41,7 +41,7 @@ module Webrat webrat_deprecate :visits, :visit def fill_in(field_identifier, options) - locator = "webrat=#{Regexp.escape(field_identifier)}" + locator = "webrat=#{field_identifier}" selenium.wait_for_element locator, :timeout_in_seconds => 5 selenium.type(locator, "#{options[:with]}") end