瀏覽代碼

Fix #418 : deal with chromedriver being broken out of the box

this is why we can't have nice things
George S. Baugh 6 年之前
父節點
當前提交
9b3ac65f89
共有 3 個文件被更改,包括 18 次插入1 次删除
  1. 5 0
      Changes
  2. 1 1
      dist.ini
  3. 12 0
      lib/Selenium/Remote/Driver.pm

+ 5 - 0
Changes

@@ -1,5 +1,10 @@
 Revision history for Selenium-Remote-Driver
 
+1.33   06-17-2019 TEODESIAN
+        [BUG FIXES]
+        - Add chrome shim to disable sandboxing by default so that Selenium::Chrome usage isn't broken by default
+        - Report failures to obtain sessions better
+
 1.32   06-12-2019 TEODESIAN
         [New Features]
         - Add support for mozilla full pags screenshots

+ 1 - 1
dist.ini

@@ -1,5 +1,5 @@
 name = Selenium-Remote-Driver
-version = 1.32
+version = 1.33
 author = George S. Baugh <george@troglodyne.net>
 author = Aditya Ivaturi <ivaturi@gmail.com>
 author = Daniel Gempesaw <gempesaw@gmail.com>

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

@@ -1023,6 +1023,14 @@ sub _request_new_session {
         }
     }
 
+    #Fix broken out of the box chrome because they hate the maintainers of their interfaces
+    if ( $self->isa('Selenium::Chrome') ) {
+        if ( exists $args->{desiredCapabilities} ) {
+            $args->{desiredCapabilities}{chromeOptions}{args} //= [];
+            push(@{$args->{desiredCapabilities}{chromeOptions}{args}}, qw{no-sandbox disable-dev-shm-usage});
+        }
+    }
+
     # Get actual status
     $self->remote_conn->check_status();
 
@@ -1037,6 +1045,10 @@ sub _request_new_session {
     my $rc = $self->remote_conn;
     my $resp = $rc->request( $resource_new_session, $args, );
 
+    if ( $resp->{cmd_status} && $resp->{cmd_status} eq 'NOT OK' ) {
+        croak "Could not obtain new session: ". $resp->{cmd_return}{message};
+    }
+
     if ( ( defined $resp->{'sessionId'} ) && $resp->{'sessionId'} ne '' ) {
         $self->session_id( $resp->{'sessionId'} );
     }