代码之家  ›  专栏  ›  技术社区  ›  IDBD

如何在RubyonRails实现Selenium中使用警报和提示JS对话框?

  •  0
  • IDBD  · 技术社区  · 15 年前

    我现在在学硒。我将在RubyonRails项目中使用它。现在我创建了一个演示项目,只是为了测试铁轨上的硒元素。

    rails_u root/test/selenium/articles/delete_article.rsel的内容如下:

    setup :fixtures => :all
    
    open "/articles"
    
    assert_text_present("First Article title")
    assert_text_present("Destroy")
    
    click_and_wait("Destroy")
    assert_match /Are you sure/i, get_confirmation
    
    assert_text_present("Articles")
    assert_text_not_present("First Article title")
    

    在此测试运行期间,我得到以下错误:

    undefined local variable or method `get_confirmation' for #<SeleniumOnRails::RSelenese::Evaluator
    

    其他测试(没有对话框)工作正常,没有任何问题。

    有关配置的一些信息:

    • Ruby 1.8.7(2009-06-12补丁级别 174)[x86_-linux]
    • Rails 2.3.5
    • RuGuEMS 1.3.5
    • Selenium on Rails插件(版本38 是日志中最后提到的 changelog)从这里 http://svn.openqa.org/svn/selenium-on-rails/stable/selenium-on-rails
    • 没有遥控器。没有安装gems 与硒有关。
    • Linux HSH 2.6.31-17-通用54 Ubuntu SMP星期四12月10日17:01:44 UTC 2009 x86_ GNU/Linux
    • 火狐3.5.7

    有什么办法可以解决这个问题吗?

    谢谢

    1 回复  |  直到 15 年前
        1
  •  1
  •   St.Woland    15 年前

    试试这个:

    assert_alert /Are you sure/i
    

    或者:

    assert_confirmation /Are you sure/i
    

    更多在 SeleniumOnRails rdoc