testing - perl selenium: Test::Exception, proper usage and good code example? -


In the Selenium IDE, the code template installed by the Pearl driver / format contains
 .  

Use "post-text" itemprop = "text">

test :: exceptions;

Test :: Exception should be used in all my files?

So far, I did not use any method of it and my tests are still running fine (I usually Khus- path test).

Now I've come up with a possible use I noted that selenium object sometimes dies, if you do not get the page or if there Loketetr wrong, etc. In many cases I want to continue my tests, i.e. selenium should not die, and continue to work on one page.

Can this be a fair use of a test :: exception method? Will I try: Trying to combine it with Tiny?

Here's a little helpful method that I've written. Life_ and Method Test :: falls under exception.

  sub-verification_text_key {my ($ sel, $ text) = @_; # $ Cell - selenium object # $ text || = 'I think'; # Some text I am searching for the page to life (sub $ {$ my $ found = $ sel- & gt; get_text ( "// p [This (text (), '$ text')"); Qr / $ Text /}}, "$ 'text' 'on page" has been found); }   

Edit - (question is still raised unanswered is I method slightly, so it can be more robust): < / P>

  sub_check_text_key {my ($ sel, $ text) = @_; # My $ text = 'as is unstriting, des'; Found my $$; Life_and (sub {try $ $ found = $ sel- & gt; get_text ( "// p [contains (text (), '$ text')]"};} catch {fail ( " '$ text' can not be found Is: $ _); $ found = 0; note "on page". $ Sel-> get_location (). ",". $ Sel- & gt; receive_title ();}; Skip: {skip "search there is no use "$ text" to 1 until $ not found (eg, received $, qr / $ text /); # or $ sel- & (gt; as) ??}}, " On page you have been seen for '$ text')}}    

Do not combine, because it's catching up for you. Simple display:

  Use Test: Use more: Test :: Exceptions; Lives_and {not_throwing (), "42"} 'Passing Test'; Life_ and {Throwing (), "42"} 'Failed Test'; Done_testing; sub not_throwing {42} sub throwing {die "unsuccessful"}   

So I'll use it as my first snippet. You can also consider using it, whatever more There is a light weight approach.

Comments