Skip to content

Commit

Permalink
InvokePatter doesn't work all the time, fixed it
Browse files Browse the repository at this point in the history
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:
  • Loading branch information
nagappan committed Mar 18, 2014
1 parent bdfaf18 commit ef33a26
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions Ldtpd/Combobox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand All @@ -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) ||
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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;
}
Expand All @@ -352,7 +369,7 @@ private int InternalComboHandler(String windowName, String objName,
}
finally
{
type = null;
comboTtype = type = null;
pattern = invokePattern = null;
elementItem = childHandle = null;
}
Expand Down

0 comments on commit ef33a26

Please sign in to comment.