Jelajahi Sumber

Fix #370: do .form.submit() in submit polyfill

George S. Baugh 7 tahun lalu
induk
melakukan
af22494412
2 mengubah file dengan 6 tambahan dan 2 penghapusan
  1. 4 0
      Changes
  2. 2 2
      lib/Selenium/Remote/WebElement.pm

+ 4 - 0
Changes

@@ -1,5 +1,9 @@
 Revision history for Selenium-Remote-Driver
 
+1.25   02-15-2018 TEODESIAN
+        [BUG FIXES]
+        - Fix issue where only <form> elements and not <input> elements could be submit()ted.
+
 1.24   02-12-2018 TEODESIAN
         [BUG FIXES]
         - Fix issue where ID finder polyfills failed on IDs with dots (.) in them.

+ 2 - 2
lib/Selenium/Remote/WebElement.pm

@@ -134,7 +134,7 @@ sub click {
     that is a descendant of a FORM element.
 
  Compatibility:
-    On webdriver3 enabled servers, this uses a JS shim, which may not submit correctly depending on the element you are attempting to submit.
+    On webdriver3 enabled servers, this uses a JS shim, which WILL NOT submit correctly unless your element is an <input>.
     Try clicking it if possible instead.
 
  Usage:
@@ -144,7 +144,7 @@ sub click {
 
 sub submit {
     my ($self) = @_;
-    return $self->driver->execute_script("if (typeof arguments[0].submit === 'function') { return arguments[0].submit(); }; return 0;", {'element-6066-11e4-a52e-4f735466cecf'=> $self->{id}} ) if $self->driver->{is_wd3} && !(grep { $self->driver->browser_name eq $_ } qw{chrome MicrosoftEdge});
+    return $self->driver->execute_script("return arguments[0].form.submit();",{'element-6066-11e4-a52e-4f735466cecf'=> $self->{id}} ) if $self->driver->{is_wd3} && !(grep { $self->driver->browser_name eq $_ } qw{chrome MicrosoftEdge});
     my $res = { 'command' => 'submitElement', 'id' => $self->id };
     return $self->_execute_command($res);
 }