Exemple #1
0
        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;
            }
        }
Exemple #2
0
        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;
            }
        }