2gis / Winium

Automation framework for Windows platforms
Mozilla Public License 2.0
384 stars 123 forks source link

Winium C# Desktop Application taking tree view items #66

Open Yuvaraja06 opened 6 years ago

Yuvaraja06 commented 6 years ago

In my desktop application, have multiple treeview. How to take all the treeview and there items. What to check read each tree view items text. Please help me on this. New to Winium tool. Thank you.

Yuvaraja06 commented 6 years ago

I have added code on By.cs file to make extra search conditions. Its working fine. public static ByProperty Type(ControlType value) { return AutomationProperty(AutomationElement.ControlTypeProperty, value); }

public static ByProperty ClassName(string value) { return AutomationProperty(AutomationElement.ClassNameProperty, value); }

and in my code. Use the following code to retrieve tree items.

` CruciatusElement win = Winium.Cruciatus.CruciatusFactory.Root.FindElement(window);

By byVariable = By.Type(ControlType.Tree); CruciatusElement tree = win.FindElement(byVariable); byVariable = By.Type(ControlType.TreeItem); IEnumerable treeItem = tree.FindElements(byVariable); List treeList = treeItem.ToList(); if (treeList.Count >= 0) { itemname = treeList[0].Properties.Name.ToString(); }`

truptibhatt commented 6 years ago

@Yuvaraja06 - Do you have the code in java. I want to click on particular tree node.