Home > Mobile >  Selenium API is not working in Chrome browser
Selenium API is not working in Chrome browser

Time:08-19

I have created a basic Selenium Console App in C# that opens a URL, signs-in and does some activity.

The code is working fine in Dev VM, but the same code isn't working in Production VM. In Prod VM, the code just opens the URL (sign-in page) and it doesn't process anything.

I have googled and tried adding different options, but nothing worked.

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--incognito");
chromeOptions.AddArgument("no-sandbox");
chromeOptions.AddArgument("disable-infobars");
chromeOptions.AddArgument("--ignore-ssl-errors");
chromeOptions.AddArgument("--ignore-certificate-errors-spki-list");
chromeOptions.AcceptInsecureCertificates = true;
string path = @"local Chromedriver.exe(103.0.5060.134) path";
IWebDriver driver = new ChromeDriver(path, chromeOptions, TimeSpan.FromMinutes(2));
driver.Url = "url";

I have chromedriver 103.0.5060.134, the same as the version of the chrome browser. Not sure what else I have to check.

The main error is:

[67852:69648:0818/112450.083:ERROR:ssl_client_socket_impl.cc(996)] handshake failed; returned -1, SSL error code 1, net_error -101 

which is not happening in dev instance. This is what I get in Production: enter image description here

Chrome version enter image description here

UPDATE

I have updated Chrome driver to 104 version and chrome browser to 104.0.5112.102 but still getting same error. enter image description here

Updated Chrome version enter image description here

and I have the same driver version and chrome version in dev and it is working fine. Is there a way that I can get additional logs? Not sure why exactly failing in Production.

CodePudding user response:

To start with, this error message...

[67852:69648:0818/112450.083:ERROR:ssl_client_socket_impl.cc(996)] handshake failed; returned -1, SSL error code 1, net_error -101 

...implies that the handshake between ChromeDriver and Chrome Browser failed at some point.


Details

As per ERROR:ssl_client_socket_openssl.cc handshake failed the main issue is the failure of handshake when ChromeDriver handshakes with SSL pages in Chrome. Though Chromium team conducts test for SSL handshake through net_unittests, content_tests, and browser_tests but were not exhaustive. Some usecases are left out relying on the upstream tests.


Mandatory checks

Always ensure that:


Unwanted Arguments

It's not that super clear why you need to add so many arguments. However,

  • --incognito: Isn't necessary as ChromeDriver initiated sessions are sandboxed by default. So you can discard it.
  • --no-sandbox: Isn't needed unless your program crashes during startup being executed as a root user (administrator) on Linux. So you can remove it.
  • disable-infobars: It's no more effective. So you can discard it.
  • --ignore-certificate-errors-spki-list: Have no effect unless --user-data-dir argument is also present. So you can remove it.

Incorporating the above mentioned changes, you would be good to go.

  • Related