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? Thanks
on 2013-02-07 14:50
on 2013-02-07 14:59
On Thu, Feb 7, 2013 at 2:50 PM, Love U Ruby <lists@ruby-forum.com> wrote: > > 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
on 2013-02-07 15:17
Robert Klemme wrote in post #1095743: > On Thu, Feb 7, 2013 at 2:50 PM, Love U Ruby <lists@ruby-forum.com> > wrote: >> >> 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 I think you missed my point. Thanks
on 2013-02-07 15:34
Love U Ruby wrote in post #1095742: > Hi, > > I have the code below : > > begin option.select_by(:text, value) wbs.cells(rows,9).value = "Done" <~~~~ Found the resolutions here rescue Selenium::WebDriver::Error::NoSuchElementError end #print "nothing" rows = rows + 1 count_dropdown = count_dropdown - 1
on 2013-02-07 15:58
On Thu, Feb 7, 2013 at 3:34 PM, Love U Ruby <lists@ruby-forum.com> wrote: > rescue Selenium::WebDriver::Error::NoSuchElementError > > end > > #print "nothing" > > rows = rows + 1 > count_dropdown = count_dropdown - 1 And now where exactly did I miss your point? This is what I suggested. Cheers robert
on 2013-02-07 16:11
Robert Klemme wrote in post #1095764: > On Thu, Feb 7, 2013 at 3:34 PM, Love U Ruby <lists@ruby-forum.com> > wrote: >> rescue Selenium::WebDriver::Error::NoSuchElementError >> >> end >> >> #print "nothing" >> >> rows = rows + 1 >> count_dropdown = count_dropdown - 1 :) I couldn't read your code well, as it was folded within it. Thanks
on 2013-02-07 17:37
You need to slow down and read everything more carefully. A lot more of your problems will solve themselves that way.
on 2013-02-07 22:27
Another construct here: begin option.select_by(:text, value) rescue Selenium::WebDriver::Error::NoSuchElementError p "do nothing" else wbs.cells(rows,9).value = "Done" <~~~~ Found the resolutions here end #print "nothing" rows = rows + 1 count_dropdown = count_dropdown - 1
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.