Only run selenium test if previous selenium test fails

Posted by Mike Grace on Stack Overflow See other posts from Stack Overflow or by Mike Grace
Published on 2011-01-10T20:15:48Z Indexed on 2011/01/10 22:53 UTC
Read the original article Hit count: 500

Filed under:
|
|
|

I have several 'it' blocks in my selenium test file (using Ruby and rspec) that test various portions of my web application. Each 'it' block stops executing and goes to the next 'it' block if any of the conditions or code fails.

  • Is there a way to run an 'it' block only if the previous fails or call a function to react to the failed test?
  • Is there a better way to accomplish what I am wanting to do that doesn't involve an 'it' block?

Example 'it' block

it "should load example.com" do
  page.open("http://example.com")
  page.wait_for_page_to_load(25)
end

© Stack Overflow or respective owner

Related posts about ruby

Related posts about error-handling