Why does my Cucumber test fail when run with Selenium?

后端 未结 2 357
礼貌的吻别
礼貌的吻别 2021-01-14 17:25

I am testing a Rails 3 app with a Cucumber/Capybara combo. I am also trying to use Selenium to test some JavaScript specific scenarios but am running into weird difficulties

相关标签:
2条回答
  • 2021-01-14 18:05

    I presume you are trying to use transactional fixtures (the default behavior) with Selenium, but that won't work. The transaction that is managed within the test is out of scope when the browser invokes the Rails app separately, so it can't see any of the uncommitted data that your test has created.

    Instead of transactional fixtures, you'll need to use one of the database cleaner gems.

    https://github.com/bmabey/database_cleaner

    Edit:

    I subsequently became aware that it is possible to use transactional fixtures with Selenium tests, and performance is better if you do (credit to Kira Corina's answer). See http://pastie.org/1745020 for details.

    0 讨论(0)
  • 2021-01-14 18:13

    For those who have the same issue with database in selenium tests, here is a really useful chat with three basic solutions summarized by Jonas (see the first April, 5th message): https://groups.google.com/forum/#!msg/ruby-capybara/JI6JrirL9gM/R6YiXj4gi_UJ

    0 讨论(0)
提交回复
热议问题