/// <summary> /// Get node from the treeNodes /// </summary> /// <param name="treeNodes"></param> /// <param name="path"></param> /// <returns></returns> private TreeNode GetNodeFromTreeNodes(TreeNodes treeNodes, string path) { foreach (var subNode in treeNodes) { if (subNode.HelpText != string.Empty && IgnoreItems.Contains(subNode.HelpText) == false) { if (subNode.HelpText.Contains(path)) { return(subNode); } } else if (subNode.Text != string.Empty && IgnoreItems.Contains(subNode.Text) == false) { if (subNode.Text.Contains(path)) { return(subNode); } } else { var lblnode = QALabel.Get(SearchCriteria.ByText(path), string.Empty, subNode, 500); if (lblnode != null && lblnode.UIItemExists && lblnode.IsVisible) { return(subNode); } } } return(null); }
/// <summary> /// Finds and returns a ListItem from a ListBox using the label of the ListItem /// </summary> /// <param name="listItemLabel">label of the ListItem</param> /// <param name="returnNullIfNotFound">function will not throw an exception, but instead return null if not found</param> /// <returns>ListItem with the passed in label</returns> public QAListItem FindListItem(string listItemLabel, bool returnNullIfNotFound = false) { ReportActionValue("FindListItem", listItemLabel); ListItem listItemFound = null; // Check if ListItem text matches foreach (var listItem in UIItem.Items) { if (listItem.Text.Equals(listItemLabel)) { listItemFound = listItem; break; } } // Check if label inside scope of ListItem matches if (listItemFound == null) { foreach (var listItem in UIItem.Items) { var label = QALabel.Get(SearchCriteria.All, string.Empty, listItem, 2); if (label.UIItem != null && label.Text.Equals(listItemLabel)) { listItemFound = listItem; break; } } } return(listItemFound == null && returnNullIfNotFound ? null : new QAListItem(listItemFound, listItemLabel)); }
/// <summary> /// Returns text of inner TextBox or Label /// </summary> public static string GetInnerText(this UIItem uIItem) { string nodeName; var textItem = QATextBox.Get(SearchCriteria.All, "UIItem text", uIItem, 1); if (textItem.Exists) { nodeName = textItem.Text; } else { var label = QALabel.Get(SearchCriteria.All, "UIItem button", uIItem, 1); nodeName = label.Exists ? label.Text : string.Empty; } return(nodeName); }
public ListItem FindItemWithText(string itemText) { ListItem listItemFound = null; var items = UIItem.Items; foreach (var listItem in items) { if (listItem.Text.Equals(itemText)) { listItemFound = listItem; break; } } if (listItemFound == null) { foreach (var listItem in items) { var label = QALabel.Get(SearchCriteria.All, string.Empty, listItem, 2); if (label.UIItem != null) { if (label.Text.Equals(itemText)) { listItemFound = listItem; break; } } } } if (listItemFound == null) { Click(); listItemFound = QAListItem.Get(SearchCriteria.ByText(itemText), string.Empty).UIItem; } return(listItemFound); }