Single step and slow motion for Cucumber scenarios can come in handy, especially in @javascript
scenarios.
# features/support/examiners.rb
AfterStep('@slow_motion') do
sleep 2
end
AfterStep('@single_step') do
print "Single Stepping. Hit enter to continue"
STDIN.getc
end
If you're using
spreewald
Show archive.org snapshot
, these tags are available as @slow-motion
and @single-step
(with dashes instead of underscores).
Note: You can also prevent the selenium webbrowser window from closing after a failed @javascript step.
Fixing out-of-sync Cucumber output
The problem with the @slow_motion
step above is that the console output of Cucumber will always be one step behind the Selenium window. This is because the sleep is blocking the completion of the step.
To fix this, you can use this (much more verbose and performance-eating!) code:
Before('@slow_motion') do
@slow_motion = true
end
After('@slow_motion') do
@slow_motion = false
end
Transform /.*/ do |match|
if @slow_motion
sleep 1.5
end
match
end
Posted by Lexy to makandra dev (2011-10-07 07:31)