From: Robert Klemme Date: 2013-02-07T22:58:16+09:00 Subject: Re: how to skip lines whenever there is an error? On Thu, Feb 7, 2013 at 2:50 PM, Love U Ruby wrote: > Hi, > > I have the code below : > > > option.select_by(:text, value) > wbs.cells(rows,9).value = "Done" > rows = rows + 1 > count_dropdown = count_dropdown - 1 > > > Now sometimes I am getting an error as - > "(Selenium::WebDriver::Error::NoSuchElementError)" > > So I tried below : > > option.select_by(:text, value) > > rescue Selenium::WebDriver::Error::NoSuchElementError > > wbs.cells(rows,9).value = "Done" <~~ But I want this line to be skipped > whenever there is an error. > > rows = rows + 1 > count_dropdown = count_dropdown - 1 > > Please guide me how to do that? The typical way to handle that is begin rescue end: begin code which might raise an exception here rescue TheExceptionType => e handle error end Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/