因此,我有一个Rails webapp,它利用子域来使用subdomain-fu将管理功能与公共功能分开。所以有一些功能(我想测试一下!)包含在两个urls中(例如admin.example.com和www.example.com)。我想在管理域上运行一些场景,而在www域上运行一些场景。
我的问题是,我不知道如何在启动后的任何时候更改selenium使用的域。我可以在我的env.rb中放入类似这样的内容:
Webrat.configure do |config|
config.mode = :selenium
config.application_address = "admin.example.com"
end它可以工作,但只适用于需要管理域的场景。如果我尝试像这样的东西:
host! "www.example.com"在我的步骤中,它似乎被selenium忽略了,它继续使用"admin.example.com“
有什么想法吗?或者,如果不可能,有什么解决办法吗?
发布于 2010-06-15 07:30:36
我在使用Webrat的时候没有做到这一点,但是在使用Cabybara的时候,下面的内容对我来说是有效的。
Given /^I visit subdomain "(.+)"$/ do |sub|
# host! "#{sub}.example.com" #for webrat
Capybara.default_host = "#{sub}.example.com" #for Rack::Test
Capybara.app_host = "http://#{sub}.example.com:9887" if Capybara.current_driver == :selenium
################################################################################
# As far as I know, you have to put all the {sub}.example.com entries that you're
# using in your /etc/hosts file for the Culerity tests. This didn't seem to be
# required for Rack::Test
################################################################################
end发布于 2010-04-28 15:36:07
我从来没有使用过webrat,但是在一个普通的测试中,如果你要把一个完整的路径而不是一个相对路径放在打开它的地方。
所以
selenium.open("http://foo/bar");将使测试转到完整的url。
https://stackoverflow.com/questions/2717911
复制相似问题