webdriverio / selenium-standalone

A Node.js based package and CLI library for launching Selenium with WebDrivers support (Chrome, Firefox, IE, Edge)
https://webdriver.io
Other
909 stars 222 forks source link

Failed to download selenium and/or chromedriver: Error: Could not download https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz #431

Closed MatUrbanski closed 3 years ago

MatUrbanski commented 5 years ago

Hey,

I'm unable to instal selenium-standalone on CircleCi. This is what I get:

selenium-standalone installation starting
----------

---
selenium install:
from: https://selenium-release.storage.googleapis.com/3.12/selenium-server-standalone-3.12.0.jar
to: /root/circleci-dashboard/public/node_modules/selenium-standalone/.selenium/selenium-server/3.12.0-server.jar
---
chrome install:
from: https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip
to: /root/circleci-dashboard/public/node_modules/selenium-standalone/.selenium/chromedriver/2.43-x64-chromedriver
---
firefox install:
from: https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz
to: /root/circleci-dashboard/public/node_modules/selenium-standalone/.selenium/geckodriver/0.23.0-x64-geckodriver
Failed to download selenium and/or chromedriver: Error: Could not download https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz
    at Request.<anonymous> (/root/circleci-dashboard/public/node_modules/selenium-standalone/lib/install.js:373:21)
    at Request.emit (events.js:182:13)
    at Request.onRequestResponse (/root/circleci-dashboard/public/node_modules/request/request.js:1066:10)
    at ClientRequest.emit (events.js:182:13)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
    at TLSSocket.socketOnData (_http_client.js:442:20)
    at TLSSocket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
selenium-standalone will attempt to re-download next time it is run.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

It was working fine in the past. How can I fix that?

lnaia commented 5 years ago

The line in question, 373, shows you the code that is running:

function getDownloadStream(downloadUrl, cb) {
    var r = request(downloadUrl, requestOpts)
      .on('response', function(res) {
        startedRequests += 1;

        if (res.statusCode !== 200) {
          return cb(new Error('Could not download ' + downloadUrl));
        }

        res.on('data', function(chunk) {
          progress += chunk.length;
          updateProgressPercentage(chunk.length);
        });

        total += parseInt(res.headers['content-length'], 10);

        cb(null, res);
      })
      .once('error', function(error) {
        cb(new Error('Could not download ' + downloadUrl + ': ' + error));
      });

    // initiate request
    r.end();
  }

Specifically, it expects status to be 200, or crash. If you try the URL manually in a local terminal, you will notice that it returns a 302 [see bellow], and the current code in selenium is not following up with the URL redirection sent by the server, so it crashes. It seems to me, like it this function code, would need to be updated to follow up 302 redirects; solving the problem now, and in future similar situations.

*   Trying 192.30.253.113...
* TCP_NODELAY set
* Connected to github.com (192.30.253.113) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [108 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [3085 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: businessCategory=Private Organization; jurisdictionC=US; jurisdictionST=Delaware; serialNumber=5157550; C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=github.com
*  start date: May  8 00:00:00 2018 GMT
*  expire date: Jun  3 12:00:00 2020 GMT
*  subjectAltName: host "github.com" matched cert's "github.com"
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Extended Validation Server CA
*  SSL certificate verify ok.
} [5 bytes data]
> GET /mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz HTTP/1.1
> Host: github.com
> User-Agent: curl/7.52.1
> Accept: */*
> 
{ [5 bytes data]
< HTTP/1.1 302 Found
< Server: GitHub.com
< Date: Fri, 29 Mar 2019 12:27:13 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Status: 302 Found
< Vary: X-PJAX
< Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/25354393/6ec7f500-c7e0-11e8-8c0f-77179f969aef?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190329%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190329T122713Z&X-Amz-Expires=300&X-Amz-Signature=2bfb422e83c233d32143976281729c045ca47f352abde9789521ef5efdfc9ab4&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dgeckodriver-v0.23.0-linux64.tar.gz&response-content-type=application%2Foctet-stream
< Cache-Control: no-cache
< Set-Cookie: has_recent_activity=1; path=/; expires=Fri, 29 Mar 2019 13:27:13 -0000
< Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Tue, 29 Mar 2039 12:27:13 -0000; secure; HttpOnly
< Set-Cookie: _gh_sess=bHdIRE9qd3pzS3ZHay9Pb2pjUEt5c296emZ1WVU0SVliUWtkbEZJZitWN08ySmtmbTE0anI5ZEJHM2hvUmRVbDU1V1N3djNYTWtVa3pWR1R1My9NRkxXOTR3Kys5ZU9oQjFyeTk1VFRQQVp5VWJGRFBwbUg1WnU1K1BDUzR5LzUxWXljNXhKWUNxSG9QV3VVWVhpQ1pheFhrNDVZV1Q1L3FaSHVSVGRKWWxIMkE0cm9QaHBsMW4zTVliVDRvLzlMbGw0K2syNExwS2ZPSEVYR2gxWnI5QT09LS11WTJpaVZoR2VBcE5kTmpURThIWjN3PT0%3D--ef3ba42cd2c10381c14446ab4e23eed7dee3b899; path=/; secure; HttpOnly
{ [5 bytes data]
< X-Request-Id: 2b62624d-baa6-4d05-80d4-f2fb928c5c2f
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< X-Frame-Options: deny
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Expect-CT: max-age=2592000, report-uri="https://api.github.com/_private/browser/errors"
< Content-Security-Policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; connect-src 'self' uploads.github.com www.githubstatus.com collector.githubapp.com api.github.com www.google-analytics.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com wss://live.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com; frame-ancestors 'none'; frame-src render.githubusercontent.com; img-src 'self' data: github.githubassets.com identicons.github.com collector.githubapp.com github-cloud.s3.amazonaws.com *.githubusercontent.com; manifest-src 'self'; media-src 'none'; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com
< X-GitHub-Request-Id: 9E92:748C:38338:68D19:5C9E0F21
< 
{ [173 bytes data]
* Curl_http_done: called premature == 0
* Connection #0 to host github.com left intact
root@box:~# 
mgrybyk commented 3 years ago

Please try with the latest version of the package, works fine in Circle CI https://github.com/mgrybyk/wdio-jasmine-boilerplate/blob/master/.circleci/config.yml

Make sure you have nodejs and java in your image.