Răsfoiți Sursa

Fix #376: Allow opt-out for JSONWire emulation in WC3 methods

George S. Baugh 7 ani în urmă
părinte
comite
195f352c11
2 a modificat fișierele cu 19 adăugiri și 0 ștergeri
  1. 12 0
      lib/Selenium/Remote/Driver.pm
  2. 7 0
      lib/Selenium/Remote/WebElement.pm

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

@@ -194,6 +194,15 @@ One way of dealing with this is setting:
 
 Of course, this will prevent access of any new WC3 methods, but will probably make your tests pass until your browser's driver gets it's act together.
 
+There are also some JSONWire behaviors that we emulate in methods, such as Selenium::Remote::WebElement::get_attribute.
+You can get around that by passing an extra flag to the sub, or setting:
+
+    $driver->{emulate_jsonwire} = 0;
+
+When in WC3 Webdriver mode.
+
+=head2 WC3 WEBDRIVER CURRENT STATUS
+
 That said, the following 'sanity tests' in the at/ (acceptance test) directory of the module passed on the following versions:
 
 =over 4
@@ -986,6 +995,7 @@ sub _request_new_session {
     #Webdriver 3 - best guess that this is 'whats goin on'
     if ( ref $resp->{cmd_return} eq 'HASH' && $resp->{cmd_return}->{capabilities}) {
         $self->{is_wd3} = 1;
+        $self->{emulate_jsonwire} = 1;
         $self->{capabilities} = $resp->{cmd_return}->{capabilities};
     }
 
@@ -993,6 +1003,7 @@ sub _request_new_session {
     if ( ref $resp->{cmd_return} eq 'HASH' && $resp->{cmd_return}->{chrome}) {
         if (defined $resp->{cmd_return}->{setWindowRect}) { #XXX i'm inferring we are wd3 based on the presence of this
             $self->{is_wd3} = 1;
+            $self->{emulate_jsonwire} = 1;
             $self->{capabilities} = $resp->{cmd_return};
         }
     }
@@ -1000,6 +1011,7 @@ sub _request_new_session {
     #XXX unsurprisingly, neither does microsoft
     if ( ref $resp->{cmd_return} eq 'HASH' && $resp->{cmd_return}->{pageLoadStrategy} && $self->browser_name eq 'MicrosoftEdge') {
         $self->{is_wd3} = 1;
+        $self->{emulate_jsonwire} = 1;
         $self->{capabilities} = $resp->{cmd_return};
     }
 

+ 7 - 0
lib/Selenium/Remote/WebElement.pm

@@ -447,6 +447,9 @@ sub clear {
  Compatibility:
     In older webDriver, this actually got the value of an element's property.
     If you want to get the initial condition (e.g. the values in the tag hardcoded in HTML), pass 1 as the second argument.
+
+    Or, set $driver->{emulate_jsonwire} = 0 to not have to pass the extra arg.
+
     This can only done on WebDriver 3 enabled servers.
 
  Input: 2
@@ -469,6 +472,10 @@ sub get_attribute {
     if ( not defined $attr_name ) {
         croak 'Attribute name not provided';
     }
+
+    #Handle global JSONWire emulation flag
+    $no_i_really_mean_it = 1 unless $self->{driver}->{emulate_jsonwire};
+
     return $self->get_property($attr_name) if $self->driver->{is_wd3} && !(grep { $self->driver->browser_name eq $_ } qw{chrome MicrosoftEdge}) && !$no_i_really_mean_it;
 
     my $res = {