Is it possible to find out the url of the active tab using Selenium WebDriver? The browser before running the program should already be open, and not cause

ChromeDriver chrome = new ChromeDriver(); 

Here's the code that searches for active tabs without the help of Selenium WebDriver

  var roots = AutomationElement.RootElement.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "Chrome_WidgetWin_1")); foreach (AutomationElement root in roots) { var textP = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit)); var vpi = textP.GetCurrentPropertyValue(ValuePatternIdentifiers.ValueProperty); Console.WriteLine(vpi); } 

But he is very actively loading the CPU. And with the help of Selenium WebDriver, I still did not understand how to find the link for the active tab of an already running browser. And generally it can be done with the help of Selenium WebDriver?

UPD

Well, or somehow you can adapt the method with Autmation

  • As far as I personally know, so far there seems to be no development in terms of connecting to an already running browser. This question is interesting to many. - Dmitry Gvozd

3 answers 3

Selenium WebDriver works only with its browser processes, which starts when WebDriver initialized.

    If you display in messagebox, then like this: browser.SwitchTo (). Window (browser.CurrentWindowHandle);

     MessageBox.Show(browser.Url); 

    The browser is an object of the IWebDriver interface type.

      Try this:

       IWebDriver driver = new ChromeDriver(); String url = driver.Url