代码之家  ›  专栏  ›  技术社区  ›  Daniel Beardsley

Selenium:在Seleniu RC ruby驱动程序中等待和朋友

  •  1
  • Daniel Beardsley  · 技术社区  · 16 年前

    所有这些漂亮的东西都有实现吗 Selenium on Rails wait_for_visible , assert_not_text_present , ... 对于 seleniumrc的ruby驱动程序 ?

    如果没有,我将如何实现像wait_for_visible这样的东西?

    1 回复  |  直到 16 年前
        1
  •  4
  •   codeConcussion    16 年前

    我解决了自己的问题。

    Git Hub Repository

    我写了这个解决方案,所以你可以 require wait_for_*, assert_*, assert_not_*, wait_for_not_*, verify_*, and verify_not_* 命令。

    #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