ruby-on-rails - Selenium:wait_for_* 和 Selenium RC ruby​​ 驱动程序中的 friend

标签 ruby-on-rails ruby unit-testing selenium integration-testing

是否有所有漂亮的Selenium on Rails的实现诸如 wait_for_visibleassert_not_text_present 等方法,用于 Selenium RC 的 ruby​​ 驱动程序

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

最佳答案

我解决了我自己的问题。

我在 Git Hub Repository 找到了官方 ruby​​ 客户端

我编写了这个解决方案,因此您只需require此代码,然后您就可以使用所有有用的wait_for_*、assert_*、assert_not_*、wait_for_not_*、verify_* 和 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

关于ruby-on-rails - Selenium:wait_for_* 和 Selenium RC ruby​​ 驱动程序中的 friend ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/211181/

相关文章:

ruby-on-rails - 微博评论用户页(Ruby on Rails)

ruby-on-rails - ActiveRecord 查询方法响应 - 需要除雾

ruby-on-rails - 如何将 "=>"Rails 运算符映射为 vim 中的快捷方式

ruby-on-rails - 创建 Rails gem

java - 在单元测试中模拟 RxJava 的 Activity 生命周期

c# - 仅可测试性就可以证明依赖注入(inject)的合理性吗?

ruby-on-rails - 如何在不执行 "update_attributes"的情况下执行 "before_save"?

Ruby 参数计数规则

Ruby - 使用 class_eval 定义方法

java - 使用 Mockito 链接模拟方法(尤其是 JPA TypedQuery)