9

Using .NET's C#:

I was thrilled to learn how to start a web driver session with your local cookie data here.

The browser now starts with my bookmarks and cookies loaded (I tested accessing sites that require authorization, to which I have already logged in in the past and saved the credentials).

However, for some reason, my web driver instance will not respond to a simple GoToUrl(). In fact, the command prompt is always reporting about the session timing out after 60 seconds.

What is interesting, nevertheless, is that the following code will work if I simply suppress the line that adds the cookie path argument. (I have done lots of stuff with ChromeDrive already).

    ChromeOptions options = new ChromeOptions();
    options.AddArgument(string.Format("user-data-dir={0}", "C:/Users/Me/AppData/Local/Google/Chrome/User Data"));

    IWebDriver wd = new ChromeDriver(options);

    wd.Navigate().GoToUrl("http://www.google.com");

I tried other ChromeDriver overloads, such as the one that uses a ChromeDriverService, to no avail.

My chromedriver.exe obviously exists in D:/ (otherwise I would get a different error message).

What's wrong ?

6

After further research, come across the following links:

https://github.com/SeleniumHQ/selenium/issues/886

https://code.google.com/p/chromedriver/issues/detail?id=962

http://peter.sh/experiments/chromium-command-line-switches/

https://sites.google.com/a/chromium.org/chromedriver/capabilities

Although I did not see any definitive conclusion, someone hinted that the problem occurs when there is another chrome instance already open. I then made sure this does not happen - and now my webdriver instance opens with the desired profile and works.

As far as I understand, seems this is a expected behavior - you cannot have two instances running the very same profile. You may ask, then, how come I can run multiple web driver instances with no problem ? Well, this happens because instantiating a webdriver object - without specifying a specific profile - creates a temporary one. So all instances one opens run on different profiles.

  • Hello.. I have the same exact issue as you mentioned. I need to run multiple web driver instances with same shared session. I didn't quite get what you said in the last line about different profiles.. can you please explain? – RKodakandla Sep 2 '17 at 17:50
  • 1
    You cannot have 2 instances running the same profile. But if you try to run multiple instances of web drivers, without specifying a profile, will work. Why ? Because when you do not specify one, a temporary (and apparently unique) one is created, and therefore no 2 instances are asked to run with the same profile - therefore you have no exception in the case of running multiple instances without specifying a profile. – Veverke Sep 3 '17 at 8:33
  • Okk.. but that's not an option for me.. if I don't specify one, the temporary profile that's created doesn't share the session. That's my main constraint. I need 10 webdriver instances to run with same authentication as the client's IDP doesnt allow multiple simultaneous logins. As soon as one is created, other one logs out. – RKodakandla Sep 3 '17 at 18:01
  • Well, my problem - and which my answer tried to explain - was that I was not succeeding in simply running a web browser with a profile. Loading the profile worked, but the web driver would not navigate anywhere. I then figured out that it was because I was firing several instances of web driver and trying to have all of them load the same profile. Doing it with a single instance only works for running a web driver instance that loads a chrome profile, which was the problem I was trying to solve. – Veverke Sep 4 '17 at 9:08
  • You are seeking how to run multiple web driver instances with the same profile. I have not tried to solve that. – Veverke Sep 4 '17 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.