Home > database >  selenium chromedriver won't connect to the given debug port c#
selenium chromedriver won't connect to the given debug port c#

Time:03-06

Iam using selenium to connect to an external application which is a cefsharp based browser(the browser app works fine) the problem is that i cannot set the debug port no matter what port i set. chromedriver.exe opens a port of its own choice and it does not even open my cefbased.exe browser. here is my code

        ChromeDriverService service = ChromeDriverService.CreateDefaultService();
        service.HideCommandPromptWindow = true;
        ChromeOptions options = new ChromeOptions();
        string hostname = "localhost";
        int portno = 12345;//just an example
        IPAddress ipa = (IPAddress)Dns.GetHostAddresses(hostname)[0];

        options.BinaryLocation = @"C:\Users\mr.315\source\repos\WindowsFormsApp3\WindowsFormsApp3\bin\x64\Debug\cefbased.exe";
        options.AddArgument("debuggerAddress=127.0.0.1:12345");
        options.AddArguments("remote-debugging-port=12345");
        options.DebuggerAddress = "127.0.0.1:"  portno.ToString();
        ChromeDriver driver = new ChromeDriver(service, options);
        driver.Navigate().GoToUrl("https://google.com");

if i remove the options.DebuggerAddress = "127.0.0.1:" portno.ToString(); it opens my cefbased.exe application yet chromedriver.exe has its own --port commandline argument(confirmed from task manager) and returns error after the 60sec timeout runs out. i came across a problem very similar to mine but the code is in ruby and i have no clue how to implement it in c# Chromedriver remote-debugging-port with Selenium

CodePudding user response:

I dunno if its a hack or a legit answer but i realized that while enabling the DebuggerAddress the exe in BinaryLocation won't be executed the only option is to execute it with a port(perhaps via command line) then launch the selenium.

  • Related