Open, close and verify expanded/Collapse states for nodes in Treeview winForms
Somebody knows how verify expanded/collapse states and doubleClick nodes in Treeview control for WinForms? Thanks so much for your kind assistance.
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;
}
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.
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...
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...
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...
}
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 ?
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...
Thanx @QAAutomationTester
I am not able to proceed ahead with WinappDriver - V1.0, Selenium - V3.10 and Appium Desktop V 1.8.1
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...
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.
Any update on this issue
In case anyone is still wondering, the ExpandCollapseState can be addressed with ExpandCollapse.ExpandCollapseState.
In case anyone is still wondering, the
ExpandCollapseStatecan be addressed withExpandCollapse.ExpandCollapseState.
This worked. Can we get a documentation for getting all the pattern state values.