【问题标题】:How to specify setup and teardown in Selenium On Rails?如何在 Selenium On Rails 中指定设置和拆卸?
【发布时间】:2010-11-08 23:08:39
【问题描述】:

我使用 Selenium On Rails 进行一些验收测试,但在大多数测试之前,我需要创建一些与固定装置相关联的二进制测试文件,并在每次测试之后 - 删除它们。 我不知道该怎么做。我正在搜索某种设置/拆卸功能,但找不到。

【问题讨论】:

    标签: ruby-on-rails testing selenium


    【解决方案1】:

    通常人们使用像Webrat 这样的验收测试框架并将其设置为使用selenium。要将 Webrat 配置为使用 selenium,您可以在 test_helper.rb 中进行设置:

    require "webrat"
    
    Webrat.configure do |config|
     config.mode = :selenium
    end
    

    然后我将在测试代码中定义我的设置和拆卸。您会对这种方法感兴趣吗?

    【讨论】:

    • 听起来很有希望... webrat 有内置 Selenium 还是我必须在 Rails 上保留 Selenium?
    • Webrat 的问题是我无法单击按钮(例如调用 javascript),因为它没有提供足够的方法...我可以将 Webrat 配置为使用 Selenium On Rails 方法吗?
    • 是的,您可以使用 Webrat 模仿 click_button 和 click_link。
    • 但是 Webrat 的 click_button 只看到提交按钮,这对我来说还不够。
    • 那么你需要模仿<button> 来实现ajax 函数吗?为什么不能使用提交按钮?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-27
    • 2021-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多