private void Window_KeyUp(object sender, KeyEventArgs e)
        {
            //TODO: check e.key and do keyevent for delete backspace etc..., or send text for simple char
            // Create amp and handle key event
            // meanwhile we send the text...
            if (!mSendKeyboardKeys)
            {
                return;
            }


            string AndroidKey = GetAndroidKey(e.Key);


            if (AndroidKey != null)
            {
                if (IsRecording)
                {
                    ActDeviceButton act = new ActDeviceButton();
                    act.Description = "Press Key '" + AndroidKey + "'";
                    act.Value       = AndroidKey;
                    mBusinessFlow.AddAct(act);
                }

                // TODO: check if we use UIAutomation PressKey with some keys maps if it is faster then shell command
                string result = mAndroidADBDriver.ExecuteShellCommand("input text " + AndroidKey);
            }
        }
Ejemplo n.º 2
0
        private void AddFromRepository(object sender, RoutedEventArgs e)
        {
            if (xActionsGrid.Grid.SelectedItems != null && xActionsGrid.Grid.SelectedItems.Count > 0)
            {
                foreach (Act selectedItem in xActionsGrid.Grid.SelectedItems)
                {
                    mBusinessFlow.AddAct((Act)selectedItem.CreateInstance(true));
                }

                int selectedActIndex           = -1;
                ObservableList <IAct> actsList = mBusinessFlow.CurrentActivity.Acts;
                if (actsList.CurrentItem != null)
                {
                    selectedActIndex = actsList.IndexOf((Act)actsList.CurrentItem);
                }
                if (selectedActIndex >= 0)
                {
                    actsList.Move(actsList.Count - 1, selectedActIndex + 1);
                }
            }
            else
            {
                Reporter.ToUser(eUserMsgKey.NoItemWasSelected);
            }
        }
Ejemplo n.º 3
0
        private void ElementRecordedHandler(ElementActionCongifuration args)
        {
            try
            {
                Act         actUI;
                ElementInfo einfo = null;
                if (args.LearnedElementInfo != null)
                {
                    einfo = (ElementInfo)args.LearnedElementInfo;
                    args.AddPOMToAction = CreatePOM;
                    args.POMGuid        = CurrentPOM.Guid.ToString();
                    args.ElementGuid    = einfo.Guid.ToString();

                    actUI = PlatformInfo.GetPlatformAction(einfo, args);
                }
                else
                {
                    actUI = PlatformInfo.GetPlatformAction(null, args);
                }
                if (actUI != null)
                {
                    if (CurrentPOM != null && einfo != null)
                    {
                        CurrentPOM.MappedUIElements.Add(einfo);
                    }
                    BusinessFlow.AddAct(actUI);
                }
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Error in Element recording event handler while recording", ex);
            }
        }
Ejemplo n.º 4
0
        private void RunCommand()
        {
            if (string.IsNullOrEmpty(CommandTextBox.Text))
            {
                CommandTextBox.Text = string.Empty;
            }

            if (mRecording)
            {
                ActConsoleCommand ACC = new ActConsoleCommand();
                ACC.Description = "Command: " + CommandTextBox.Text;

                ACC.LocateBy = eLocateBy.NA;
                ACC.AddOrUpdateInputParamValue("Free Command", CommandTextBox.Text);
                ACC.ConsoleCommand = ActConsoleCommand.eConsoleCommand.FreeCommand;
                mBusinessFlow.AddAct(ACC);
            }

            ConsoleWriteCommand(CommandTextBox.Text);

            //Checking Console Driver Platform
            if (mConsoleDriver.Platform.ToString() == "Unix")
            {
                //Unix then only \n is required
                mConsoleDriver.taskFinished = false;
                mConsoleDriver.SendCommand(CommandTextBox.Text + "\n");
            }
            else
            {
                //Dos then \r\n is required
                mConsoleDriver.SendCommand(CommandTextBox.Text + Environment.NewLine);
            }
            CommandTextBox.Text = "";
        }
