瀏覽代碼

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

George S. Baugh 7 年之前
父節點
當前提交
195f352c11
共有 2 個文件被更改,包括 19 次插入0 次删除
  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.
 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:
 That said, the following 'sanity tests' in the at/ (acceptance test) directory of the module passed on the following versions:
 
 
 =over 4
 =over 4
@@ -986,6 +995,7 @@ sub _request_new_session {
     #Webdriver 3 - best guess that this is 'whats goin on'
     #Webdriver 3 - best guess that this is 'whats goin on'
     if ( ref $resp->{cmd_return} eq 'HASH' && $resp->{cmd_return}->{capabilities}) {
     if ( ref $resp->{cmd_return} eq 'HASH' && $resp->{cmd_return}->{capabilities}) {
         $self->{is_wd3} = 1;
         $self->{is_wd3} = 1;
+        $self->{emulate_jsonwire} = 1;
         $self->{capabilities} = $resp->{cmd_return}->{capabilities};
         $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 ( 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
         if (defined $resp->{cmd_return}->{setWindowRect}) { #XXX i'm inferring we are wd3 based on the presence of this
             $self->{is_wd3} = 1;
             $self->{is_wd3} = 1;
+            $self->{emulate_jsonwire} = 1;
             $self->{capabilities} = $resp->{cmd_return};
             $self->{capabilities} = $resp->{cmd_return};
         }
         }
     }
     }
@@ -1000,6 +1011,7 @@ sub _request_new_session {
     #XXX unsurprisingly, neither does microsoft
     #XXX unsurprisingly, neither does microsoft
     if ( ref $resp->{cmd_return} eq 'HASH' && $resp->{cmd_return}->{pageLoadStrategy} && $self->browser_name eq 'MicrosoftEdge') {
     if ( ref $resp->{cmd_return} eq 'HASH' && $resp->{cmd_return}->{pageLoadStrategy} && $self->browser_name eq 'MicrosoftEdge') {
         $self->{is_wd3} = 1;
         $self->{is_wd3} = 1;
+        $self->{emulate_jsonwire} = 1;
         $self->{capabilities} = $resp->{cmd_return};
         $self->{capabilities} = $resp->{cmd_return};
     }
     }
 
 

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

@@ -447,6 +447,9 @@ sub clear {
  Compatibility:
  Compatibility:
     In older webDriver, this actually got the value of an element's property.
     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.
     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.
     This can only done on WebDriver 3 enabled servers.
 
 
  Input: 2
  Input: 2
@@ -469,6 +472,10 @@ sub get_attribute {
     if ( not defined $attr_name ) {
     if ( not defined $attr_name ) {
         croak 'Attribute name not provided';
         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;
     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 = {
     my $res = {