views:

610

answers:

1

Are there any implementations of all the nifty Selenium on Rails methods like wait_for_visible, assert_not_text_present, ... for the ruby driver of Selenium RC?

If not, how would I go about implementing something like wait_for_visible?

+2  A: 

I solved my own problem.

I found the official ruby client at the Git Hub Repository

I wrote this solution so you can just require this code then you can use all the useful wait_for_*, assert_*, assert_not_*, wait_for_not_*, verify_*, and verify_not_* commands.

#need this for starts_with? and camelize
require 'activesupport'
module Selenium
  module Client
    class Driver
      def method_missing(method, *args)
        method_prefixes = %w(wait_for wait_for_not assert_ assert_not verify verify_not store)
        method_name = method.to_s

        prefix = method_prefixes.find {|pre| method_name.starts_with?(pre)}

        #if the method starts with a prefix, camelize the name.
        if(prefix)
          string_command method_name.camelize(:lower), *args
        else
          super *args
        end
      end
    end
  end
end
Daniel Beardsley