in reply to Re^2: Error Handling in Selenium
in thread Error Handling in Selenium
Hi 9mohit2,
Your question is unclear because you don't say how your code is "not working" and what you would like your code to do. Also note that the better way to use eval is eval { ...; 1 } or do { print "Error: $@"; };, as explained in Bug in eval in pre-5.14.
In the code you showed, eval will trap any errors, such as from die, thrown by the code inside the eval, which you can then handle in any way you want. If you remove the eval, then an error in find_element should instead cause your script to die. If this is not happening, then perhaps the function is not throwing an error, or you have some other kind of error handling already in place.
On the other hand, if by "immediate error", you mean you want the code to throw an error, as you also seem to be saying in the OP, and find_element is not throwing an error, then you will have to inspect the return value of the function. One thing you could do is inspect it with Data::Dumper, to see what kind of values the function returns under various conditions, that should help you decide on the conditions in which you'd like to throw your own error.
In general it would be better if you could be more clear on what you mean with "not working", i.e. what the expected vs actual behavior is, with code examples. See I know what I mean. Why don't you? and How do I post a question effectively?
Hope this helps,
-- Hauke D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Error Handling in Selenium
by 9mohit2 (Sexton) on Nov 18, 2016 at 07:22 UTC | |
by Corion (Patriarch) on Nov 18, 2016 at 07:37 UTC | |
by soonix (Chancellor) on Nov 18, 2016 at 13:39 UTC | |
by haukex (Archbishop) on Nov 20, 2016 at 19:22 UTC | |
by 9mohit2 (Sexton) on Nov 21, 2016 at 06:44 UTC | |
by haukex (Archbishop) on Nov 21, 2016 at 16:54 UTC | |
by 9mohit2 (Sexton) on Nov 22, 2016 at 06:59 UTC | |
by Anonymous Monk on Nov 22, 2016 at 07:55 UTC |