Ejemplo n.º 5
0
        public void CreateSwitchWindowAction(string title)
        {
            ActSwitchWindow act = new ActSwitchWindow();

            act.Description = "Switch Window - " + title;
            act.LocateBy    = eLocateBy.ByTitle;
            act.LocateValue = title;
            BusinessFlow.AddAct(act, true);
        }
Ejemplo n.º 6
0
        private void SetValueButton_Click(object sender, RoutedEventArgs e)
        {
            // TODO: create an action to get the focusable control from the driver on the device
            List <ElementInfo> list = ((IWindowExplorer)mAndroidADBDriver).GetVisibleControls(null);

            // get from the list only text Edit
            foreach (ElementInfo EI in list)
            {
                if (EI.ElementType == "android.widget.EditText")  // check if it will work on all apps, might need to rethink
                {
                    ObservableList <ControlProperty> props = EI.GetElementProperties();
                    ControlProperty cp = (from x in props where x.Name == "focused" select x).FirstOrDefault();

                    //FIXME: temp just to try, need to get the best locator for element.
                    ControlProperty cpresourceid = (from x in props where x.Name == "resource-id" select x).FirstOrDefault();

                    if (cp.Value == "true")
                    {
                        // mDeviceViewPage.AddTextBox()
                        ActUIElement a = new ActUIElement();
                        a.ElementLocateBy = eLocateBy.ByResourceID;
                        a.ElementType     = eElementType.TextBox;
                        a.ElementAction   = ActUIElement.eElementAction.SetText;

                        // Need to set value in both since sending direct to driver
                        // a.ElementLocateValue = cpresourceid.Value;
                        a.GetOrCreateInputParam(ActUIElement.Fields.ElementLocateValue).ValueForDriver = cpresourceid.Value;


                        a.GetOrCreateInputParam(ActUIElement.Fields.Value).ValueForDriver = SetValueTextBox.Text;


                        // a.Value = SendKeysTextBox.Text;
                        //mAndroidADBDriver.RunAction(a);  // !!!!!!!!!!!!!!!!


                        if (IsRecording)
                        {
                            ControlProperty desc = (from x in props where x.Name == "content-desc" select x).FirstOrDefault();
                            if (string.IsNullOrEmpty(desc.Value))
                            {
                                desc = cpresourceid;
                            }
                            a.Description = "Set '" + desc.Value + "' value to '" + SetValueTextBox.Text + "'";
                            a.GetOrCreateInputParam(ActUIElement.Fields.Value).Value = SetValueTextBox.Text;
                            a.GetOrCreateInputParam(ActUIElement.Fields.ElementLocateValue).Value = cpresourceid.Value;

                            mBusinessFlow.AddAct(a);
                        }

                        return;
                    }
                }
            }
        }
 private void AddActionBtn_Click(object sender, RoutedEventArgs e)
 {
     if (mBF != null)
     {
         mBF.AddAct(ACC);
     }
     else
     {
         Reporter.ToUser(eUserMsgKeys.AskToSelectBusinessflow);
     }
 }
Ejemplo n.º 8
0
 private void AddActionBtn_Click(object sender, RoutedEventArgs e)
 {
     if (mBF != null)
     {
         mBF.AddAct(ACC);
     }
     else
     {
         MessageBox.Show("Please select " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow));;
     }
 }
Ejemplo n.º 9
0
 private void AddActionToBusinessFlow(Act actUI, ElementInfo einfo)
 {
     try
     {
         if (actUI != null)
         {
             if (CurrentPOM != null && einfo != null)
             {
                 CurrentPOM.MappedUIElements.Add(einfo);
             }
             actUI.Context = Context;
             BusinessFlow.AddAct(actUI);
         }
     }
     catch (Exception ex)
     {
         Reporter.ToLog(eLogLevel.ERROR, "Error while adding action to business flow", ex);
     }
 }
