浏览代码

Fix #413 - WC3 webdriver standard changed timeout definitions.

George S. Baugh 7 年之前
父节点
当前提交
4049905717
共有 7 个文件被更改,包括 26 次插入17 次删除
  1. 2 1
      Changes
  2. 1 1
      at/sanity-chrome.test
  3. 3 3
      at/sanity-edge.test
  4. 1 1
      at/sanity.test
  5. 12 3
      lib/Selenium/Remote/Driver.pm
  6. 7 7
      t/01-driver.t
  7. 0 1
      t/Firefox-Profile.t

+ 2 - 1
Changes

@@ -1,8 +1,9 @@
 Revision history for Selenium-Remote-Driver
 
-1.31   XX-XX-XXXX TEODESIAN
+1.31   01-06-2019 TEODESIAN
         [BUG FIXES]
         - Kill dangling driver processes in Selenium::Chrome/Firefox on unix hosts
+        - Adjust set_timeout to WC3 standard changing out from under us
 
 1.30   09-17-2018 TEODESIAN
         [BUG FIXES]

+ 1 - 1
at/sanity-chrome.test

@@ -133,7 +133,7 @@ like($driver->upload_file($otherloc),qr/other.html$/,"upload_file fallback works
 
 #Jinkies, this stuff is cool, it prints the selenium server help page @_@
 like( exception { $driver->get_local_storage_item('whee') },qr/help/i,"get_local_storage_item prints help page");
-like( exception { $driver->delete_local_storage_item('whee') },qr/405/i,"get_local_storage_item prints help page");
+like( exception { $driver->delete_local_storage_item('whee') },qr/help/i,"get_local_storage_item prints help page");
 
 ok($driver->switch_to_frame($driver->find_element('frame', 'id')),"can switch to frame (WD3)");
 ok($driver->switch_to_frame(),"can switch to parent frame (WD3 only)");

+ 3 - 3
at/sanity-edge.test

@@ -45,7 +45,7 @@ SKIP: {
 
     $driver->set_async_script_timeout(20000);
     $driver->set_implicit_wait_timeout(5000);
-    my $timeouts = $driver->get_timeouts();
+    $timeouts = $driver->get_timeouts();
     is($timeouts->{script},20000,"WD3 shim for set_async timeouts works");
     is($timeouts->{implicit},5000,"WD3 shim for implicit timeouts works");
 }
@@ -135,8 +135,8 @@ like(exception { $driver->get_geolocation() }, qr/permission to ask/i, "get_geol
 ok($driver->get_log('server'), "get_log fallback works");
 ok( scalar(@{$driver->get_log_types()}),"can fallback for get_log_types");
 
-like(exception { $driver->set_orientation("LANDSCAPE") }, qr/not implemented/i, "set_orientation unimplemented in WD3");
-like(exception { $driver->get_orientation() }, qr/not implemented/i, "get_orientation unimplemented in WD3");
+like(exception { $driver->set_orientation("LANDSCAPE") }, qr/unknown command/i, "set_orientation unimplemented in WD3");
+like(exception { $driver->get_orientation() }, qr/unknown command/i, "get_orientation unimplemented in WD3");
 like($driver->upload_file($otherloc),qr/other.html$/,"upload_file fallback works");
 
 #Jinkies, this stuff is cool, it prints the selenium server help page @_@

+ 1 - 1
at/sanity.test

@@ -129,7 +129,7 @@ like($driver->upload_file($otherloc),qr/other.html$/,"upload_file fallback works
 
 #Jinkies, this stuff is cool, it prints the selenium server help page @_@
 like( exception { $driver->get_local_storage_item('whee') },qr/help/i,"get_local_storage_item prints help page");
-like( exception { $driver->delete_local_storage_item('whee') },qr/405/i,"get_local_storage_item prints help page");
+like( exception { $driver->delete_local_storage_item('whee') },qr/help/i,"get_local_storage_item prints help page");
 
 ok($driver->switch_to_frame($driver->find_element('frame', 'id')),"can switch to frame (WD3)");
 ok($driver->switch_to_frame(),"can switch to parent frame (WD3 only)");

+ 12 - 3
lib/Selenium/Remote/Driver.pm

@@ -1496,9 +1496,15 @@ sub set_timeout {
         croak "Expecting type";
     }
     $ms = _coerce_timeout_ms( $ms );
+    $type = 'pageLoad' if $type eq 'page load' && $self->browser_name ne 'MicrosoftEdge'; #XXX SHIM they changed the WC3 standard mid stream
 
     my $res = { 'command' => 'setTimeout' };
-    my $params = { 'type' => $type, 'ms' => $ms, $type => $ms };
+    my $params = { $type => $ms };
+    #XXX edge still follows earlier versions of the WC3 standard
+    if ($self->browser_name eq 'MicrosoftEdge') {
+        $params->{ms}   = $ms;
+        $params->{type} = $type;
+    }
     return $self->_execute_command( $res, $params );
 }
 
@@ -1520,8 +1526,10 @@ sub set_timeout {
 
 sub set_async_script_timeout {
     my ( $self, $ms ) = @_;
-    $ms = _coerce_timeout_ms( $ms );
 
+    return $self->set_timeout('script',$ms) if $self->{is_wd3};
+
+    $ms = _coerce_timeout_ms( $ms );
     my $res    = { 'command' => 'setAsyncScriptTimeout' };
     my $params = { 'ms'      => $ms };
     return $self->_execute_command( $res, $params );
@@ -1554,8 +1562,9 @@ sub set_async_script_timeout {
 
 sub set_implicit_wait_timeout {
     my ( $self, $ms ) = @_;
-    $ms = _coerce_timeout_ms( $ms );
+    return $self->set_timeout('implicit',$ms) if $self->{is_wd3};
 
+    $ms = _coerce_timeout_ms( $ms );
     my $res    = { 'command' => 'setImplicitWaitTimeout' };
     my $params = { 'ms'      => $ms };
     return $self->_execute_command( $res, $params );

+ 7 - 7
t/01-driver.t

@@ -165,7 +165,7 @@ IME: {
 
 LOAD_PAGE: {
     $driver->get("$website/index.html");
-    pass('Loaded home page');
+    note('Loaded home page');
     $ret = $driver->get_title();
     is($ret, 'Hello WebDriver', 'Got the title');
     $ret = $driver->get_current_url();
@@ -236,17 +236,17 @@ COOKIES: {
     $ret = $driver->get_all_cookies();
     is(@{$ret}, 2, 'Got 2 cookies');
     $ret = $driver->delete_all_cookies();
-    pass('Deleting cookies...');
+    note('Deleting cookies...');
     $ret = $driver->get_all_cookies();
     is(@{$ret}, 0, 'Deleted all cookies.');
     $driver->debug_on();
     $ret = $driver->add_cookie('foo', 'bar', '/', $domain, 0);
-    pass('Adding cookie foo...');
+    note('Adding cookie foo...');
     $ret = $driver->get_all_cookies();
     is(@{$ret}, 1, 'foo cookie added.');
     is($ret->[0]{'secure'}, 0, 'foo cookie insecure.');
     $ret = $driver->delete_cookie_named('foo');
-    pass('Deleting cookie foo...');
+    note('Deleting cookie foo...');
     $ret = $driver->get_all_cookies();
     is(@{$ret}, 0, 'foo cookie deleted.');
     $ret = $driver->delete_all_cookies();
@@ -256,15 +256,15 @@ MOVE: {
     $driver->get("$website/index.html");
     $driver->get("$website/formPage.html");
     $ret = $driver->go_back();
-    pass('Clicked Back...');
+    note('Clicked Back...');
     $ret = $driver->get_title();
     is($ret, 'Hello WebDriver', 'Got the right title');
     $ret = $driver->go_forward();
-    pass('Clicked Forward...');
+    note('Clicked Forward...');
     $ret = $driver->get_title();
     is($ret, 'We Leave From Here', 'Got the right title');
     $ret = $driver->refresh();
-    pass('Clicked Refresh...');
+    note('Clicked Refresh...');
     $ret = $driver->get_title();
     is($ret, 'We Leave From Here', 'Got the right title');
 }

+ 0 - 1
t/Firefox-Profile.t

@@ -73,7 +73,6 @@ CUSTOM_EXTENSION_LOADED: {
     # the preference 'browser.startup.homepage' isn't blocking, so we
     # need to wait until the page is loaded (when we can find
     # elements)
-    $driver->set_implicit_wait_timeout(30000);
     $driver->find_element("h1", "tag_name");
     cmp_ok($driver->get_current_url, '=~', qr/$domain/i,
            "profile loaded and preference respected!");