ruby-on-rails-4 - 使用 Rails 4 的 cucumber 测试抛出错误 : element is not attached to the page document

标签 ruby-on-rails-4 selenium cucumber capybara

bundle exec cucumber features/products.feature

使用此命令我正在运行我的产品功能 cucumber 测试 对于所有场景,但在一个场景执行后会抛出错误

Given I am an authenticated user #features/step_definitions/login.rb:37
stale element reference: element is not attached to the page document
    (Session info: chrome=46.0.2490.80)
    (Driver info: chromedriver=2.13.307650 (feffe1dd547ee7b5c16d38784cd0cd679dfd7850),platform=Mac OS X 10.8.5 x86_64) (Selenium::WebDriver::Error::StaleElementReferenceError)

用于身份验证。但是,如果我一个一个地运行它就会成功。请帮助如何在异常情况下同时运行所有场景。

最佳答案

如果您在页面上寻找尚未加载或过期的元素,则会出现此错误,因为 dom 在上一步中已更改。确保当您批量运行测试用例时,每个用例都应该与其他用例隔离。如果没有添加额外的步骤以确保它加载到那里,您应该检查您想要交互的元素是否在页面上。

关于ruby-on-rails-4 - 使用 Rails 4 的 cucumber 测试抛出错误 : element is not attached to the page document,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33434182/

相关文章:

ruby-on-rails-4 - Rails 4 使用 JBuilder 使用自定义键构建 JSON

ruby - Selenium IDE 并告诉它记录操作

android - Cucumber 测试未按指定顺序运行,出了什么问题?

javascript - 简单的 cucumber.js + zombie 测试失败

ruby-on-rails - 制作 Rails 应用程序多语言的最佳实践

ruby-on-rails - 如何在routes.rb中添加别名

api - Rails 4 葡萄 API ActionController::RoutingError

java - 如何在 Eclipse 中使用 Selenium 路径从日历弹出窗口中选择日期

java - 尽管有 --no-sandbox 选项,Chromedriver 不会以 root 身份运行

Java、Cucumber 和 Selenium : Problems with navigate(). to()