1

I recently upgraded to Selenium 3.14 from 3.9.1 . Now everytime I run, I am getting below error where I try to instantiate the webdriver. Below is the line where it fails and throws an expecption.

When I downgrade to 3.9.1 it works fine. Is there something I am missing? Has anyone see this before?

I am using c# + Spec flow + BrowserStack grid.

Please let me know if you need more information. This is my first post and have googled and researched but couldn't find any information regarding this error.

_driver = new RemoteWebDriver(new Uri("http://" + browserStackConfig["BSserver"] + "/wd/hub/"), capability,  new TimeSpan(0,0,30));


Result Message: 
OneTimeSetUp: OpenQA.Selenium.WebDriverException : A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://hub-cloud.browserstack.com/wd/hub/session. The status of the exception was ReceiveFailure, and the message was: The underlying connection was closed: An unexpected error occurred on a receive.
  ----> System.Net.WebException : The underlying connection was closed: An unexpected error occurred on a receive.
  ----> System.IO.IOException : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
  ----> System.Net.Sockets.SocketException : An existing connection was forcibly closed by the remote host
4
  • This is quite likely related to your HTTP request not using TLS 1.2. Can you explicitly force your client to use TLS 1.2 and rerun your tests? You may refer the following link: stackoverflow.com/questions/45382254/… Commented Sep 11, 2018 at 19:23
  • I tried to force the TLS 1.2. by adding below line to the code. I am still having the same issue. Unfortunaetly I cant upgrade to 4.6 .Net framework at this time. I am on 4.5.1 .Net Framework System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Commented Sep 11, 2018 at 20:56
  • Since you started seeing the error only after upgrading to the latest selenium client bindings, it is quite likely that the http library used by the client binding is not sending request that use TLS 1.2. You can determine the same using an intercepting tool like wireshark OR fiddler and open a ticket with Selenium on github OR browserstack based on your findings. Commented Sep 12, 2018 at 5:21
  • @BountyHunter - Thank you so much. I found out what was causing this issue.Posted the answer below. Commented Sep 13, 2018 at 19:21

1 Answer 1

2

Selenium made a change on Jul 25th to expose the Proxy property from HttpCommandExecutor class ( Below is the link) . You would expect that if no Proxy is passed then the Selenium would use Default Web Proxy. This is not the case. The proxy is being set to null which would cause the executor to fail while instantiating the driver.

https://github.com/SeleniumHQ/selenium/commit/52969e49a16efee7efb52893addde19605162a66#diff-bc8a75c5cb22ca86093a1bbced41a6ee

Fix: I made a simple change in my code to pass the default web proxy. Below is the code snippet. This fixed my issue.

 var executor = new HttpCommandExecutor(new Uri("http://" + browserStackConfig["BSserver"] + "/wd/hub/"), new TimeSpan(0, 0, 0, 30));
 executor.Proxy = WebRequest.DefaultWebProxy;
 _driver = new RemoteWebDriver(executor, capability);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.