Cannot navigate to websites if a chrome window is already open with Selenium

I’m having an interesting issue that when a Chrome window is already open (via me just clicking the shortcut to open it in windows). Selenium seems to be unable to navigate to a website.

If I have no chrome windows open, selenium can navigate to websites just fine. Any idea whats going on?

WebDriver code:

        ChromeDriverService driverService = ChromeDriverService.CreateDefaultService();
        driverService.HideCommandPromptWindow = true;

        string path = Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%GoogleChromeUser Data");

        ChromeOptions options = new ChromeOptions();
        options.AddArguments("user-data-dir=" + path);
        options.AddArguments("--start-maximized");
        IWebDriver driver = new ChromeDriver(driverService, options);
        driver.Navigate().GoToUrl("https://www.google.com/");

It works fine if chrome is not already open, if chrome is open the driver will open a new window, and do nothing with it. My application just hangs.

Any ideas?


Source: .net

Leave a Reply