0
我正在測試登臺服務器上的一項功能,該功能需要基本身份驗證才能訪問該站點。我得到了它運行使用下列內容:在Capybara驗證問題
Capybara.app_host = "http://user:[email protected]"
在方案中的一個點我訪問使用https而不是http,並要求我把在用戶名和密碼再次以繼續頁面。如果我只是再次訪問,這很容易,但我確實想點擊一個鏈接...
我怎麼能通過這個?我瘋狂搜索,但無法找到可行的解決方案。
我發現這個:http://theadmin.org/articles/test-http-basic-authentication-in-rails/,但我不知道如何實現它。我對這一切都很陌生,所以我可能會想念那些顯而易見的事物。
有人能指出我正確的方向嗎?
這裏是我的代碼:
env.rb
require 'capybara/cucumber'
Capybara.app_host = "https://user:[email protected]"
Capybara.default_driver = :selenium
Capybara.default_wait_time = 5
Capybara.ignore_hidden_elements = true
Capybara.current_session.driver.browser.manage.window.resize_to(1024, 1000)
checkout_steps.rb(有刪節)
Given /^I am on the main page$/ do
visit('/')
end
When /^I navigate to the page with the available boxes$/ do
page.find(:xpath, "//a[contains(@href,'how-it-works')]").click
page.find(:xpath, "//a[contains(@class,'join')]").click
end
When /^I choose a monthly subscription$/ do
page.find(:xpath, "//span[contains(@class,'title') and .[contains(., 'Unbefristetes Abo')]]").click
page.find_button("Jetzt Bestellen").click
end
嘗試將'Capybara.visit'''env.rb – 2013-02-27 18:54:07
@AndreyBotalov:我嘗試過,但我仍然得到相同的登錄對話框。這個建議背後有什麼想法? – TrashyMcTrash 2013-02-28 08:31:43
神奇的是,它適用於我的情況 – 2013-02-28 08:42:16