private void HandleWindowControlAction(ActWindow actWindow) { try { switch (actWindow.WindowActionType) { case ActWindow.eWindowActionType.IsExist: string val = mUIAutomationHelper.IsWindowExist(actWindow).ToString(); actWindow.Error = ""; if (String.IsNullOrEmpty(actWindow.Error)) { actWindow.AddOrUpdateReturnParamActual("Actual", val); actWindow.ExInfo += val; } break; case ActWindow.eWindowActionType.Close: bool isClosed = mUIAutomationHelper.CloseWindow(actWindow); if (!isClosed) { actWindow.Error = "Window cannot be closed, please use the close window button."; } break; case ActWindow.eWindowActionType.Maximize: case ActWindow.eWindowActionType.Minimize: case ActWindow.eWindowActionType.Restore: bool isDone = mUIAutomationHelper.SetWindowVisualState(actWindow); if (!isDone) { actWindow.Error = "Window Action " + actWindow.WindowActionType.ToString() + " could not be performed."; } break; default: actWindow.Error = "Unknown Action - " + actWindow.WindowActionType; break; } } catch (System.Runtime.InteropServices.COMException e) { Reporter.ToLog(eLogLevel.ERROR, "COM Exception when HandleWindowControlAction Error details:", e); throw e; } catch (ElementNotAvailableException e) { Reporter.ToLog(eLogLevel.ERROR, "Element not available Exception when HandleWindowControlAction Error details:", e); throw e; } catch (ArgumentException e) { Reporter.ToLog(eLogLevel.ERROR, "Argument Exception when HandleWindowControlAction Error details:", e); throw e; } catch (Exception e) { Reporter.ToLog(eLogLevel.ERROR, "Exception in HandleWindowControlAction", e); throw e; } }
private void HandleWindowAction(ActWindow actWindow) { try { switch (actWindow.WindowActionType) { case ActWindow.eWindowActionType.Switch: bool b = mUIAutomationHelper.HandleSwitchWindow(actWindow.LocateBy, actWindow.LocateValueCalculated); if (!b) { actWindow.Error = "Window not found: " + actWindow.LocateValue; } break; case ActWindow.eWindowActionType.IsExist: string val = mUIAutomationHelper.IsWindowExist(actWindow).ToString(); actWindow.Error = ""; actWindow.AddOrUpdateReturnParamActual("Actual", val); actWindow.ExInfo = val; break; case ActWindow.eWindowActionType.Close: bool isClosed = mUIAutomationHelper.CloseWindow(actWindow); if (!isClosed) { actWindow.Error = "Window cannot be closed, please use the close window button."; } break; case ActWindow.eWindowActionType.Maximize: case ActWindow.eWindowActionType.Minimize: case ActWindow.eWindowActionType.Restore: bool isDone = mUIAutomationHelper.SetWindowVisualState(actWindow); if (!isDone) { actWindow.Error = "Window Action " + actWindow.WindowActionType.ToString() + " could not be performed."; } break; default: actWindow.Error = "Unknown Action - " + actWindow.WindowActionType; break; } } catch (Exception e) { throw e; } }
ObservableList <Act> IWindowExplorerTreeItem.GetElementActions() { ObservableList <Act> list = new ObservableList <Act>(); ActWindow a1 = new ActWindow(); a1.Description = "Check window exist " + Path; a1.LocateBy = eLocateBy.ByTitle; a1.LocateValue = Path; a1.WindowActionType = ActWindow.eWindowActionType.IsExist; list.Add(a1); ActWindow a2 = new ActWindow(); a2.Description = "Close window " + Path; a2.LocateBy = eLocateBy.ByTitle; a2.LocateValue = Path; a2.WindowActionType = ActWindow.eWindowActionType.Close; list.Add(a2); ActWindow a3 = new ActWindow(); a3.Description = "Switch to window " + Path; a3.LocateBy = eLocateBy.ByTitle; a3.LocateValue = Path; a3.WindowActionType = ActWindow.eWindowActionType.Switch; list.Add(a3); ActWindow a4 = new ActWindow(); a4.Description = "Minimize window " + Path; a4.LocateBy = eLocateBy.ByTitle; a4.LocateValue = Path; a4.WindowActionType = ActWindow.eWindowActionType.Minimize; list.Add(a4); ActWindow a5 = new ActWindow(); a5.Description = "Maximize window " + Path; a5.LocateBy = eLocateBy.ByTitle; a5.LocateValue = Path; a5.WindowActionType = ActWindow.eWindowActionType.Maximize; list.Add(a5); return(list); }
public override void RunAction(Act act) { //TODO: add func to Act + Enum for switch string actClass = act.GetType().ToString(); mUIAutomationHelper.mLoadTimeOut = mActionTimeout; mUIAutomationHelper.taskFinished = false; //TODO: avoid hard coded string... actClass = actClass.Replace("GingerCore.Actions.", ""); actClass = actClass.Replace("Windows.", ""); if (actClass != "ActSwitchWindow" || (actClass == "ActWindow" && ((ActWindow)act).WindowActionType != ActWindow.eWindowActionType.Switch)) { CheckRetrySwitchWindowIsNeeded(); } if (act.Timeout != null) { mUIAutomationHelper.mLoadTimeOut = act.Timeout; } try { switch (actClass) { case "ActWindow": ActWindow actWindow = (ActWindow)act; HandleWindowAction(actWindow); break; //TODO: ActSwitchWindow is the correct approach for switch window. And we should guide the users accordingly. case "ActSwitchWindow": mUIAutomationHelper.SmartSwitchWindow((ActSwitchWindow)act); break; case "ActWindowsControl": HandleWindowsControlAction((ActWindowsControl)act); break; case "ActGenElement": ActGenElement AGE = (ActGenElement)act; HandleWindowsGenericWidgetControlAction(AGE); break; case "ActMenuItem": ActMenuItem actMenuItem = (ActMenuItem)act; HandleMenuControlAction(actMenuItem); break; case "ActSmartSync": mUIAutomationHelper.SmartSyncHandler((ActSmartSync)act); break; case "ActScreenShot": try { //TODO: When capturing all windows, we do showwindow. for few applications show window is causing applicaiton to minimize //Disabling the capturing all windows for Windows driver until we fix show window issue Bitmap bmp = mUIAutomationHelper.GetCurrentWindowBitmap(); act.AddScreenShot(bmp); //if not running well. need to add return same as PBDrive } catch (Exception ex) { act.Error = "Error: Action failed to be performed, Details: " + ex.Message; } break; case "Common.ActUIElement": HandleUIElementAction(act); break; case "ActBrowserElement": ActBrowserElement actWBE = (ActBrowserElement)act; HandleWindowsBrowserElementAction(actWBE); break; case "ActTableElement": ActTableElement actTable = (ActTableElement)act; HandleWindowsWidgetTableControlAction(actTable); break; default: throw new Exception("Action unknown/Not Impl in Driver - " + this.GetType().ToString()); } GC.Collect(); GC.WaitForPendingFinalizers(); } catch (System.Runtime.InteropServices.COMException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (ElementNotAvailableException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (ArgumentException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (Exception e) { Reporter.ToLog(eLogLevel.WARN, "Exception at Run action", e); act.Error = e.Message; } }
public override void RunAction(Act act) { //TODO: add func to Act + Enum for switch string actClass = act.GetType().ToString(); mUIAutomationHelper.mLoadTimeOut = mActionTimeout; mUIAutomationHelper.taskFinished = false; //TODO: avoid hard coded string... actClass = actClass.Replace("GingerCore.Actions.", ""); if (actClass != "ActUIASwitchWindow" && actClass != "ActSwitchWindow") { CheckRetrySwitchWindowIsNeeded(); } if (act.Timeout != null) { mUIAutomationHelper.mLoadTimeOut = act.Timeout; } try { Reporter.ToLog(eLogLevel.DEBUG, "Start Executing action of type '" + actClass + "' Description is" + act.Description); switch (actClass) { case "ActPBControl": ActPBControl actPBC = (ActPBControl)act; HandlePBControlAction(actPBC); break; case "ActGenElement": ActGenElement AGE = (ActGenElement)act; HandlePBGenericWidgetControlAction(AGE); break; case "ActBrowserElement": ActBrowserElement actBE = (ActBrowserElement)act; HandlePBBrowserElementAction(actBE); break; //TODO: ActSwitchWindow is the correct approach for switch window. And we should guide the users accordingly. //Down the line we need to clean up ActUIASwitchWindow. This is old way, but we keep it to support old actions case "ActUIASwitchWindow": mUIAutomationHelper.SwitchWindow((ActUIASwitchWindow)act); break; case "ActSwitchWindow": mUIAutomationHelper.SmartSwitchWindow((ActSwitchWindow)act); break; case "ActMenuItem": ActMenuItem actMenuItem = (ActMenuItem)act; HandleMenuControlAction(actMenuItem); break; case "ActWindow": ActWindow actWindow = (ActWindow)act; HandleWindowControlAction(actWindow); break; //case "ActUIAButton": // ActUIAButton b = (ActUIAButton)act; // UIA.ClickButton(b); // break; //case "ActUIATextBox": // ActUIATextBox ATB = (ActUIATextBox)act; // if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.SetValue) // { // UIA.SetTextBoxValue(ATB); // return; // } // if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.GetValue) UIA.GetTextBoxValue(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.GetValue) UIA.GetTextBoxValue(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.IsDisabled) UIA.IsTextBoxDisabled(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.GetFont) UIA.GetTextBoxFont(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.IsPrepopulated) UIA.IsTextBoxPrepopulated(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.IsRequired) UIA.IsTextBoxRequired(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.IsDisplayed) UIA.IsTextBoxDisplayed(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.GetInputLength) UIA.GetTextBoxInputLength(ATB); // break; //case "ActUIALabel": // if (((ActUIALabel)act).LabelAction == ActUIALabel.eLabelAction.GetForeColor) UIA.LabelGetColor((ActUIALabel)act); // break; //TODO: What Jave is doing here? is it needed? case "Java.ActTableElement": ActTableElement actTable = (ActTableElement)act; mUIAutomationHelper.HandleGridControlAction(actTable); break; case "ActTableElement": ActTableElement actTable1 = (ActTableElement)act; mUIAutomationHelper.HandleGridControlAction(actTable1); break; case "ActSmartSync": mUIAutomationHelper.SmartSyncHandler((ActSmartSync)act); break; //case "ActUIAClickOnPoint": // ActUIAClickOnPoint ACP = (ActUIAClickOnPoint)act; // if (ACP.ActUIAClickOnPointAction == ActUIAClickOnPoint.eUIAClickOnPointAction.ClickXY) UIA.ClickOnPoint(ACP); // break; case "ActScreenShot": try { //TODO: Implement Multi window capture if (act.WindowsToCapture == Act.eWindowsToCapture.AllAvailableWindows) { List <AppWindow> list = mUIAutomationHelper.GetListOfDriverAppWindows(); List <Bitmap> bList; foreach (AppWindow aw in list) { Bitmap bmp = mUIAutomationHelper.GetAppWindowAsBitmap(aw); act.AddScreenShot(bmp); bList = mUIAutomationHelper.GetAppDialogAsBitmap(aw); foreach (Bitmap tempbmp in bList) { act.AddScreenShot(tempbmp); } bList.Clear(); } } else { Bitmap bmp = mUIAutomationHelper.GetCurrentWindowBitmap(); act.AddScreenShot(bmp); } return; } catch (Exception ex) { act.Error = "Error: Action failed to be performed, Details: " + ex.Message; } break; //case "ActUIAImage": // if (((ActUIAImage)act).ImageAction == ActUIAImage.eImageAction.IsVisible) UIA.ImageIsVisible((ActUIAImage)act); // break; //case "ActPBControl": // ActPBControl APBC = (ActPBControl)act; // RunControlAction(APBC); // break; //case "ActMenuItem": // ActMenuItem ami = (ActMenuItem)act; // MenuItem(ami); // break; case "Common.ActUIElement": //ActUIElement actUIPBC = (ActUIElement)act; HandleUIElementAction(act); break; default: throw new Exception("Action unknown/Not Impl in Driver - " + this.GetType().ToString()); } } catch (System.Runtime.InteropServices.COMException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (ElementNotAvailableException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (ArgumentException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (Exception e) { Reporter.ToLog(eLogLevel.WARN, "Exception at Run action", e); act.Error = e.Message; } }
public abstract Boolean SetWindowVisualState(ActWindow act);
public override bool SetWindowVisualState(ActWindow act) { throw new NotImplementedException(); }