Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to use UIAutomation to get Microsoft Edge browser title and url on each tab?

Use .NET UIAutomation, I can get title and url only on active tab. I want to get them on all tabs of all Edge windows.

e.g. I open 3 Edge windows, and each window has many tabs.

What I have tried:

void test2()
{
    foreach (AutomationElement edgegroup in AutomationElement.RootElement.FindAll(TreeScope.Children, PropertyCondition.TrueCondition))
    {
        if (!edgegroup.Current.Name.Contains("Edge")) continue;

        this.textBox1.Text += Environment.NewLine;
        this.textBox1.Text += Environment.NewLine + "edgegroup title:" + edgegroup.Current.Name;

        foreach (AutomationElement edgewin in edgegroup.FindAll(TreeScope.Children, PropertyCondition.TrueCondition))
        {
            if (edgewin.Current.ClassName != "Windows.UI.Core.CoreWindow") continue;

            this.textBox1.Text += "    "+Environment.NewLine + "ClassName:" + edgewin.Current.ClassName;

            foreach (AutomationElement edgetab in edgewin.FindAll(TreeScope.Children, PropertyCondition.TrueCondition))
            {
                if (edgetab.Current.ClassName != "GridViewItem") continue;

                this.textBox1.Text +="        "+ Environment.NewLine + "ClassName:" + edgetab.Current.ClassName;
                this.textBox1.Text += "            " + Environment.NewLine + "Name:" + edgetab.Current.Name;
            }
        }

    }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900