Perform only selenium test if previous selenium test failed

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

  • Is there a way to run the 'it' block only if the previous failure or call to respond to a failed test?
  • Is there a better way to accomplish what I want to do does not include the 'it' block?

'It' block example

it "should load example.com" do
  page.open("http://example.com")
  page.wait_for_page_to_load(25)
end
+3
source share
1 answer

, , ...

  • , "it"

.

it "should load example.com" do
  begin
    page.open("http://example.com")
    page.wait_for_page_to_load(25)
    "wow".should == "cool"
  rescue Exception => e
    // code that responds to failed test
  end
end

  • , , ( !)
  • rspec ,
+1

Source: https://habr.com/ru/post/1784598/


All Articles