Authlogic - 硒问题

发布于 12-11 19:00 字数 1236 浏览 2 评论 0原文

我将黄瓜与水豚一起使用。当我使用 Capybara 的默认驱动程序时,我有一组运行正常的功能。现在我编写了一个需要硒的新功能(因为它涉及一个alert()框)。我安装了 selenium webdriver gem,并将 selenium 设置为我的默认驱动程序(目前,稍后我可能会将其更改为某些测试的驱动程序)。

现在,我的所有场景都失败了。所有这些都涉及让已经登录的用户做一些事情。事实证明,没有创建任何用户会话。我正在使用 Authlogic 进行身份验证。我高度怀疑 selenium webdriver 对此有罪,因为,正如我在一开始所说的,当我使用默认驱动程序时,一切都正常。

这是涉及创建立即进行身份验证的用户的步骤(如果从 User 模型创建用户,模型 acts_as_authenticatable,则该用户默认登录。无需创建新的 UserSession):

And I am logged in as "[email protected]", with password "12345" and school with subdomain "subdomain1"

这是该步骤的步骤定义:

Given /^I am logged in as "([^"]*)", with password "([^"]*)" and school with subdomain "([^"]*)"$/ do |email, password, domain|
  school = School.find_by_subdomain(domain)
  user = Factory.create(:user, :email => email, :password => password, :password_confirmation => password, :confirmed_email => true, :authenticatable => Factory.build(:employee, :school => school))
end

请注意,我从不显式创建 UserSession,只是创建用户即可为我完成此操作。请记住,这适用于机架测试驱动程序,但不适用于 Selenium。 Selenium 并不关心这个新创建的 UserSession。

你能帮助我吗?谢谢!

I'm using Cucumber with Capybara. I've got a set of feautures which are running ok when I use the default driver for Capybara. Now I've written a new feature which requires selenium (because it involves an alert() box). I installed the selenium webdriver gem, and I set selenium to be my default driver (for now, later I may change it to be the driver for some tests).

Now, all of my scenarios fail. All of them involve having an already logged user do some stuff. It turns out that no user session gets created. I'm using Authlogic for authentication. I highly suspect the selenium webdriver is guilty of this, because, as I've said in the beginning, when I use the default driver, everything turns out ok.

This is the step which involves creating a user which is authenticated inmediately (if one creates a user from the User model, model which acts_as_authenticatable, then that user get logged in by default. There's no need to create a new UserSession):

And I am logged in as "[email protected]", with password "12345" and school with subdomain "subdomain1"

This is the step definition for that step:

Given /^I am logged in as "([^"]*)", with password "([^"]*)" and school with subdomain "([^"]*)"$/ do |email, password, domain|
  school = School.find_by_subdomain(domain)
  user = Factory.create(:user, :email => email, :password => password, :password_confirmation => password, :confirmed_email => true, :authenticatable => Factory.build(:employee, :school => school))
end

Notice that I never create a UserSession explicitly, just creating the user does that for me. Remember, this works with the rack-test driver, but not with selenium. Selenium just doesn't care for this newly created UserSession.

Can you help me? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文