2

Code

ChromeOptions options = new ChromeOptions();

options.AddArguments("--headless");
options.AddArguments("--disable-gpu");
options.AddArguments("--disable-software-rasterizer");
options.AddArguments("--user-data-dir=/profiles/" + profile);
options.AddArguments("--disable-software-rasterizer");
options.AddArguments("--window-size=1920x1080");
options.AddArguments("--disable-extensions");
options.AddArguments("--disable-plugins-discovery");

IWebDriver webDriver = new ChromeDriver(options);
WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(15));
webDriver.Navigate().GoToUrl(@"someUrl"); ---> Here code stucks

Error:

OpenQA.Selenium.WebDriverException: 'The HTTP request to the remote WebDriver server for URL http://localhost:64225/session timed out after 60 seconds.'

I also tried

options.AddArguments("--disable-dev-shm-usage");
options.AddArguments("--no-sandbox");

Console output

"A cookie associated with a cross-site resource at 
<SomeSite> was set without the `SameSite` attribute. 
A future release of Chrome will only deliver cookies 
with cross-site requests if they are set with 
`SameSite=None` and `Secure`. You can review cookies 
in developer tools under Application>Storage>Cookies 
and see more details at 
https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.", 
source: <someURL> (0)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Ennorath
  • 48
  • 1
  • 7

1 Answers1

1

This error message...

OpenQA.Selenium.WebDriverException: 'The HTTP request to the remote WebDriver server for URL http://localhost:64225/session timed out after 60 seconds.

...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session using the desired Chrome Profile.

As per the discussion in How to open a Chrome Profile through --user-data-dir argument of Selenium instead of specifying only the directory name through user-data-dir, you need to pass the absolute path of the user-data-dir.


Solution

So you need to replace the line of code:

options.add_argument("user-data-dir=bot_data")

With:

options.add_argument("user-data-dir=C:\\Users\\AtechM_03\\AppData\\Local\\Google\\Chrome\\User Data\\bot_data")

Reference

You can find a couple of relevant discussions in:


Outro

A couple of relevant documentations:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 3
    Thanks Very much!! The thing is that without --headless option, the application works with incorrect user-data-dir, how is it possible? Is it using default (coz the cookie really same)? It can be seen that you are professional in Selenium, could you look please on options, are all of them are necessary for headless chrome? no-sandbox, headless, disable-gpu, disable-dev-shm-usage I'm using it on windows. Really appreciate your answer – Ennorath Jul 14 '20 at 16:42