黄瓜+水豚+硒firefox打开example.com而不是我的应用程序

问题描述

| 我一直在使用Cucumber + Webrat,但需要额外的Rails 3兼容性和javascript测试,因此更改为capybara + selenium。目前,我使用的是Rails 3.0.7,Cucumber 0.10.2,caybara 1.0.0.beta1。 问题:运行javascript脚本时,firefox打开\“ http://www.iana.org/domains/example/ \”或\“ www.example.com \”而不是我的Rails应用程序。 我确定这只是我所缺少的一个小设置,但我找不到它,这让我难过了几天。 无论如何,我的gemfile读取:
group :development,:test do
  gem \'cucumber\'
  gem \'cucumber-rails\',\">= 0.3.2\"
  gem \'pickle\'
  gem \"launchy\"
  gem \"rspec-rails\"
  gem \"Selenium\"
  gem \"selenium-client\"
  gem \"selenium-webdriver\"
  gem \"database_cleaner\"
  gem \"factory_girl_rails\"
  gem \"capybara\"
  gem \"escape_utils\"
end
功能是:
  @wip
  @javascript
  Scenario: Calculate 1 recipe and be deducted a credit
    Given the following page records
      | name | permalink |
      | home | home      |
    And the following role records
      | name       |
      | SuperAdmin |
      | Admin      |
      | Customer   |
    When  I register \"adam\" with password \"password\"
    And I go to the index
    Then I should see \"5 credits\"
打开Firefox窗口的步骤:
    When /^I am logged in as \"([^\"]*)\" with password \"([^\"]*)\"$/ do |username,password|
  unless username.blank?
    visit(root_path)
    fill_in \"user_session_username\",:with => username
    fill_in \"user_session_password\",:with => password
    click_button \"login\"
    page.should have_content(\"Successfully logged in!\")
  end
end
我的功能/support/env.rb:
   require \'cucumber/rails\'
    require \'factory_girl\'
    require \'ruby-debug\'
    require \'selenium/client\'
    # require \'capybara/cucumber\' commented out because it doesn\'t want to work with it in
    Capybara.default_driver = :selenium

    Capybara.server_boot_timeout = 50
    Capybara.default_selector = :css

    begin
      DatabaseCleaner.strategy = :truncation
    rescue NameError
      raise \"You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it.\"
    end
命令提示符说:
    When I register \"adam\" with password \"password\"     # features/step_definiti
ons/web_steps.rb:229
      no link with title,id or text \'register\' found (Capybara::ElementNotFound
)
      (eval):2:in `click_link\'
      ./features/step_definitions/web_steps.rb:232:in `/^I register \"([^\"]*)\" wi
th password \"([^\"]*)\"$/\'
      features\\credit_behaviour.feature:30:in `When I register \"adam\" with passw
ord \"password\"\'
我对Rails和Ruby还是很陌生,所以请对我提出任何建议都很容易,说任何帮助将不胜感激。     

解决方法

好吧,让它正常工作。这就是我所做的。 env.rb添加:
require \"selenium-webdriver\"
并使用\'visit root_url \'将我的步骤更改为:
visit root_path
我认为这就是我所做的一切。 老实说,我已经尝试过了(以及我所见过的每个其他问题/修复程序的其他排列)。不敢相信我在此上浪费了三天,然后在公开发布问题几小时后才找到答案。     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...