0

I am testing a CEF app which is already launched so I am trying to attach to it using the DebuggerAddress option.

  • Browser: Microsoft Edge 107.0.1418.24
  • Driver: msedgedriver 107.0.1418.24

EdgeOptions used:

EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.DebuggerAddress = "localhost:9222";
edgeOptions.AddArguments("window-size=1680x1050");
edgeOptions.AddArguments("no-sandbox");
Driver = new EdgeDriver(edgeOptions);
Driver.Navigate();

MyTest:

public void Test()
{
    var item = Driver.FindElement(By.Id("tableItem")); //test fails here
    item.Click();
}

Error message:

Message: 
OpenQA.Selenium.NoSuchElementException : no such element: Unable to locate element: {"method":"css selector","selector":"#tableItem"}
(Session info: MicrosoftEdge=107.0.1418.24)

As per CEF documentation, CEF apps should be tested using Chromedriver, but when I tried it gave me the following error:

Message: 
OpenQA.Selenium.WebDriverException : unknown error: cannot connect to chrome at localhost:9222
from unknown error: unrecognized Chrome version: Edg/107.0.1418.24

ChromeOptions used:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("window-size=1680x1050");
chromeOptions.AddArguments("no-sandbox");
chromeOptions.DebuggerAddress = "localhost:9222";
Driver = new ChromeDriver(chromeOptions);
Driver.Navigate();
Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92

1 Answers1

0

Web driver instances can hang out in memory even after your test is complete. You need to call Driver.Dispose() when you are done in order to shut down all of the web driver processes, and kill the msedgedriver.exe process. Then you can start up ChromeDriver on the same host name and port.

Same thing with ChromeDriver. You need to call Dispose() on the driver after you are done with it so it shuts down properly. If you include the full code for the test in your question, I can change my answer to show you where to call Dispose().

In the meantime, it would be a good idea to use two different ports. One port for Edge, and another one for Chrome.

Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92