After do |scenario|
if scenario.failed?
Dir::mkdir('screenshots') if not File.directory?('screenshots')
screenshot = "./screenshots/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png"
@browser.driver.save_screenshot(screenshot)
embed screenshot, 'image/png'
end
@browser.close
end
But it will create the file but nothing gets populated, and this exception comes up:
No connection could be made because the target machine actively refused it. - connect(2)
Well I pinpointed the error - it's the fact that the browser is closed before I made the call to take the screenshot. Put the browser close in a finally (ensure) block to make sure it's closed off.
Friday, 2 November 2012
Ruby/Watir/Cucumber: Taking a screenshot error: No connection could be made because the target machine actively refused it. - connect(2)
I was tasked with investigating a framework that lets QAs and Devs work together so we can get a functional test suite up. One of the tasks is to ensure we can capture screenshots on error so we can troubleshoot it. Here's my original code:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment