public override void DoExecute()
        {
            switch (PlaybackObject.action)
            {
            case "SetText":
                try
                {
                    bool CapsLockOn = (((ushort)GetKeyState(0x14)) & 0xffff) != 0;
                    if (CapsLockOn == true)
                    {
                        //Console.WriteLine(CapsLock);
                        const int KEYEVENTF_EXTENDEDKEY = 0x1;
                        const int KEYEVENTF_KEYUP       = 0x2;
                        keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
                        keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                                    (UIntPtr)0);
                    }
                    //(UiElement.AutomationElement.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern).SetValue(PlaybackObject.text);
                    UiElement.AsTextBox().Text = PlaybackObject.text;

                    Result = true;
                }
                //}
                catch (Exception)
                {
                    Result = false;
                }
                break;
            }
        }
        public override void DoExecute()
        {
            switch (PlaybackObject.action)
            {
            case "SetText":
                try
                {
                    if (UiElement.AsComboBox().IsEditable.Equals(true))
                    {
                        UiElement.AsTextBox().Enter(PlaybackObject.text);
                        Result = true;
                    }
                    else
                    {
                        Result = false;
                    }
                }
                catch (Exception)
                {
                    Result = false;
                }
                break;

            case "Select":
                try
                {
                    //AutomationElement a = UiElement.AutomationElement;
                    //ExpandCollapsePattern expandCollapsePattern = a.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern;
                    //expandCollapsePattern.Expand();
                    //var cbxEditItems = UiElement.FindAll(TreeScope.Subtree, new System.Windows.Automation.PropertyCondition(AutomationElement.ClassNameProperty, "ComboBoxItem"));
                    //cbxEditItems[PlaybackObject.itemIndex].AutomationElement.SelectionItemPattern().Select();
                    //expandCollapsePattern.Collapse();
                    UiElement.AsComboBox().Select(PlaybackObject.itemIndex);
                    UiElement.AsComboBox().Collapse();
                    Result = true;
                }
                catch (Exception)
                {
                    Result = false;
                }
                break;

            default:
                Result = false;
                break;
            }
        }
        public override void DoExecute()
        {
            switch (PlaybackObject.action)
            {
            case "SetText":
                try
                {
                    UiElement.AsTextBox().Enter(PlaybackObject.text);
                    Result = false;
                }
                catch (Exception)
                {
                    Result = true;
                }

                break;

            default:

                break;
            }
        }
        public override void DoExecute()
        {
            switch (Control.action)
            {
            case "SetText":
                try
                {
                    UiElement.AsTextBox().Enter(Control.text);
                    result = true;
                }
                catch (Exception)
                {
                    MessageBox.Show("Can not execute this action!");
                    result = false;
                    throw;
                }
                break;

            default:
                Thread.Sleep(2000);
                break;
            }
        }
Example #5
0
        public override void DoExecuteCheckPoint()
        {
            if (cpIsEmpty == true)
            {
                try
                {
                    string a = UiElement.AsTextBox().Text.Trim();
                    //string b = "";

                    if (string.IsNullOrEmpty(a))
                    {
                        cpIsEmptyResult = true;
                    }
                    else
                    {
                        cpIsEmptyResult = false;
                    }
                }
                catch (Exception)
                {
                    cpIsEmpty = false;
                }
            }
            if (cpIsReadOnly == true)
            {
                try
                {
                    if (UiElement.AsTextBox().IsReadOnly)
                    {
                        cpIsReadOnlyResult = true;
                    }
                    else
                    {
                        cpIsReadOnlyResult = false;
                    }
                }
                catch (Exception)
                {
                    cpIsReadOnlyResult = false;
                }
            }

            if (cpIsEqual == true)
            {
                try
                {
                    string a = UiElement.AsTextBox().Text;
                    string b = this.expectedVal;

                    if (string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b))
                    {
                        a = "0";
                        b = a;
                    }

                    if (a.Equals(b))
                    {
                        cpIsEqualResult = true;
                    }
                    else
                    {
                        cpIsEqualResult = false;
                    }
                }
                catch (Exception)
                {
                    cpIsEqualResult = false;
                }
            }
            if (cpIsEnabled == true)
            {
                try
                {
                    if (UiElement.AsTextBox().IsEnabled)
                    {
                        cpIsEnabledResult = true;
                    }
                    else
                    {
                        cpIsEnabledResult = false;
                    }
                }
                catch (Exception)
                {
                    cpIsEnabledResult = false;
                }
            }
        }
