2

I am using:

  • chromedriver=2.26.436362
  • Chrome Version 55.0.2883.87 m (64-bit)
  • .Net C# 4.6.1 / Visual Studio 2015 Community Edition

I am seeing the following exception during website testing (this is my log4net entry):

FATAL2017-01-09 05:03:10 – no such session
  (Driver info: chromedriver=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64)
FATAL2017-01-09 05:03:10 –    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScriptCommand(String script, String commandName, Object[] args)
   at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScript(String script, Object[] args)

I start my driver session like this:

        var options = new ChromeOptions();
        options.AddArguments("test-type");          
        options.AddArgument("incognito"); // works
        options.AddArgument("--disable-bundled-ppapi-flash"); // works! this turns off shockwave
        options.AddArgument("--disable-extensions"); // works
        options.AddArguments("--start-fullscreen");
        var driver = new ChromeDriver(options);
        driver.Manage().Cookies.DeleteAllCookies();
        return driver;

And I navigate to a "new" tab in Chrome with the following command:

lock (Session.Driver)
{                
    JavaScriptExecutor jscript = Session.Driver as IJavaScriptExecutor;
    jscript.ExecuteScript(string.Format("window.open('{0}', '_blank');", url));
}

Which works in DEBUG 100% of the time. In RELEASE mode, I receive the error above. Which makes this a difficult problem to resolve...no debugger.

I have checked and the session is active, and at the point of entry two handles in Driver.WindowHandles corresponding to the tabs in Chrome are available. I have resorted to Console.Writeline() statements to view variables that I would normally diagnose in the watch window in visual studio debug mode.

I have been unable to reproduce this exception while debugging. It always "works" during debugging.

There are 5-10 other SO posts about the same issue. The answers to those questions involved updating the chromedriver.exe (I have the latest, and also tried older versions), or, are working with a different technology stack. There must be something else going on here.

Notes:

  1. I can reproduce this error every time in RELEASE mode. However in DEBUG mode it works every time (no error).
  2. I tried downgrading to chrome32_53.0.2785.116 (I uninstalled version 54) - same results no improvement.
  3. I checked which chrome driver I'm using for DEBUG: it is exactly the same chromedriver.exe used during RELEASE. (this leads me to conclude that neither Chrome, nor the Chrome driver, are the culprit).
sapbucket
  • 6,795
  • 15
  • 57
  • 94

2 Answers2

1

I discovered that I had to remove "optimize code" setting from Project->Properties->Build->(Release Configuration)->uncheck "optimize code".

I do not know why the "optimize code" setting would cause this issue.

I cannot claim credit. I followed the instructions at this SO post for the solution. See Josh Berke's post.

Community
  • 1
  • 1
sapbucket
  • 6,795
  • 15
  • 57
  • 94
0

Found same error when running ChromeDriver in multithreading.

Try to add:

ChromeOptions chromeOptions = new ChromeOptions();
.....
chromeOptions.AddArgument("--disable-impl-side-painting"); //it worked for me
.....
var tmp = new ChromeDriver(service, chromeOptions);
AlexK11
  • 21
  • 1
  • So, what does your code snippet do? Does it fix the mentioned error? – Alex Jul 18 '17 at 20:17
  • I found it on google resource, when peoples are talking about this issue. You need to add this argument when starting new ChromeDriver instance. And also you need to check up profiles files, where they are. If you will try to run another thread in already used profile path - it will bring to exception. So i've fixed that issue with these 2 steps. Add argument to my options, and deleting profile path. And try to check if there are some instances of chrome is still using you profile path. – AlexK11 Jul 18 '17 at 21:23