Explorar o código

Fix #283: die in Selenium::Waiter if you want to

George S. Baugh %!s(int64=5) %!d(string=hai) anos
pai
achega
6352a49528
Modificáronse 2 ficheiros con 8 adicións e 0 borrados
  1. 1 0
      Changes
  2. 7 0
      lib/Selenium/Waiter.pm

+ 1 - 0
Changes

@@ -3,6 +3,7 @@ Revision history for Selenium-Remote-Driver
 1.39  10-20-2020 TEODESIAN
 1.39  10-20-2020 TEODESIAN
         [NEW FEATURES]
         [NEW FEATURES]
         - Add execute_script and execute_async_script convenience methods to WebElements.
         - Add execute_script and execute_async_script convenience methods to WebElements.
+        - Add die flag to Selenium::Waiter
         [BUG FIXES]
         [BUG FIXES]
         - Fix a couple more documentation issues with driver specific problems
         - Fix a couple more documentation issues with driver specific problems
         [REMOVALS]
         [REMOVALS]

+ 7 - 0
lib/Selenium/Waiter.pm

@@ -65,6 +65,11 @@ to see the massacre:
     # carps: "kept from dying" once a second for thirty seconds
     # carps: "kept from dying" once a second for thirty seconds
     wait_until { die 'kept from dying' } debug => 1;
     wait_until { die 'kept from dying' } debug => 1;
 
 
+If you want to die anyways, just pass die => 1 to wait_until instead:
+
+    # Dies on the first failure, do your own error handling:
+    wait_until { die 'oops' } die => 1;
+
 =head4 Timeouts and Intervals
 =head4 Timeouts and Intervals
 
 
 You can also customize the timeout, and/or the retry interval between
 You can also customize the timeout, and/or the retry interval between
@@ -81,6 +86,7 @@ sub wait_until (&%) {
         timeout  => 30,
         timeout  => 30,
         interval => 1,
         interval => 1,
         debug    => 0,
         debug    => 0,
+        die      => 0,
         @_
         @_
     };
     };
 
 
@@ -99,6 +105,7 @@ sub wait_until (&%) {
         }
         }
         catch {
         catch {
             $exception = $_;
             $exception = $_;
+            die $_  if $args->{die};
             warn $_ if $args->{debug};
             warn $_ if $args->{debug};
             return '';
             return '';
         }
         }