这是我的测试,但是即使@timeout_exception在代码运行期间工作,它在测试期间也是空的。那么,如何测试是否设置了此变量呢?
Then(/^the output should be '(.*)'$/) do |expectedException|
expect(@timeout_exception).to eq(expectedException)
end这是包exec cucumber运行的输出。
And the output should be 'Execution Timeout Error: This deployment has taken too long to run' # features/step_definitions/my_steps.rb:309
expected: "Execution Timeout Error: This deployment has taken too long to run"
got: nil
(compared using ==)
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/my_steps.rb:310:in `/^the output should be '(.*)'$/'
features/timeout_lengthy_deploys.feature:25:in `And the output should be 'Execution Timeout Error: This deployment has taken too long to run''
Failing Scenarios:
cucumber features/timeout_lengthy_deploys.feature:11 # Scenario: Normal deploy that times out because it takes too long发布于 2016-04-27 21:06:42
Selenium有自己的等待时间,如果设置的等待时间少于预期的等待时间,那么您将永远不会看到预期的等待被触发。讲得通?
下面将页面加载的最大等待时间设置为5秒
@browser.driver.manage.timeouts.page_load = 5脚本超时是另一个原因(通常与Ajax一起使用)
@browser.driver.manage.timeouts.script_timeout = 5
@browser.execute_script("return jQuery.active")隐式等待是Selenium等待元素上的操作完成的最长等待时间。如果这首先触发,那么您的期望将失败。
@browser.driver.manage.timeouts.implicit_wait = 5我建议在测试之前将implicit_wait设置为比超时更高的值,然后在测试结束后将其设置回来。顺便说一句,如果你的超时引发了一个异常,你将需要一个救援块。
https://stackoverflow.com/questions/36888292
复制相似问题