Example #6
0
        public override void DoExecute()
        {
            switch (PlaybackObject.action)
            {
            case "SetText":
                try
                {
                    #region vinh's date validation

                    //if (UiElement.AsTextBox().Text == "__/__/____")
                    //{
                    //    if (PlaybackObject.text.Count() == 8)
                    //    {
                    //        string date = PlaybackObject.text.Trim();
                    //        date = date.Substring(0, 2) + "/" + date.Substring(2, 2) + "/" + date.Substring(4, 4);
                    //        try
                    //        {
                    //            DateTime dt = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    //            //(UiElement.AutomationElement.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern).SetValue(PlaybackObject.text);
                    //            UiElement.AsTextBox().Enter(PlaybackObject.text);
                    //        }
                    //        catch
                    //        {
                    //            MessageBox.Show("Date input is invalid");
                    //            Result = false;
                    //        }
                    //        if (UiElement.AsTextBox().Text == date)
                    //            Result = true;
                    //        else
                    //            Result = false;
                    //    }
                    //    else
                    //    {
                    //        Console.WriteLine("You have to enter exactly dd/MM/yyyy");
                    //        Result = false;
                    //    }
                    //}
                    //else
                    //{

                    #endregion vinh's date validation

                    bool CapsLockOn = (((ushort)GetKeyState(0x14)) & 0xffff) != 0;
                    if (CapsLockOn == true)
                    {
                        //Console.WriteLine(CapsLock);
                        const int KEYEVENTF_EXTENDEDKEY = 0x1;
                        const int KEYEVENTF_KEYUP       = 0x2;
                        keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
                        keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                                    (UIntPtr)0);
                    }
                    //(UiElement.AutomationElement.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern).SetValue(PlaybackObject.text);
                    UiElement.AsTextBox().Enter(PlaybackObject.text);
                    int  n;
                    bool isNumeric = int.TryParse(PlaybackObject.text, out n);

                    if (UiElement.AsTextBox().Text == "__/__/____" && isNumeric == false)
                    {
                        Result = false;
                    }
                    else
                    {
                        Result = true;
                    }
                }
                //}
                catch (Exception)
                {
                    Result = false;
                }
                break;

            case "IsEmpty":

                try
                {
                    object a = UiElement.AsTextBox().Text;
                    object b = "";

                    if (a.Equals(b))
                    {
                        Result = true;
                    }
                    else
                    {
                        Result = false;
                    }
                }
                catch (Exception)
                {
                    Result = false;
                }

                break;

            case "IsEqual":

                try
                {
                    string a = UiElement.AsTextBox().Text;
                    string b = PlaybackObject.text;

                    if (string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b))
                    {
                        a = "0";
                        b = a;
                    }

                    if (a.Equals(b))
                    {
                        Result = true;
                    }
                    else
                    {
                        Result = false;
                    }
                }
                catch (Exception)
                {
                    Result = false;
                }

                break;

            case "IsReadOnly":

                try
                {
                    if (UiElement.AsTextBox().IsReadOnly)
                    {
                        Result = true;
                    }
                    else
                    {
                        Result = false;
                    }
                }
                catch (Exception)
                {
                    Result = false;
                }

                break;

            case "IsEnabled":

                try
                {
                    if (UiElement.AsTextBox().IsEnabled)
                    {
                        Result = true;
                    }
                    else
                    {
                        Result = false;
                    }
                }
                catch (Exception)
                {
                    Result = false;
                }

                break;

            default:
                //Result = false;
                //Thread.Sleep(2000);
                break;
            }
        }