15 Replies Last post: Mar 5, 2009 6:51 PM by Tapajos   1 2 Previous Next
Beginner 2 posts since
Sep 24, 2008
Currently Being Moderated

Sep 24, 2008 9:26 AM

Selenium Broken on Edge Rails (soon to be Rails 2.2)

Hi!

We are having issues upgrading to Rails Edge that we need for I18N support. The Selenium plugin works on Rails 2.1 but fails on edge rails with this stack trace:

 

NoMethodError (undefined method `call' for SeleniumOnRails::Selenese:Class):
    /vendor/rails/actionpack/lib/action_view/renderable.rb:21:in `_unmemoized_compiled_source'
    /vendor/rails/activesupport/lib/active_support/memoizable.rb:53:in `compiled_source'
    /vendor/rails/activesupport/lib/active_support/memoizable.rb:21:in `__send__'
    /vendor/rails/activesupport/lib/active_support/memoizable.rb:21:in `memoize_all'
    /vendor/rails/activesupport/lib/active_support/memoizable.rb:18:in `each'
    /vendor/rails/activesupport/lib/active_support/memoizable.rb:18:in `memoize_all'
    /vendor/rails/activesupport/lib/active_support/memoizable.rb:13:in `freeze'
    /vendor/rails/activesupport/lib/active_support/memoizable.rb:66:in `_pick_template'
    /vendor/rails/actionpack/lib/action_view/base.rb:266:in `render'
    /vendor/rails/actionpack/lib/action_controller/base.rb:1122:in `render_for_file'
    /vendor/rails/actionpack/lib/action_controller/base.rb:885:in `render_without_benchmark'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
    /vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
    /vendor/rails/actionpack/lib/action_controller/base.rb:933:in `render_to_string'
    /vendor/plugins/selenium_on_rails/selenium-on-rails/lib/selenium_on_rails/renderer.rb:7:in `render_test_case'
    /vendor/plugins/selenium_on_rails/selenium-on-rails/lib/controllers/selenium_controller.rb:24:in `test_file'
    /vendor/rails/actionpack/lib/action_controller/base.rb:1179:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:1179:in `perform_action_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /vendor/rails/actionpack/lib/action_controller/rescue.rb:202:in `perform_action_without_caching'
    /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in `cache'
    /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
    /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
    /vendor/rails/actionpack/lib/action_controller/base.rb:539:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:539:in `process_without_filters'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
    /vendor/rails/actionpack/lib/action_controller/base.rb:539:in `process_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
    /vendor/rails/actionpack/lib/action_controller/session_management.rb:134:in `process'
    /vendor/rails/actionpack/lib/action_controller/base.rb:403:in `process'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:151:in `handle_request'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:116:in `dispatch_cgi'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:33:in `dispatch'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:76:in `process'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:74:in `synchronize'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:74:in `process'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:159:in `process_client'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:158:in `each'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:158:in `process_client'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `initialize'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `new'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `initialize'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `new'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:282:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:281:in `each'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:281:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:128:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/command.rb:212:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:281
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:141:in `load_without_new_constant_marking'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:141:in `load'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:507:in `new_constants_in'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:141:in `load'
    /vendor/rails/railties/lib/commands/servers/mongrel.rb:64
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:148:in `require'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:507:in `new_constants_in'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:148:in `require'
    /vendor/rails/railties/lib/commands/server.rb:49
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require'
    ./script/server:3

I tried to debug this but got lost somewhere in the trenches of the Selenium plugin and the Rais templating engine and the interaction between the two. Can anyone shed a light on this or point me in a direction to investigate?

 

Thanks a lot!

 

Regards

 

Peter Marklund

http://marklunds.com

http://newsdesk.se

eric@8thlight.com Beginner 20 posts since
Apr 10, 2008
Currently Being Moderated
1. Sep 25, 2008 9:36 AM in response to: Peter Marklund
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

Recently I got everything working on Rails 2.1 (I'm not sure how you had it working before).

 

This error looks familiar.  Have you recently tried reinstalling from the version at http://svn.openqa.org/svn/selenium-on-rails/current/selenium-on-rails?

 

In the meantime I'll give this a try on edge rails, but I can't do it this instant so that might be faster.

 

Eric

eric@8thlight.com Beginner 20 posts since
Apr 10, 2008
Currently Being Moderated
3. Sep 25, 2008 9:54 AM in response to: Peter Marklund
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

Bummer - okay thanks.  It can be tricky for me to test against new 

versions of Rails - my current work is on Rails 2.0.2 and there are 

issues with setting the gems in our work environment.  All of which 

means I have to install Rails edge, then uninstall, so it might take 

me a couple days.

 

That error looks really familiar though.  I thought I fixed it.  

Hmmm.....

Beginner 1 posts since
Oct 13, 2008
Currently Being Moderated
4. Oct 13, 2008 5:36 AM in response to: eric@8thlight.com
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

Hi Eric,

 

I'm trying out Selenium on Rails 2.2.0, and getting the same error. Have you been able to recreate the error from your end?

 

Best,

Omar

Fridel Beginner 6 posts since
Nov 14, 2008
Currently Being Moderated
5. Nov 14, 2008 9:16 AM in response to: omar
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

Hello,

 

since I need to use Rails 2.2.0 the Selenium Tests don´t work anymore.

 

I got always the error

 

undefined method `call' for SeleniumOnRails::RSelenese:Class

when I open the Testrunner

http://localhost:3000/selenium/TestRunner.html?test=tests

Maybe anybody have an idea to fix this?

Greetings,
Fridel



eric@8thlight.com Beginner 20 posts since
Apr 10, 2008
Currently Being Moderated
6. Nov 14, 2008 9:30 AM in response to: Fridel
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

I haven't investigated the problems with Rails 2.2 yet, but since 2.2 

is getting released soon I will.

 

If anybody has a patch for 2.2 ready, please feel free to fork the 

github repo and let me know.

 

Eric

Beginner 2 posts since
Nov 26, 2008
Currently Being Moderated
7. Nov 26, 2008 10:21 AM in response to: eric@8thlight.com
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

Following patch works for me on Rails 2.2.2 . I am using .rsel for writing test cases

Only i get one problem. I can't add method inside .rsel file , it throws "`render': can't modify frozen class"  error.

 

diff --git a/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb b/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb
index 85814c1..63637fd 100755
--- a/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb
+++ b/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb
@@ -20,8 +20,8 @@ class SeleniumOnRails::RSelenese < SeleniumOnRails::TestBuilder
   end

   # Render _template_ using _local_assigns_.
-  def render template
-    local_assigns = template.locals
+  def render template, local_assigns
+    #local_assigns = template.locals
     title = (@view.assigns['page_title'] or local_assigns['page_title'])
     table(title) do
       test = self #to enable test.command
@@ -29,11 +29,15 @@ class SeleniumOnRails::RSelenese < SeleniumOnRails::TestBuilder
       assign_locals_code = ''
       local_assigns.each_key {|key| assign_locals_code << "#{key} = local_assigns[#{key.inspect}];"}

-      eval assign_locals_code + "\n" + template.source
+      eval assign_locals_code + "\n" + template.source     
     end
   end
  
   def compilable?
     false
   end

+  def self.call(template)
+    "#{name}.new(self).render(template, local_assigns)"
+  end
end
diff --git a/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_actions.rb b/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_
index dfdc005..306e01c 100755
--- a/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_actions.rb
+++ b/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_actions.rb
@@ -503,9 +503,7 @@ private
   def self.generate_and_wait_actions
     public_instance_methods.each do |method|
       define_method method + '_and_wait' do |*args|
-        make_command_waiting do
-          send method, *args
-        end
+        send 'command_and_wait', method, *args       
       end
     end
   end
diff --git a/vendor/plugins/selenium-on-rails/test/rselenese_test.rb b/vendor/plugins/selenium-on-rails/test/rselenese_test.rb
index 7f44f17..6f3d3bb 100755
--- a/vendor/plugins/selenium-on-rails/test/rselenese_test.rb
+++ b/vendor/plugins/selenium-on-rails/test/rselenese_test.rb
@@ -11,7 +11,7 @@ class RSeleneseTest < Test::Unit::TestCase
       File.open(path, 'w+') do |index_file|
         index_file << input
       end
-      view.render_template ActionView::Template.new(view, path, false, locals = {})
+      ActionView::Template.new(path).render_template(view, locals = {})
     end
   end

Beginner 2 posts since
Nov 26, 2008
Currently Being Moderated
8. Nov 27, 2008 12:24 AM in response to: Sujoy Kumar Roy
Re: Selenium Broken on Rails 2.2.2

I found that the reason that I can not define method in .rsel files is that Rails is freezing the SeleniumOnRails::RSelenese class. After few tries I found that when you freeze a ruby Class, it doesn't freeze classes defined inside that frozen class. Try this ruby snippet and check.

 

class A
  def f1; p "f1";end
  def f2(script);eval script;end
 
  class B
   def f2(script);eval script;end  
  end
end
A.freeze
a = A::B.new
a.f2(%q{def f3()
  p "B::f3"
end})
a.f3

 

a = A.new
a.f2(%q{def f3()
  p "A::f3"
end})

 

So I went aread and modified the render instance method and it works (at least as per as rselenese is concerned). Below is the modified patch (seems pretty ugly )

diff --git a/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb b/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb
index 85814c1..7618c88 100755
--- a/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb
+++ b/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb
@@ -20,20 +20,31 @@ class SeleniumOnRails::RSelenese < SeleniumOnRails::TestBuilder
   end

   # Render _template_ using _local_assigns_.
-  def render template
-    local_assigns = template.locals
+  def render template, local_assigns
+    #local_assigns = template.locals
     title = (@view.assigns['page_title'] or local_assigns['page_title'])
-    table(title) do
-      test = self #to enable test.command
-
-      assign_locals_code = ''
-      local_assigns.each_key {|key| assign_locals_code << "#{key} = local_assigns[#{key.inspect}];"}
-
-      eval assign_locals_code + "\n" + template.source
-    end
+   
+    assign_locals_code = ''
+    local_assigns.each_key {|key| assign_locals_code << "#{key} = local_assigns[#{key.inspect}];"}
+     
+    evaluator = Evaluator.new(@view)
+    evaluator.run_script title, assign_locals_code + "\n" + template.source   
   end
  
   def compilable?
     false
   end

+  def self.call(template)
+    "#{name}.new(self).render(template, local_assigns)"
+  end

+  class Evaluator < SeleniumOnRails::TestBuilder
+    def run_script(title, script)
+      table(title) do
+        test = self #to enable test.command
+        eval script
+      end 
+    end
+  end
end
diff --git a/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_actions.rb b/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_
index dfdc005..306e01c 100755
--- a/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_actions.rb
+++ b/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_actions.rb
@@ -503,9 +503,7 @@ private
   def self.generate_and_wait_actions
     public_instance_methods.each do |method|
       define_method method + '_and_wait' do |*args|
-        make_command_waiting do
-          send method, *args
-        end
+        send 'command_and_wait', method, *args       
       end
     end
   end
diff --git a/vendor/plugins/selenium-on-rails/test/rselenese_test.rb b/vendor/plugins/selenium-on-rails/test/rselenese_test.rb
index 7f44f17..6f3d3bb 100755
--- a/vendor/plugins/selenium-on-rails/test/rselenese_test.rb
+++ b/vendor/plugins/selenium-on-rails/test/rselenese_test.rb
@@ -11,7 +11,7 @@ class RSeleneseTest < Test::Unit::TestCase
       File.open(path, 'w+') do |index_file|
         index_file << input
       end
-      view.render_template ActionView::Template.new(view, path, false, locals = {})
+      ActionView::Template.new(path).render_template(view, locals = {})
     end
   end

 

 


Hope this will help to make this great test framework even greater and somebody will come up with the patch for .sel too.

eric@8thlight.com Beginner 20 posts since
Apr 10, 2008
Currently Being Moderated
9. Nov 28, 2008 6:29 PM in response to: Sujoy Kumar Roy
Re: Selenium Broken on Rails 2.2.2

I'm working on incorporating Sujoy's patches, which have similar implementations in Selenese.  It's taking a bit longer than I'd hoped because of the tests but it will be up as soon as possible.

 

I don't know why my email response didn't go through to this list, but thanks Sujoy for your contributions.

Eric

Beginner 8 posts since
Dec 3, 2008
Currently Being Moderated
10. Dec 4, 2008 9:23 AM in response to: Sujoy Kumar Roy
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

Is it possible to get Sujoy's patch? Would be very glad to run my tests under the current version

eric@8thlight.com Beginner 20 posts since
Apr 10, 2008
Currently Being Moderated
11. Dec 4, 2008 9:45 AM in response to: Anton Trapp
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

Anton ( and anybody else) the patch has been deployed here:

 

http://github.com/paytonrules/selenium-on-rails/

 

I'll release it to the official repo when I've given it a thorough workup, but it passes all tests.

Beginner 8 posts since
Dec 3, 2008
Currently Being Moderated
12. Dec 4, 2008 9:55 AM in response to: eric@8thlight.com
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

Thank you! That's great!

Beginner 1 posts since
Dec 16, 2008
Currently Being Moderated
13. Dec 16, 2008 11:31 AM in response to: Peter Marklund
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

I haven't dug into this code yet, but it seems like the latest code at http://github.com/paytonrules/selenium-on-rails/tree/master as of Dec 16 didn't have the send part of the patch applied to it.  But I needed to do it to get it to work over here on our rails app with 2.2.  The part about:

 

  def self.generate_and_wait_actions

    public_instance_methods.each do |method|

      define_method method + '_and_wait' do |*args|

        # make_command_waiting do

        #   send method, *args

        # end

        send 'command_and_wait', method, *args       

      end

    end

  end

 

 

Any reason why that wasn't patched too?

eric@8thlight.com Beginner 20 posts since
Apr 10, 2008
Currently Being Moderated
14. Dec 17, 2008 8:51 AM in response to: Nathan Kontny
Re: Selenium Broken on Edge Rails (soon to be Rails 2.2)

The pull request I got didn't have any tests with it, so I had to 

further investigate it before putting it into trunk.  When I do 

release SOR officially I'm going to announce a patch policy.

 

If you want me to pull your patch, it has to have Unit Tests.  I'm 

mean no disrespect to anybody who has done any hard work on a patch, 

but because my name is on this I can't in good conscience release it 

untested.  Which means when somebody sends me a patch that doesn't 

have them then I've got to try and make it work within the tests, 

which already aren't the way I'd like them, and frankly it's a real 

pain in the butt and prevents me from having time to get good features 

done.

 

That's a pretty long-winded way of putting it.  So you have that, and 

my newborn daughter to blame.   She doesn't have a SOR schedule yet

 

Eric

More Like This

  • Retrieving data ...