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 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; } }