ruby - Stop `until`-loop when condition is met -
i want make sure following test can't stuck in infinite loop. make loop run amount of times.
when /^i click settings link$/ footer = @browser.div(:id, 'iwinbottombar') footer.wait_until_present unless footer.html.include?('settings') throw exception.new("expected see settings button not there") end until @browser.div(:id, 'dialogcontainer').div(:class, 'settings_browsebutton button clickable').present? footer.a(:class, 'button_settings').when_present.click end end
but i'm not sure how limit code that. think need counter, i'm not sure how implement it.
if got correctly, want while
/until
maximum times of retries:
10.times break if condition_met? do_whatever end
Comments
Post a Comment