WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Open, close and verify expanded/Collapse states for nodes in Treeview winForms

Open bicentennial opened this issue 7 years ago • 13 comments

Somebody knows how verify expanded/collapse states and doubleClick nodes in Treeview control for WinForms? Thanks so much for your kind assistance.

bicentennial avatar Sep 04 '18 21:09 bicentennial

Hi,

Treview control has 'NodeMouseDoubleClick' which executed while double click on treeview node. You can get the clicked treeview node and add your business logic. Below is the example code of treeview node double click event.

private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {

            //To Do - Business logic
            TreeNode clickedNode = e.Node;
        }

jignesh6990 avatar Sep 05 '18 10:09 jignesh6990

Thanks for the assistance jignesh6990, but let me explain little more my question, sorry about that.

We are preparing an automation test for an existing third party WinForms application, this application uses a Treeview control.

We want, from our automation test application, by automation calling WinAppDriver from our testMethod, execute the action double click in a node if this node is collapsed.

We have found the TreeView node by FindElementByXPath method but now we want to verify states and execute actions on it. The instance that FindElementByXPath returns is a WindowsElement instance under the namespace OpenQA.Selenium.Appium.Windows, but I don't see, by intellisense, the double click method and I don't see any property/method to query his collapsed state.

Thanks for your kind assistance.

bicentennial avatar Sep 05 '18 12:09 bicentennial

For double click: i tried some like this, query works, element has value but DoubleClick method do nothing in UI...

     string nodeXPath= "...";
     var element = MySession.FindElementByXPath(nodeXPath);
     MySession.Mouse.DoubleClick(element.Coordinates);

Continue with research...

bicentennial avatar Sep 05 '18 18:09 bicentennial

Done!...: Example for double click on TreeView control node or any other UIElement:

 string nodeXPath= "...";
 var element = MySession.FindElementByXPath(nodeXPath);
 MySession.Mouse.MouseMove(element.Coordinates);
 MySession.Mouse.DoubleClick(null);

Lets continue research for expanded/collapsed state...

bicentennial avatar Sep 05 '18 20:09 bicentennial

Done!...:

 Collapsed states for node in TreeView control: (node visible is required, validation out of the scope of the original question, but easy to accomplish...):

     var xmlDoc = new XmlDocument();
     xmlDoc.LoadXml(MySession.PageSource);
     string nodeXPath = "...";
     var xmlNode = xmlDoc.SelectSingleNode(nodeXPath);
     if (xmlNode != null)
     {
        string state = xmlNode.Attributes["ExpandCollapseState"].Value;
        bool expanded = state == "Expanded";
        bool leafNode = state == "LeafNode";
        bool collapsed = state == "Collapsed";
     }
    else
    {
       // Node not visible or not exists in the UI...
    }

bicentennial avatar Sep 05 '18 20:09 bicentennial

Hi @QAAutomationTester

Can you pls tell me which Appium, java client , Winapp driver versions are you using to automate? My application is WPF and i am trying to automate Treeview control of Devexpress. And here my tree is getting dynamically loading with nodes. Unable to locate element with Xpath (#478 ).

Can you pls help ?

jsingh-qualitrol avatar Sep 07 '18 13:09 jsingh-qualitrol

Of course jsingh-qualitrol: I am using:

Winapp driver: 1.1.1808.7001 Selenium.WebDriver v3.0.1 Selenium.Support v3.0.1 Appium.WebDriver v3.0.0.2

Testing [TestMethod]'s with Visual Studio 2017.

We don't updrade to latest Selenium NuGet Packages v.3.14.0 yet because some issues with capabilities at time to create Session instance...

bicentennial avatar Sep 07 '18 20:09 bicentennial

Thanx @QAAutomationTester

I am not able to proceed ahead with WinappDriver - V1.0, Selenium - V3.10 and Appium Desktop V 1.8.1

jsingh-qualitrol avatar Sep 10 '18 09:09 jsingh-qualitrol

This is an update about the versions used successfully for the issue in this thread: I am using: Winapp driver: 1.1.1808.7001 Selenium.WebDriver v3.5.0 Selenium.Support v3.5.0 Appium.WebDriver v3.0.0.2 Testing [TestMethod]'s with Visual Studio 2017.

We don't updrade to Selenium NuGet Packages bigger than v3.5.0 because some issues with capabilities at time to create Session instance...

bicentennial avatar Sep 10 '18 12:09 bicentennial

try In the appicatioon i test, it shows the ExpandedState in the inspect.exe, but am not able to get the property using the appium functions.

karthikmsctcs avatar Feb 04 '20 11:02 karthikmsctcs

Any update on this issue

karthikmsctcs avatar Mar 12 '20 06:03 karthikmsctcs

In case anyone is still wondering, the ExpandCollapseState can be addressed with ExpandCollapse.ExpandCollapseState.

somecho avatar Mar 14 '24 13:03 somecho

In case anyone is still wondering, the ExpandCollapseState can be addressed with ExpandCollapse.ExpandCollapseState.

This worked. Can we get a documentation for getting all the pattern state values.

karthikmsctcs avatar Mar 15 '24 04:03 karthikmsctcs