Ejemplo n.º 10
0
        private void ProcessActions(ConvertedCodeLine CCL)
        {
            string CodeLine         = CCL.CodeLine;
            string value            = "";
            string SetValueinObject = "";
            string varName          = "";
            string xpath            = "";
            string type             = "";

            if (CodeLine.Contains("WebEdit"))
            {
                if (CodeLine.Contains("WebEditTxtChange"))
                {
                    type             = "Edit Box";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebEdit(\"", "\")");

                    varName = CodeLine.Substring(CodeLine.IndexOf("GlobalDictionary")).Replace("GlobalDictionary", "").Trim();
                    varName = varName.Replace("(", "").Replace(")", "");
                    value   = "{Var Name=" + varName + "}";

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }

                // Add Action to biz flow
                ActGenElement act = new ActGenElement();
                act.Value            = value.Replace("\"", "").Replace("\"", "");
                act.GenElementAction = ActGenElement.eGenElementAction.SetValue;
                act.LocateBy         = eLocateBy.ByXPath;
                act.LocateValue      = xpath;
                act.Description      = "Set value in " + SetValueinObject + " " + type;
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - ActGenElement.SetValue : LocateValue=" + act.LocateValue + ", Value=" + act.Value;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }

            // Extract the WebEdit/WebCheckBox
            else if (CodeLine.Contains(".Set") || CodeLine.Contains(".set"))
            {
                if (CodeLine.Contains("WebEdit"))
                {
                    type             = "Edit Box";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebEdit(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }
                else if (CodeLine.Contains("WebCheckBox"))
                {
                    type             = "Check Box";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebCheckBox(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }

                // for Values to Set
                if (CodeLine.Contains("Set \""))  // For hard coded values
                {
                    value = GetStringBetween(CodeLine, "Set \"", CodeLine[CodeLine.Length - 1].ToString());
                }
                else if (CodeLine.Contains("GlobalDictionary"))
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("GlobalDictionary")).Replace("GlobalDictionary", "").Trim();
                    varName = varName.Replace("(", "").Replace(")", "");
                    value   = "{Var Name=" + varName + "}";
                }
                else if (CodeLine.Contains("Globaldictionary"))
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("Globaldictionary")).Replace("Globaldictionary", "").Trim();
                    varName = varName.Replace("(", "").Replace(")", "");
                    value   = "{Var Name=" + varName + "}";
                }
                else if (!CodeLine.Contains("GlobalDictionary") && !CodeLine.Contains("Globaldictionary"))  // for variables declared using Dim
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("Set")).Replace("Set", "").Trim();
                    value   = "{Var Name=" + varName + "}";
                    VariableString v = new VariableString();
                    v.Description = GingerDicser.GetTermResValue(eTermResKey.Variable) + " added by UFT Script";
                    v.Name        = varName;
                    v.Value       = value;
                    mBusinessFlow.AddVariable(v);
                }

                // Add Action to biz flow
                ActGenElement act = new ActGenElement();
                act.Value            = value.Replace("\"", "").Replace("\"", "");
                act.GenElementAction = ActGenElement.eGenElementAction.SetValue;
                act.LocateBy         = eLocateBy.ByXPath;
                act.LocateValue      = xpath;
                act.Description      = "Set value in " + SetValueinObject + " " + type;
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - ActGenElement.SetValue : LocateValue=" + act.LocateValue + ", Value=" + act.Value;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }

            // Extract the WebButton/Link/Image/WebELemnt
            else if (CodeLine.Contains(".Click") || CodeLine.Contains(".click"))
            {
                if (CodeLine.Contains("WebButton"))
                {
                    type             = "Button";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebButton(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }
                else if (CodeLine.Contains("Link"))
                {
                    type             = "Link";
                    SetValueinObject = GetStringBetween(CodeLine, ".Link(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }
                else if (CodeLine.Contains("WebElement"))
                {
                    type             = "Web Element";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebElement(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }
                else if (CodeLine.Contains("Image"))
                {
                    type             = "Image";
                    SetValueinObject = GetStringBetween(CodeLine, ".Image(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }

                // Add Action to biz flow
                ActGenElement act = new ActGenElement();
                act.Value            = "";
                act.LocateBy         = eLocateBy.ByXPath;
                act.LocateValue      = xpath;
                act.GenElementAction = ActGenElement.eGenElementAction.Click;
                act.Description      = "Click on " + SetValueinObject + " " + type;
                mBusinessFlow.AddAct(act);

                CCL.Converted = "New Action - ActGenElement.Click : LocateValue=" + act.LocateValue; // +", Value=" + act.Value;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }

            // Extract the WeBlist/WebRadiogroup
            else if (CodeLine.Contains(".Select") || CodeLine.Contains(".select"))
            {
                if (CodeLine.Contains("WebList"))
                {
                    type             = "List";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebList(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }
                else if (CodeLine.Contains("WebRadiogroup"))
                {
                    type             = "Radio Group";
                    SetValueinObject = GetStringBetween(CodeLine, ".WebRadiogroup(\"", "\")");

                    //Calling function to identify Locate By and Locate Value
                    xpath = ProcessLocateBy_Value(SetValueinObject);
                }

                //For Values to Set
                if (CodeLine.Contains("Select \""))  // For hard coded values
                {
                    value = GetStringBetween(CodeLine, "Select \"", CodeLine[CodeLine.Length - 1].ToString());
                }
                else if (CodeLine.Contains("GlobalDictionary"))
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("GlobalDictionary")).Replace("GlobalDictionary", "").Trim();
                    varName = varName.Replace("(", "").Replace(")", "");
                    value   = "{Var Name=" + varName + "}";
                }
                else if (CodeLine.Contains("Globaldictionary"))
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("Globaldictionary")).Replace("Globaldictionary", "").Trim();
                    varName = varName.Replace("(", "").Replace(")", "");
                    value   = "{Var Name=" + varName + "}";
                }
                else
                {
                    varName = CodeLine.Substring(CodeLine.IndexOf("Select ")).Replace("Select ", "").Trim();
                    value   = "{Var Name=" + varName + "}";
                    VariableString v = new VariableString();
                    v.Description = GingerDicser.GetTermResValue(eTermResKey.Variable) + " added by UFT Script";
                    v.Name        = varName;
                    v.Value       = value;
                    mBusinessFlow.AddVariable(v);
                }

                // Add Action to biz flow
                ActGenElement act = new ActGenElement();
                act.Value            = value;
                act.LocateBy         = eLocateBy.ByXPath;
                act.LocateValue      = xpath;
                act.GenElementAction = ActGenElement.eGenElementAction.SetValue;
                act.Description      = "Select value from " + SetValueinObject + " " + type;
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - ActGenElement.SetValue : LocateValue=" + act.LocateValue + ", Value=" + act.Value;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }

            // Extract the URL to Navigate to
            else if (CodeLine.Contains("Navigate"))
            {
                // Extract the URL
                string URL = GetStringBetween(CodeLine, ".Navigate(\"", "\")");

                // Add Action to biz flow
                ActGotoURL act = new ActGotoURL();
                act.Value       = URL;
                act.Description = "Navigate to URL";
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - ActGotoURL : " + URL;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }

            // Extract the URL launched using SystemUtil.Run
            else if (CodeLine.Contains("SystemUtil.Run") && CodeLine.Contains("iexplore.exe"))
            {
                // Extract the URL
                string URL = GetStringBetween(CodeLine, "iexplore.exe\",\"", "\"");

                // Add Action to biz flow
                ActGotoURL act = new ActGotoURL();
                act.Value       = URL;
                act.Description = "Navigate to URL";
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - ActGotoURL : " + URL;
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }
            else if (CodeLine.Contains("fDBCheck") || CodeLine.Contains("fDBActivities")) //ASAP function
            {
                // Temp until we read the SQL from common.xls
                ActDBValidation act = new ActDBValidation();
                act.Description = "DB Action-Configure Manually";
                mBusinessFlow.AddAct(act);
                CCL.Converted = "New Action - DB Action ";
                CCL.Status    = ConvertedCodeLine.eStatus.ConvertedToScript;
            }
        }