Selenium: wait_for_* and friends in Selenium RC ruby driver

谁说我不能喝 提交于 2019-12-10 23:26:46

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/211181/selenium-wait-for-and-friends-in-selenium-rc-ruby-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!