【问题标题】:Selenium: wait_for_* and friends in Selenium RC ruby driverSelenium:wait_for_* 和 Selenium RC ruby​​ 驱动程序中的朋友
【发布时间】:2008-10-17 05:47:49
【问题描述】:

对于 Selenium RC 的 ruby​​ 驱动程序,是否有所有漂亮的 Selenium on Rails 方法的实现,例如 wait_for_visible、assert_not_text_present、...?

如果没有,我将如何实施类似 wait_for_visible 的东西?

【问题讨论】:

  • 看起来好像 Selenium RC 服务器已设置为处理所有命令(即,对于每个方法 selenium 服务器命令 getFoo,还有 assertFoo、verifyFoo waitForFoo waitForNotFoo,...)并非所有这些命令已进入服务器附带的 selenium.rb。

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


【解决方案1】:

我解决了我自己的问题。

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

我编写了这个解决方案,因此您可以只使用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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-23
    • 2014-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-21
    • 1970-01-01
    相关资源
    最近更新 更多