From ef33a2654db3d92667688387762ebf906a16cb9e Mon Sep 17 00:00:00 2001 From: Nagappan Alagappan Date: Tue, 18 Mar 2014 12:05:56 -0700 Subject: [PATCH] InvokePatter doesn't work all the time, fixed it InvokePatter doesn't work all the time, fixed it with InternalClick QA Notes: Testing Done: Yes Documentation Notes: Bug Number: Reviewed by: Approved by: Mailto: --- Ldtpd/Combobox.cs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Ldtpd/Combobox.cs b/Ldtpd/Combobox.cs index c9cc9fc..96e3ac6 100644 --- a/Ldtpd/Combobox.cs +++ b/Ldtpd/Combobox.cs @@ -149,14 +149,14 @@ private int InternalComboHandler(String windowName, String objName, ArrayList childList = null) { bool verify = actionType == "Verify" ? true : false; - ControlType[] type = new ControlType[3] { ControlType.ComboBox, + ControlType[] comboTtype = new ControlType[3] { ControlType.ComboBox, ControlType.ListItem, ControlType.List/*, ControlType.Text */ }; AutomationElement childHandle = utils.GetObjectHandle(windowName, - objName, type, !verify); + objName, comboTtype, !verify); Object pattern = null; Object invokePattern = null; AutomationElement elementItem = null; - type = new ControlType[1] { ControlType.Button }; + ControlType[] type = new ControlType[1] { ControlType.Button }; try { LogMessage("Handle name: " + childHandle.Current.Name + @@ -166,6 +166,8 @@ private int InternalComboHandler(String windowName, String objName, throw new XmlRpcFaultException(123, "Object state is disabled"); } elementItem = utils.GetObjectHandle(childHandle, "Open", type, true); + LogMessage("elementItem: " + elementItem.Current.Name + + " - " + elementItem.Current.ControlType.ProgrammaticName); if (childHandle.TryGetCurrentPattern(ExpandCollapsePattern.Pattern, out pattern) || childHandle.TryGetCurrentPattern( InvokePattern.Pattern, out invokePattern) || @@ -240,15 +242,28 @@ private int InternalComboHandler(String windowName, String objName, elementItem.TryGetCurrentPattern(InvokePattern.Pattern, out invokePattern))) { - ((InvokePattern)invokePattern).Invoke(); + LogMessage("InvokePattern"); + childHandle.SetFocus(); + utils.InternalClick(elementItem); + // InvokePattern doesn't work with Virtual Network + // Editor of VMware Workstation, so used the above InternalClick + //((InvokePattern)invokePattern).Invoke(); } else if (pattern != null) + { + LogMessage("ExpandCollapsePattern"); ((ExpandCollapsePattern)pattern).Expand(); + } // Required to wait 1 second, // before checking the state and retry expanding utils.InternalWait(1); + LogMessage("Handle name: " + childHandle.Current.Name + + " - " + childHandle.Current.ControlType.ProgrammaticName); + bool typeExist = utils.InternalWaitTillChildControlTypeExist(childHandle, comboTtype); + LogMessage("Control type exist: " + typeExist); AutomationElementCollection c = childHandle.FindAll(TreeScope.Subtree, Condition.TrueCondition); + LogMessage("AutomationElementCollection " + c.Count); foreach (AutomationElement e in c) { LogMessage(e.Current.Name + " : " + e.Current.ControlType.ProgrammaticName); @@ -266,6 +281,7 @@ private int InternalComboHandler(String windowName, String objName, } } } + LogMessage("Unable to find selected combo box value"); c = null; selectionPattern = null; if (invokePattern != null) @@ -337,6 +353,7 @@ private int InternalComboHandler(String windowName, String objName, // verified correctly on Player with this fix else { + LogMessage("SelectListItem"); childHandle.SetFocus(); return SelectListItem(childHandle, item, verify) ? 1 : 0; } @@ -352,7 +369,7 @@ private int InternalComboHandler(String windowName, String objName, } finally { - type = null; + comboTtype = type = null; pattern = invokePattern = null; elementItem = childHandle = null; }