On Thu, Feb 7, 2013 at 2:50 PM, Love U Ruby <lists / ruby-forum.com> 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/