【问题标题】:Disable cookies for a cucumber test为黄瓜测试禁用 cookie
【发布时间】:2012-02-28 03:33:02
【问题描述】:

我希望能够执行以下操作:

@javascript @disallow_cookies
Scenario: Test Something that depends on cookies

我将如何编写 @disallow_cookies 黄瓜钩子来实现这一点?

我正在使用以下内容:

  • gem '薄','1.2.11'
  • gem 'cucumber-rails' , '1.0.4'
  • gem 'database_cleaner', '0.6.7'
  • gem '水豚','1.1.2'
  • gem 'capybara-firebug','0.0.10'
  • gem 'selenium-webdriver', '2.14.0'

谢谢!

【问题讨论】:

    标签: selenium cucumber capybara


    【解决方案1】:

    这是一个古老的问题,但在这里。为标签 @disallow_cookies 创建一个 before 钩子。

    Before('@disallow_cookies') do
        profile = Selenium::WebDriver::Firefox::Profile.new
        profile['network.cookie.cookieBehavior'] = 2 # disables all kind of cookies
    
        Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile) 
    end
    

    假设您在钩子之前创建了一般的驱动程序,您应该没问题。我还没有运行此代码,但它是我将开始该过程的地方。

    【讨论】:

      猜你喜欢
      • 2018-07-04
      • 2016-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-18
      • 2013-05-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多