Beispiel #1
0
        //**********************************************************************
        /// <summary>
        /// Form action: Add device.
        /// </summary>
        public static void Add_Device(LxScriptItem item)
        {
            repo.NFormApp.NformG2Window.FormMain.Configure.Click();
            repo.NFormApp.NformG2Window.FormMain.Devices.Click();
            repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Add.Click();

            if (item.getArgText() == "SingleAuto")
            {
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Hostname_or_IP_address.PressKeys(item.getArg2Text());
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Obtain_setting_from_device.Check();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Finish.Click();
                Delay.Milliseconds(5000);
                repo.NFormApp.AddDeviceWizard.FormAdd_Device_Results.OK.Click();
                repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Close.Click();
            }
            if (item.getArgText() == "SingleManual")
            {
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Hostname_or_IP_address.PressKeys(item.getArg2Text());
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Obtain_setting_from_device.Uncheck();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Name.PressKeys(item.getArg3Text());
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Description.PressKeys(item.getArg4Text());
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Device_type.SelectedItemText     = item.getArg5Text();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Device_protocol.SelectedItemText = item.getArg6Text();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Finish.Click();
                Delay.Milliseconds(5000);
                repo.NFormApp.AddDeviceWizard.FormAdd_Device_Results.OK.Click();
                repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Close.Click();
            }

            if (item.getArgText() == "MultiSearch")
            {
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Discover_devices.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.DeleteRow.Click();
                while (repo.NFormApp.AddDeviceWizard.FormAdd_Device.DeleteRow.Enabled == true)
                {
                    repo.NFormApp.AddDeviceWizard.FormAdd_Device.DeleteRow.Click();
                }
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Search_device_table.Rows[1].Cells[0].Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Search_device_table.Rows[1].Cells[1].Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Search_device_table.Rows[1].Cells[1].Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Search_device_table.Rows[1].Cells[1].PressKeys(item.getArg2Text() + "{TAB}{CONTROL down}{Akey}{CONTROL up}" + item.getArg3Text());
                Delay.Duration(1000);
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                Delay.Duration(4000);
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Select_all.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Finish.Click();
                Delay.Duration(2000);
                repo.NFormApp.AddDeviceWizard.FormAdd_Device_Results.OK.Click();
                repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Close.Click();
            }
        }
Beispiel #2
0
        //**********************************************************************
        /// <summary>
        /// Form action: Add device.
        /// </summary>
        public static void Add_Device(LxScriptItem item)
        {
            repo.NFormApp.NformG2Window.FormMain.Configure.Click();
            repo.NFormApp.NformG2Window.FormMain.Devices.Click();
            repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Add.Click();

            if(item.getArgText() == "SingleAuto")
            {
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Hostname_or_IP_address.PressKeys(item.getArg2Text());
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Obtain_setting_from_device.Check();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Finish.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device_Results.OK.Click();
                repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Close.Click();
            }
            if(item.getArgText() == "SingleManual")
            {
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Hostname_or_IP_address.PressKeys(item.getArg2Text());
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Obtain_setting_from_device.Uncheck();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Name.PressKeys(item.getArg3Text());
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Description.PressKeys(item.getArg4Text());
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Device_type.SelectedItemText = item.getArg5Text();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Device_protocol.SelectedItemText = item.getArg6Text();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Finish.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device_Results.OK.Click();
                repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Close.Click();
            }

            if(item.getArgText() == "MultiSearch")
            {
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Discover_devices.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.DeleteRow.Click();
                while(repo.NFormApp.AddDeviceWizard.FormAdd_Device.DeleteRow.Enabled==true)
                {
                    repo.NFormApp.AddDeviceWizard.FormAdd_Device.DeleteRow.Click();
                }
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Search_device_table.Rows[1].Cells[0].Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Search_device_table.Rows[1].Cells[1].Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Search_device_table.Rows[1].Cells[1].Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Search_device_table.Rows[1].Cells[1].PressKeys(item.getArg2Text() + "{TAB}{CONTROL down}{Akey}{CONTROL up}" +item.getArg3Text());
                Delay.Duration(1000);
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                Delay.Duration(40000);
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Next.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Select_all.Click();
                repo.NFormApp.AddDeviceWizard.FormAdd_Device.Finish.Click();
                Delay.Duration(10000);
                repo.NFormApp.AddDeviceWizard.FormAdd_Device_Results.OK.Click();
                repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Close.Click();
            }
        }
Beispiel #3
0
 //**********************************************************************
 /// <summary>
 /// Form action: VerifyProperty equal, Contains, NotContains.
 /// </summary>
 public static void VerifyProperty(LxScriptItem item)
 {
     if (item.getArg2Text() == "Equal")
     {
         Validate.Attribute(item.getComponentInfo(), item.getArgText(), item.getArg3Text());
     }
     if (item.getArg2Text() == "Contains")
     {
         Validate.Attribute(item.getComponentInfo(), item.getArgText(), new Regex(Regex.Escape(item.getArg3Text())));
     }
     if (item.getArg2Text() == "NotContains")
     {
         Validate.Attribute(item.getComponentInfo(), item.getArgText(), new Regex("^((?!(" + Regex.Escape(item.getArg3Text()) + ")).)*$"));
     }
 }
Beispiel #4
0
        //**********************************************************************
        /// <summary>
        /// Send command to simulator, sent traps, change data OID values.
        /// </summary>
        public static void SendCommandToSimulator(LxScriptItem item)
        {
            string strDestination = item.getArgText();
            string IP             = "";
            string port           = "163";

            if (strDestination.IndexOf(":") != -1)
            {
                string[] spilt = strDestination.Split(':');
                //IP = strDestination.Substring(0,strDestination.IndexOf(":"));
                //port = strDestination.Substring(strDestination.IndexOf(":")+1,strDestination.Length - strDestination.IndexOf(":"));
                IP   = spilt[0];
                port = spilt[1];
            }
            else
            {
                IP = strDestination;
            }
            int    circle  = Convert.ToInt32(item.getArg2Text());
            string message = item.getArg3Text();

            IPAddress  GroupAddress = IPAddress.Parse(IP);
            int        GroupPort    = Convert.ToInt32(port);
            UdpClient  sender       = new UdpClient();
            IPEndPoint groupEP      = new IPEndPoint(GroupAddress, GroupPort);

            for (int i = 0; i < circle; i++)
            {
                byte[] bytes = StrToByteArray(message);
                sender.Send(bytes, bytes.Length, groupEP);
                Delay.Milliseconds(50);
            }

            sender.Close();
        }
Beispiel #5
0
        //**********************************************************************
        /// <summary>
        /// Open txt file, verify content contains or not contains given string.
        /// </summary>
        public static void VerifyTxtfileValues(LxScriptItem item)
        {
            string strPath     = item.getArgText();
            string strFileName = strPath.Substring(strPath.LastIndexOf("/") + 1, strPath.Length - strPath.LastIndexOf("/") - 1);
            string flag        = item.getArg3Text();       // flag=true, contains; flag=false, not contains.

            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            //startInfo.CreateNoWindow = true;
            startInfo.FileName = "notepad.exe";
            //startInfo.UseShellExecute = false;
            //startInfo.RedirectStandardOutput = true;
            //startInfo.RedirectStandardInput = true;
            startInfo.Arguments = " " + strPath;
            System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo);
            bool bContains = repo.ExternalApp.NotePad.MainContext.TextValue.IndexOf(item.getArg2Text()) == -1?false:true;

            Delay.Milliseconds(6000);
            process.Kill();
            if (flag.Equals("True"))
            {
                Validate.AreEqual(bContains, true);
            }
            else
            {
                Validate.AreEqual(bContains, false);
            }
        }
Beispiel #6
0
        //**********************************************************************
        /// <summary>
        /// Open excel file, verify content contains or not contains given string.
        /// </summary>
        public static void VerifyExcelfileValues(LxScriptItem item)
        {
            string strPath     = item.getArgText();
            string strFileName = strPath.Substring(strPath.LastIndexOf("/") + 1, strPath.Length - strPath.LastIndexOf("/") - 1);
            string mark        = item.getArg3Text();       // flag=true, contains; flag=false, not contains.

            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.FileName  = "excel.exe";
            startInfo.Arguments = " " + strPath;
            System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo);
            RepoItemInfo targetCellInfo        = new RepoItemInfo(repo.ExternalApp.FormExcel.TableEntityInfo.ParentFolder, "variableCell",
                                                                  repo.ExternalApp.FormExcel.TableEntityInfo.Path + "/row/cell[@text='" + item.getArg2Text() + "']",
                                                                  10000, null, System.Guid.NewGuid().ToString());


            Delay.Milliseconds(6000);
            bool bExists = targetCellInfo.Exists();

            process.Kill();
            if (mark.Equals("True"))
            {
                Validate.AreEqual(bExists, true);
            }
            else
            {
                Validate.AreEqual(bExists, false);
            }
        }
Beispiel #7
0
        //**********************************************************************
        /// <summary>
        /// Click to given items in the comoponet like List, Table and Tree.
        /// </summary>
        public static void Select_Item(LxScriptItem item)
        {
            object       objComponet     = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type         objType         = objComponet.GetType();

            //MessageBox.Show(objType.Name.ToString());

            if (objType.Name.ToString() == "List")
            {
                RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem",
                                                                   objComponetInfo.Path + "/listitem[@accessiblename='" + item.getArgText() + "']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.ListItem targetListItem = targetListItemInfo.CreateAdapter <Ranorex.ListItem>(true);
                targetListItem.Click();
            }

            if (objType.Name.ToString() == "Table")
            {
                RepoItemInfo targetCellInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableCell",
                                                               objComponetInfo.Path + "/row/cell[@text='" + item.getArgText() + "']",
                                                               10000, null, System.Guid.NewGuid().ToString());
                Ranorex.Cell targetCell = targetCellInfo.CreateAdapter <Ranorex.Cell>(true);
                targetCell.Click();
            }

            if (objType.Name.ToString() == "Tree")
            {
                int    treeLevel       = Convert.ToInt32(item.getArgText());
                string strTreelevel    = "";
                string strTreelevelCkb = "";
                for (int i = 1; i <= treeLevel; i++)
                {
                    strTreelevel    += "/treeitem";
                    strTreelevelCkb += "/checkbox";
                }

                RepoItemInfo targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem",
                                                                   objComponetInfo.Path + strTreelevel + "[@accessiblename='" + item.getArg2Text() + "']",
                                                                   10000, null, System.Guid.NewGuid().ToString());

                if (targetTreeItemInfo.Exists())
                {
                    Ranorex.TreeItem targetTreeItem = targetTreeItemInfo.CreateAdapter <Ranorex.TreeItem>(true);
                    targetTreeItem.Click();
                }
                else
                {
                    targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem1",
                                                          objComponetInfo.Path + strTreelevelCkb + "[@accessiblename='" + item.getArg2Text() + "']",
                                                          10000, null, System.Guid.NewGuid().ToString());
                    Ranorex.CheckBox targetTreeItemCkb = targetTreeItemInfo.CreateAdapter <Ranorex.CheckBox>(true);
                    targetTreeItemCkb.Click();
                }
            }
        }
Beispiel #8
0
        //**********************************************************************
        /// <summary>
        /// Click to the Cell by given index in the Table.
        /// </summary>
        public static void Click_Cell(LxScriptItem item)
        {
            object       objComponet     = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type         objType         = objComponet.GetType();

            if (objType.Name.ToString() == "Table")
            {
                Ranorex.Table tb = (Ranorex.Table)objComponet;
                tb.Rows[Convert.ToInt32(item.getArgText())].Cells[Convert.ToInt32(item.getArg2Text())].Click();
            }
        }
Beispiel #9
0
 //**********************************************************************
 /// <summary>
 /// Form action: Del device.
 /// </summary>
 public static void Del_Device(LxScriptItem item)
 {
     repo.NFormApp.NformG2Window.FormMain.Configure.Click();
     repo.NFormApp.NformG2Window.FormMain.Devices.Click();
     if (item.getArgText() == "SingleDel")
     {
         repo.myCustom = item.getArg2Text();
         repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.CellVariables.Click();
         repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Delete.Click();
         repo.NFormApp.ManagedDevicesWindow.FormConfirm_Device_Delete.Yes.Click();
     }
     if (item.getArgText() == "AllDel")
     {
         repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Managed_device_table.Click();
         repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Managed_device_table.PressKeys("{CONTROL down}{Akey}{CONTROL up}");
         repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Delete.Click();
         repo.NFormApp.ManagedDevicesWindow.FormConfirm_Device_Delete.Yes.Click();
         Delay.Duration(5000);
     }
     repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Close.Click();
 }
Beispiel #10
0
        //**********************************************************************
        /// <summary>
        /// DoubleClick to given items in the comoponet like List, Table and Tree.
        /// </summary>
        public static void DoubleClick_Item(LxScriptItem item)
        {
            object       objComponet     = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type         objType         = objComponet.GetType();

            //MessageBox.Show(objType.Name.ToString());

            if (objType.Name.ToString() == "List")
            {
                RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem",
                                                                   objComponetInfo.Path + "/listitem[@accessiblename='" + item.getArgText() + "']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.ListItem targetListItem = targetListItemInfo.CreateAdapter <Ranorex.ListItem>(true);
                targetListItem.DoubleClick();
            }

            if (objType.Name.ToString() == "Table")
            {
                RepoItemInfo targetCellInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableCell",
                                                               objComponetInfo.Path + "/row/cell[@text='" + item.getArgText() + "']",
                                                               10000, null, System.Guid.NewGuid().ToString());
                Ranorex.Cell targetCell = targetCellInfo.CreateAdapter <Ranorex.Cell>(true);
                targetCell.DoubleClick();
            }

            if (objType.Name.ToString() == "Tree")
            {
                int    treeLevel    = Convert.ToInt32(item.getArgText());
                string strTreelevel = "";
                for (int i = 1; i <= treeLevel; i++)
                {
                    strTreelevel += "/treeitem";
                }
                RepoItemInfo targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem",
                                                                   objComponetInfo.Path + strTreelevel + "[@accessiblename='" + item.getArg2Text() + "']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.TreeItem targetTreeItem = targetTreeItemInfo.CreateAdapter <Ranorex.TreeItem>(true);
                targetTreeItem.DoubleClick();

                /*
                 *           Ranorex.Control treeViewControl = targetTreeItem.Element.As<Ranorex.Control>();
                 *                           System.Windows.Forms.TreeNode node = treeViewControl.InvokeMethod(
                 *                           "GetNodeAt",
                 *                           new object[] { targetTreeItem.Element.ClientRectangle.Location + new Size(1, 1) })
                 *                               as System.Windows.Forms.TreeNode;
                 *           object mynode = node.GetLifetimeService();
                 *           Ranorex.CheckBox mycheckbox = (Ranorex.CheckBox)mynode;
                 *           mycheckbox.Check();
                 */
            }
        }
Beispiel #11
0
        //**********************************************************************
        /// <summary>
        /// Input Cell by given index in the Table.
        /// </summary>
        public static void Input_Cell(LxScriptItem item)
        {
            object       objComponet     = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type         objType         = objComponet.GetType();

            if (objType.Name.ToString() == "Table")
            {
                Ranorex.Table tb = (Ranorex.Table)objComponet;
                tb.Rows[Convert.ToInt32(item.getArgText())].Cells[Convert.ToInt32(item.getArg2Text())].DoubleClick();
                Keyboard.Press("{CONTROL down}{Akey}{CONTROL up}" + item.getArg3Text());
            }
        }
Beispiel #12
0
        //**********************************************************************
        /// <summary>
        /// Copy Copydata from Trends graph to one txt file.
        /// </summary>
        public static void CopyDataToFile(LxScriptItem item)
        {
            string      strFilePath = item.getArgText();
            IDataObject iData       = Clipboard.GetDataObject();

            if (iData.GetDataPresent(DataFormats.StringFormat))
            {
                string s_value = (string)iData.GetData(DataFormats.StringFormat);
                Console.WriteLine("Clipboard is:" + s_value);
                Write_text(@strFilePath, s_value);
            }
            else
            {
                Console.WriteLine("Clipboard can not convert to text string!");
            }
        }
Beispiel #13
0
        //**********************************************************************
        /// <summary>
        /// Verify the comoponet like List, Table and Tree not contains given items.
        /// </summary>
        public static void VerifyNotContains(LxScriptItem item)
        {
            object       objComponet     = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type         objType         = objComponet.GetType();

            if (objType.Name.ToString() == "List")
            {
                RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem",
                                                                   objComponetInfo.Path + "/listitem[@accessiblename='" + item.getArgText() + "']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Validate.AreEqual(targetListItemInfo.Exists(), false);
            }

            if (objType.Name.ToString() == "Table")
            {
                RepoItemInfo targetCellInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableCell",
                                                               objComponetInfo.Path + "/row/cell[@text='" + item.getArgText() + "']",
                                                               10000, null, System.Guid.NewGuid().ToString());
                Validate.AreEqual(targetCellInfo.Exists(), false);
            }

            if (objType.Name.ToString() == "Tree")
            {
                int    treeLevel    = Convert.ToInt32(item.getArgText());
                string strTreelevel = "";
                for (int i = 1; i <= treeLevel; i++)
                {
                    strTreelevel += "/treeitem";
                }
                RepoItemInfo targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem",
                                                                   objComponetInfo.Path + strTreelevel + "[@accessiblename='" + item.getArg2Text() + "']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Validate.AreEqual(targetTreeItemInfo.Exists(), false);
            }
        }
Beispiel #14
0
        //**********************************************************************
        /// <summary>
        /// Form action: VerifyProperty equal, Contains, NotContains.
        /// </summary>
        public static void VerifyProperty(LxScriptItem item)
        {
            //MessageBox.Show(item.getComponent().ToString());
            // The component is lable
            string testtemp = item.getComponent().ToString();
            if(item.getComponent().ToString().IndexOf("Lbl") != -1)
            {
                Ranorex.NativeWindow nativeWnd = item.getComponentInfo().CreateAdapter<Ranorex.NativeWindow>(false);
                string lableText = nativeWnd.WindowText;

                if(item.getArg2Text() == "Equal")
                {string abc = item.getArg3Text();
                    Validate.AreEqual(lableText, item.getArg3Text());
                }
                if(item.getArg2Text() == "Contains")
                {
                    int iFlag = lableText.IndexOf(item.getArg3Text());
                    Validate.IsTrue(iFlag != -1);
                }
                if(item.getArg2Text() == "NotContains")
                {
                    int iFlag = lableText.IndexOf(item.getArg3Text());
                    Validate.IsTrue(iFlag == -1);
                }
                return;
            }

            if(item.getArg2Text() == "Equal")
            {
                Validate.Attribute(item.getComponentInfo(), item.getArgText(), item.getArg3Text());
            }
            if(item.getArg2Text() == "Contains")
            {
                Validate.Attribute(item.getComponentInfo(), item.getArgText(), new Regex(Regex.Escape(item.getArg3Text())));
            }
            if(item.getArg2Text() == "NotContains")
            {
                Validate.Attribute(item.getComponentInfo(), item.getArgText(), new Regex("^((?!("+Regex.Escape(item.getArg3Text())+")).)*$"));
            }

            if(item.getArg2Text() == "ListContains")
            {
                bool Resultflag = false;
                object objComponet = item.getComponent();
                Ranorex.ComboBox myComboBox = (Ranorex.ComboBox)(objComponet);
                Ranorex.Button btn = myComboBox.FindSingle("./button");
                btn.Click();
                List lst = "/list";
                foreach (ListItem lst_item in lst.FindChildren<ListItem>())
                {
                    if((lst_item.Text).Equals(item.getArg3Text()))
                    {
                        Resultflag = true;
                        break;
                    }
                }
                btn.Click();
                Validate.AreEqual(Resultflag,true);

            }
        }
Beispiel #15
0
        //**********************************************************************
        /// <summary>
        /// Open txt file, verify content contains or not contains given string.
        /// </summary>
        public static void VerifyTxtfileValues(LxScriptItem item)
        {
            string strPath = item.getArgText();
            string strFileName = strPath.Substring(strPath.LastIndexOf("/") + 1,strPath.Length - strPath.LastIndexOf("/") -1);
            string flag = item.getArg3Text();  // flag=true, contains; flag=false, not contains.

            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
               			//startInfo.CreateNoWindow = true;
               			startInfo.FileName = "notepad.exe";
            //startInfo.UseShellExecute = false;
            //startInfo.RedirectStandardOutput = true;
            //startInfo.RedirectStandardInput = true;
               			startInfo.Arguments = " " + strPath;
               			System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo);
               			bool bContains = repo.ExternalApp.NotePad.MainContext.TextValue.IndexOf(item.getArg2Text())==-1?false:true;

               			Delay.Milliseconds(6000);
            process.Kill();
            if(flag.Equals("True"))
                Validate.AreEqual(bContains,true);
            else
                Validate.AreEqual(bContains,false);
        }
Beispiel #16
0
        //**********************************************************************
        /// <summary>
        /// Execute one command, parse the command.
        /// </summary>
        public static bool executeCommand(LxScriptItem item)
        {
            if(item.m_Type == "F")
            {
                return executeFormCommand(item);
            }

            if(item.m_Type == "C" && item.m_WindowName == "Pause")
            {
                Delay.Milliseconds(Convert.ToInt32(item.m_Component) * 1000);
                return true;
            }

            if(item.m_Type == "C" && item.m_WindowName == "VerifyTxtfileValues")
            {
                VerifyTxtfileValues(item);
                return true;
            }

            if(item.m_Type == "C" && item.m_WindowName == "VerifyExcelfileValues")
            {
                VerifyExcelfileValues(item);
                return true;
            }

            if(item.m_Type == "C" && item.m_WindowName == "SendCommandToSimulator")
            {
                SendCommandToSimulator(item);
                return true;
            }

            if(item.m_Type == "C" && item.m_WindowName == "CopyDataToFile")
            {
                CopyDataToFile(item);
                return true;
            }

            if(item.m_Type == "C" && item.m_WindowName == "LaunchApplication")
            {
                AppStart(item);
                return true;
            }

            if(item.m_Type == "C" && item.m_WindowName == "DeleteLocalFile")
            {

                DeleteLocalFile(item);
                return true;
            }

            if(item.m_Type == "C" && item.m_WindowName == "CloseApplication")
            {
                AppClose(item);
                return true;
            }

            if(item.m_Type.Substring(0,1) == ";")
            {
                return true;
            }

            if(item.m_Action == "Exists")
            {
                Validate.Exists(item.getComponentInfo());
                return true;
            }

            if(item.m_Action == "NotExists")
            {
                Validate.NotExists(item.getComponentInfo());
                return true;
            }

            if(item.m_Action == "VerifyProperty")
            {
                //PropertyInfo property = objType.GetProperty(item.m_Arg1);
                //property.GetValue(objComponet, null).ToString();
                //Validate.Attribute(item.getComponentInfo(),item.m_Arg1,item.m_Arg2);
                //Validate.Attribute(
                VerifyProperty(item);
                return true;
            }

            object[] arg = (object[])m_ActionMap[item.m_Action];
            MethodInfo method = null;
            object[] parameters = null;

            if(arg[1].ToString() == "S2")
            {
                repo.myCustom = item.getArgText();
            }
            if(item.m_Index == "33")
            {
                Delay.Milliseconds(2000);
            }
            object objComponet = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type objType = objComponet.GetType();

            if(arg[1].ToString() == "0" || arg[1].ToString() == "S2")
            {
                method = objType.GetMethod(arg[0].ToString(),
                                                  new Type[]{});
                parameters = new object[]{};
            }
            if(arg[1].ToString() == "1")
            {
                method = objType.GetMethod(arg[0].ToString(),
                                                  new Type[]{ typeof (string)});
                parameters = new object[]{item.getArgText()};
            }
            if(arg[1].ToString() == "S1")
            {
                PropertyInfo pi = objType.GetProperty(arg[0].ToString());
                pi.SetValue(objComponet,item.getArgText(),null);
                return true;
            }

            if(arg[1].ToString() == "S3")
            {
                method = objType.GetMethod(arg[0].ToString(),
                                                  new Type[]{typeof (string)});
                parameters = new object[]{item.getArgText()};
                PropertyInfo pi = objType.GetProperty("TextValue")!=null?objType.GetProperty("TextValue"):objType.GetProperty("Text");
                pi.SetValue(objComponet,"",null);
            }

            if(arg[1].ToString() == "S4")
            {
                Select_Item(item);
                return true;
            }

            if(arg[1].ToString() == "S5")
            {
                method = objType.GetMethod(arg[0].ToString(),
                                                  new Type[]{ });
                parameters = new object[]{};
                method.Invoke(objComponet,parameters);
                Delay.Milliseconds(1500);
                Validate.AreEqual(Ranorex.ToolTip.Current.Text,item.getArgText());
                return true;
            }

            if(arg[1].ToString() == "S6")
            {
                VerifyContains(item);
                return true;
            }

            if(arg[1].ToString() == "S7")
            {
                VerifyNotContains(item);
                return true;
            }

            if(arg[1].ToString() == "S8")
            {
                MoveTo(item);
                return true;
            }

            if(arg[1].ToString() == "S9")
            {
                Click_Cell(item);
                return true;
            }

            if(arg[1].ToString() == "S10")
            {
                DoubleClick_Item(item);
                return true;
            }

            if(arg[1].ToString() == "S11")
            {
                RightClick_Item(item);
                return true;
            }

            if(arg[1].ToString() == "S12")
            {
                Input_Cell(item);
                return true;
            }

               	method.Invoke(objComponet,parameters);
               	return true;
        }
Beispiel #17
0
        //**********************************************************************
        /// <summary>
        /// Execute one command, parse the command.
        /// </summary>
        public static bool executeCommand(LxScriptItem item)
        {
            if (item.m_Type == "F")
            {
                return(executeFormCommand(item));
            }

            if (item.m_Type == "C" && item.m_WindowName == "Pause")
            {
                Delay.Milliseconds(Convert.ToInt32(item.m_Component) * 1000);
                return(true);
            }

            if (item.m_Type == "C" && item.m_WindowName == "VerifyTxtfileValues")
            {
                VerifyTxtfileValues(item);
                return(true);
            }

            if (item.m_Type == "C" && item.m_WindowName == "VerifyExcelfileValues")
            {
                VerifyExcelfileValues(item);
                return(true);
            }

            if (item.m_Type == "C" && item.m_WindowName == "SendCommandToSimulator")
            {
                SendCommandToSimulator(item);
                return(true);
            }

            if (item.m_Type == "C" && item.m_WindowName == "CopyDataToFile")
            {
                CopyDataToFile(item);
                return(true);
            }

            if (item.m_Type == "C" && item.m_WindowName == "LaunchApplication")
            {
                AppStart(item);
                return(true);
            }

            if (item.m_Type == "C" && item.m_WindowName == "DeleteLocalFile")
            {
                DeleteLocalFile(item);
                return(true);
            }

            if (item.m_Type == "C" && item.m_WindowName == "CloseApplication")
            {
                AppClose(item);
                return(true);
            }

            if (item.m_Type.Substring(0, 1) == ";")
            {
                return(true);
            }

            if (item.m_Action == "Exists")
            {
                Validate.Exists(item.getComponentInfo());
                return(true);
            }

            if (item.m_Action == "NotExists")
            {
                Validate.NotExists(item.getComponentInfo());
                return(true);
            }

            if (item.m_Action == "VerifyProperty")
            {
                //PropertyInfo property = objType.GetProperty(item.m_Arg1);
                //property.GetValue(objComponet, null).ToString();
                //Validate.Attribute(item.getComponentInfo(),item.m_Arg1,item.m_Arg2);
                //Validate.Attribute(
                VerifyProperty(item);
                return(true);
            }

            object[]   arg    = (object[])m_ActionMap[item.m_Action];
            MethodInfo method = null;

            object[] parameters = null;

            if (arg[1].ToString() == "S2")
            {
                repo.myCustom = item.getArgText();
            }
            if (item.m_Index == "33")
            {
                Delay.Milliseconds(2000);
            }
            object       objComponet     = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type         objType         = objComponet.GetType();

            if (arg[1].ToString() == "0" || arg[1].ToString() == "S2")
            {
                method = objType.GetMethod(arg[0].ToString(),
                                           new Type[] {});
                parameters = new object[] {};
            }
            if (arg[1].ToString() == "1")
            {
                method = objType.GetMethod(arg[0].ToString(),
                                           new Type[] { typeof(string) });
                parameters = new object[] { item.getArgText() };
            }
            if (arg[1].ToString() == "S1")
            {
                PropertyInfo pi = objType.GetProperty(arg[0].ToString());
                pi.SetValue(objComponet, item.getArgText(), null);
                return(true);
            }

            if (arg[1].ToString() == "S3")
            {
                method = objType.GetMethod(arg[0].ToString(),
                                           new Type[] { typeof(string) });
                parameters = new object[] { item.getArgText() };
                PropertyInfo pi = objType.GetProperty("TextValue") != null?objType.GetProperty("TextValue") : objType.GetProperty("Text");

                pi.SetValue(objComponet, "", null);
            }

            if (arg[1].ToString() == "S4")
            {
                Select_Item(item);
                return(true);
            }

            if (arg[1].ToString() == "S5")
            {
                method = objType.GetMethod(arg[0].ToString(),
                                           new Type[] { });
                parameters = new object[] {};
                method.Invoke(objComponet, parameters);
                Delay.Milliseconds(1500);
                Validate.AreEqual(Ranorex.ToolTip.Current.Text, item.getArgText());
                return(true);
            }

            if (arg[1].ToString() == "S6")
            {
                VerifyContains(item);
                return(true);
            }

            if (arg[1].ToString() == "S7")
            {
                VerifyNotContains(item);
                return(true);
            }

            if (arg[1].ToString() == "S8")
            {
                MoveTo(item);
                return(true);
            }

            if (arg[1].ToString() == "S9")
            {
                Click_Cell(item);
                return(true);
            }

            if (arg[1].ToString() == "S10")
            {
                DoubleClick_Item(item);
                return(true);
            }

            if (arg[1].ToString() == "S11")
            {
                RightClick_Item(item);
                return(true);
            }

            if (arg[1].ToString() == "S12")
            {
                Input_Cell(item);
                return(true);
            }

            if (arg[1].ToString() == "S13")             //click location
            {
                Adapter adapterObj = (Adapter)objComponet;
                int     x_loc      = Convert.ToInt16(item.m_Arg2);
                int     y_loc      = Convert.ToInt16(item.m_Arg3);
                adapterObj.Click((item.m_Arg1.Equals("right") ? MouseButtons.Right : MouseButtons.Left), new Location(x_loc, y_loc));
            }


            method.Invoke(objComponet, parameters);
            return(true);
        }
Beispiel #18
0
        //**********************************************************************
        /// <summary>
        /// Form action: VerifyProperty equal, Contains, NotContains.
        /// </summary>
        public static void VerifyProperty(LxScriptItem item)
        {
            //MessageBox.Show(item.getComponent().ToString());
            // The component is lable
            string testtemp = item.getComponent().ToString();

            if (item.getComponent().ToString().IndexOf("Lbl") != -1)
            {
                Ranorex.NativeWindow nativeWnd = item.getComponentInfo().CreateAdapter <Ranorex.NativeWindow>(false);
                string lableText = nativeWnd.WindowText;

                if (item.getArg2Text() == "Equal")
                {
                    string abc = item.getArg3Text();
                    Validate.AreEqual(lableText, item.getArg3Text());
                }
                if (item.getArg2Text() == "Contains")
                {
                    int iFlag = lableText.IndexOf(item.getArg3Text());
                    Validate.IsTrue(iFlag != -1);
                }
                if (item.getArg2Text() == "NotContains")
                {
                    int iFlag = lableText.IndexOf(item.getArg3Text());
                    Validate.IsTrue(iFlag == -1);
                }
                return;
            }

            if (item.getArg2Text() == "Equal")
            {
                Validate.Attribute(item.getComponentInfo(), item.getArgText(), item.getArg3Text());
            }
            if (item.getArg2Text() == "Contains")
            {
                Validate.Attribute(item.getComponentInfo(), item.getArgText(), new Regex(Regex.Escape(item.getArg3Text())));
            }
            if (item.getArg2Text() == "NotContains")
            {
                Validate.Attribute(item.getComponentInfo(), item.getArgText(), new Regex("^((?!(" + Regex.Escape(item.getArg3Text()) + ")).)*$"));
            }

            if (item.getArg2Text() == "ListContains")
            {
                bool             Resultflag  = false;
                object           objComponet = item.getComponent();
                Ranorex.ComboBox myComboBox  = (Ranorex.ComboBox)(objComponet);
                Ranorex.Button   btn         = myComboBox.FindSingle("./button");
                btn.Click();
                List lst = "/list";
                foreach (ListItem lst_item in lst.FindChildren <ListItem>())
                {
                    if ((lst_item.Text).Equals(item.getArg3Text()))
                    {
                        Resultflag = true;
                        break;
                    }
                }
                btn.Click();
                Validate.AreEqual(Resultflag, true);
            }
        }
Beispiel #19
0
        //**********************************************************************
        /// <summary>
        /// Input Cell by given index in the Table.
        /// </summary>
        public static void Input_Cell(LxScriptItem item)
        {
            object objComponet = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type objType = objComponet.GetType();

            if(objType.Name.ToString() == "Table")
            {
                Ranorex.Table tb = (Ranorex.Table)objComponet;
                tb.Rows[Convert.ToInt32(item.getArgText())].Cells[Convert.ToInt32(item.getArg2Text())].DoubleClick();
                Keyboard.Press("{CONTROL down}{Akey}{CONTROL up}"+item.getArg3Text());
            }
        }
Beispiel #20
0
        //**********************************************************************
        /// <summary>
        /// Click to the Cell by given index in the Table.
        /// </summary>
        public static void Click_Cell(LxScriptItem item)
        {
            object objComponet = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type objType = objComponet.GetType();

            if(objType.Name.ToString() == "Table")
            {
                Ranorex.Table tb = (Ranorex.Table)objComponet;
                tb.Rows[Convert.ToInt32(item.getArgText())].Cells[Convert.ToInt32(item.getArg2Text())].Click();
            }
        }
Beispiel #21
0
        //**********************************************************************
        /// <summary>
        /// DoubleClick to given items in the comoponet like List, Table and Tree.
        /// </summary>
        public static void DoubleClick_Item(LxScriptItem item)
        {
            object objComponet = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type objType = objComponet.GetType();

            //MessageBox.Show(objType.Name.ToString());

            if(objType.Name.ToString() == "List")
            {
                RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem",
                                                                   objComponetInfo.Path + "/listitem[@accessiblename='"+ item.getArgText() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.ListItem targetListItem = targetListItemInfo.CreateAdapter<Ranorex.ListItem>(true);
                targetListItem.DoubleClick();
            }

            if(objType.Name.ToString() == "Table")
            {
                RepoItemInfo targetCellInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableCell",
                                                                   objComponetInfo.Path + "/row/cell[@text='"+ item.getArgText() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.Cell targetCell = targetCellInfo.CreateAdapter<Ranorex.Cell>(true);
                targetCell.DoubleClick();
            }

            if(objType.Name.ToString() == "Tree")
            {
                int treeLevel = Convert.ToInt32(item.getArgText());
                string strTreelevel = "";
                for(int i = 1 ; i <= treeLevel; i++)
                {
                    strTreelevel += "/treeitem";
                }
                RepoItemInfo targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem",
                                                                   objComponetInfo.Path + strTreelevel +"[@accessiblename='"+ item.getArg2Text() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.TreeItem targetTreeItem = targetTreeItemInfo.CreateAdapter<Ranorex.TreeItem>(true);
                targetTreeItem.DoubleClick();
               /*
                Ranorex.Control treeViewControl = targetTreeItem.Element.As<Ranorex.Control>();
                System.Windows.Forms.TreeNode node = treeViewControl.InvokeMethod(
                                "GetNodeAt",
                                new object[] { targetTreeItem.Element.ClientRectangle.Location + new Size(1, 1) })
                                    as System.Windows.Forms.TreeNode;
                object mynode = node.GetLifetimeService();
                Ranorex.CheckBox mycheckbox = (Ranorex.CheckBox)mynode;
                mycheckbox.Check();
            */

            }
        }
Beispiel #22
0
        //**********************************************************************
        /// <summary>
        /// Verify the comoponet like List, Table and Tree not contains given items.
        /// </summary>
        public static void VerifyNotContains(LxScriptItem item)
        {
            object objComponet = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type objType = objComponet.GetType();

            if(objType.Name.ToString() == "List")
            {
                RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem",
                                                                   objComponetInfo.Path + "/listitem[@accessiblename='"+ item.getArgText() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Validate.AreEqual(targetListItemInfo.Exists(),false);
            }

            if(objType.Name.ToString() == "Table")
            {
                RepoItemInfo targetCellInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableCell",
                                                                   objComponetInfo.Path + "/row/cell[@text='"+ item.getArgText() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Validate.AreEqual(targetCellInfo.Exists(),false);
            }

            if(objType.Name.ToString() == "Tree")
            {
                int treeLevel = Convert.ToInt32(item.getArgText());
                string strTreelevel = "";
                for(int i = 1 ; i <= treeLevel; i++)
                {
                    strTreelevel += "/treeitem";
                }
                RepoItemInfo targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem",
                                                                   objComponetInfo.Path + strTreelevel +"[@accessiblename='"+ item.getArg2Text() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Validate.AreEqual(targetTreeItemInfo.Exists(),false);
            }
        }
Beispiel #23
0
 //**********************************************************************
 /// <summary>
 /// Form action: VerifyProperty equal, Contains, NotContains.
 /// </summary>
 public static void VerifyProperty(LxScriptItem item)
 {
     if(item.getArg2Text() == "Equal")
     {
         Validate.Attribute(item.getComponentInfo(), item.getArgText(), item.getArg3Text());
     }
     if(item.getArg2Text() == "Contains")
     {
         Validate.Attribute(item.getComponentInfo(), item.getArgText(), new Regex(Regex.Escape(item.getArg3Text())));
     }
     if(item.getArg2Text() == "NotContains")
     {
         Validate.Attribute(item.getComponentInfo(), item.getArgText(), new Regex("^((?!("+Regex.Escape(item.getArg3Text())+")).)*$"));
     }
 }
Beispiel #24
0
 //**********************************************************************
 /// <summary>
 /// Copy Copydata from Trends graph to one txt file.
 /// </summary>
 public static void CopyDataToFile(LxScriptItem item)
 {
     string strFilePath = item.getArgText();
     IDataObject iData = Clipboard.GetDataObject();
     if(iData.GetDataPresent(DataFormats.StringFormat))
     {
         string s_value = (string)iData.GetData(DataFormats.StringFormat);
         Console.WriteLine("Clipboard is:" + s_value);
         Write_text(@strFilePath, s_value);
     }
     else
     {
         Console.WriteLine("Clipboard can not convert to text string!");
     }
 }
Beispiel #25
0
        //**********************************************************************
        /// <summary>
        /// Send command to simulator, sent traps, change data OID values.
        /// </summary>
        public static void SendCommandToSimulator(LxScriptItem item)
        {
            string strDestination = item.getArgText();
            string IP = "";
            string port = "163";
            if(strDestination.IndexOf(":") != -1)
            {
                string[] spilt = strDestination.Split(':');
                //IP = strDestination.Substring(0,strDestination.IndexOf(":"));
                //port = strDestination.Substring(strDestination.IndexOf(":")+1,strDestination.Length - strDestination.IndexOf(":"));
                IP = spilt[0];
                port = spilt[1];
            }
            else
            {
                IP = strDestination;
            }
            int circle = Convert.ToInt32(item.getArg2Text());
            string message = item.getArg3Text();

            IPAddress GroupAddress = IPAddress.Parse(IP);
            int GroupPort = Convert.ToInt32(port);
            UdpClient sender = new UdpClient();
            IPEndPoint groupEP = new IPEndPoint(GroupAddress, GroupPort);
            for(int i = 0;i < circle; i++)
            {
                byte[] bytes = StrToByteArray(message);
                sender.Send(bytes, bytes.Length, groupEP);
                Delay.Milliseconds(50);
            }

            sender.Close();
        }
Beispiel #26
0
        //**********************************************************************
        /// <summary>
        /// Click to given items in the comoponet like List, Table and Tree.
        /// </summary>
        public static void Select_Item(LxScriptItem item)
        {
            object objComponet = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type objType = objComponet.GetType();

            //MessageBox.Show(objType.Name.ToString());

            if(objType.Name.ToString() == "List")
            {
                RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem",
                                                                   objComponetInfo.Path + "/listitem[@accessiblename='"+ item.getArgText() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.ListItem targetListItem = targetListItemInfo.CreateAdapter<Ranorex.ListItem>(true);
                targetListItem.Click();
            }

            if(objType.Name.ToString() == "Table")
            {
                RepoItemInfo targetCellInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableCell",
                                                                   objComponetInfo.Path + "/row/cell[@text='"+ item.getArgText() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.Cell targetCell = targetCellInfo.CreateAdapter<Ranorex.Cell>(true);
                targetCell.Click();
            }

            if(objType.Name.ToString() == "Tree")
            {

                String Xpos = " ";
                String Ypos = " ";
                String sPoint ="0;0";

                if((!(item.getArg3Text().Trim().Equals("")))&&(!(item.getArg4Text().Trim().Equals(""))))
                {
                    Xpos = item.getArg3Text();
                    Ypos = item.getArg4Text();
                    sPoint =Xpos+";"+Ypos;
                }

                int treeLevel = Convert.ToInt32(item.getArgText());
                string strTreelevel = "";
                string strTreelevelCkb = "";
                for(int i = 1 ; i <= treeLevel; i++)
                {
                    strTreelevel += "/treeitem";
                    strTreelevelCkb += "/checkbox";
                }

                RepoItemInfo targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem",
                                                                   objComponetInfo.Path + strTreelevel +"[@accessiblename='"+ item.getArg2Text() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());

                if(targetTreeItemInfo.Exists())
                {
                    Ranorex.TreeItem targetTreeItem = targetTreeItemInfo.CreateAdapter<Ranorex.TreeItem>(true);

                    targetTreeItem.Click(sPoint);
                }
                else
                {
                    targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem1",
                                                                   objComponetInfo.Path + strTreelevelCkb +"[@accessiblename='"+ item.getArg2Text() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                    Ranorex.CheckBox targetTreeItemCkb = targetTreeItemInfo.CreateAdapter<Ranorex.CheckBox>(true);
                    targetTreeItemCkb.Click(sPoint);
                }

            }
        }
Beispiel #27
0
        //**********************************************************************
        /// <summary>
        /// Move mouse to given items in the comoponet like List, Table and Tree.
        /// </summary>
        public static void MoveTo(LxScriptItem item)
        {
            object objComponet = item.getComponent();
            RepoItemInfo objComponetInfo = item.getComponentInfo();
            Type objType = objComponet.GetType();

            //MessageBox.Show(objType.Name.ToString());

            if(objType.Name.ToString() == "List")
            {
                RepoItemInfo targetListItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableListItem",
                                                                   objComponetInfo.Path + "/listitem[@accessiblename='"+ item.getArgText() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.ListItem targetListItem = targetListItemInfo.CreateAdapter<Ranorex.ListItem>(true);
                targetListItem.MoveTo();
            }

            if(objType.Name.ToString() == "Table")
            {
                RepoItemInfo targetCellInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableCell",
                                                                   objComponetInfo.Path + "/row/cell[@text='"+ item.getArgText() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.Cell targetCell = targetCellInfo.CreateAdapter<Ranorex.Cell>(true);
                targetCell.MoveTo();
            }

            if(objType.Name.ToString() == "Tree")
            {
                int treeLevel = Convert.ToInt32(item.getArgText());
                string strTreelevel = "";
                for(int i = 1 ; i <= treeLevel; i++)
                {
                    strTreelevel += "/treeitem";
                }
                RepoItemInfo targetTreeItemInfo = new RepoItemInfo(objComponetInfo.ParentFolder, "variableTreeItem",
                                                                   objComponetInfo.Path + strTreelevel +"[@accessiblename='"+ item.getArg2Text() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());
                Ranorex.TreeItem targetTreeItem = targetTreeItemInfo.CreateAdapter<Ranorex.TreeItem>(true);
                targetTreeItem.MoveTo();
            }
        }
Beispiel #28
0
 //**********************************************************************
 /// <summary>
 /// Form action: Login in.
 /// </summary>
 public static void Login(LxScriptItem item)
 {
     repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Username.PressKeys(item.getArgText());
     repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Password.PressKeys(item.getArg2Text());
     repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.ServerCombo.PressKeys(item.getArg3Text());
     repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Login.Click();
     Delay.Milliseconds(3000);
     //	if(repo.NFormApp.LogintoLiebertNformWindow.FormEvaluation_Period_Expiration.OKInfo.Exists())
     //	{
     //		repo.NFormApp.LogintoLiebertNformWindow.FormEvaluation_Period_Expiration.OK.Click();
     //	}
     //	if(repo.NFormApp.LicensesWindow.FormReminder.RawTextNoInfo.Exists())
     //	{
     //		repo.NFormApp.LicensesWindow.FormReminder.RawTextNo.Click("53;10");
     //	}
 }
		/// <summary>
		/// Verify content contains or not contains Error in Server.log and Viewer.log
		/// </summary>
		/// <param name="item">item</param>
		public static void VerifyErrorInLog(LxScriptItem item)
		{
			string strPath = item.getArgText();
			string strFileName = strPath.Substring(strPath.LastIndexOf("/") + 1,strPath.Length - strPath.LastIndexOf("/") -1);
			string flag = item.getArg3Text();  // flag=true, contains; flag=false, not contains.
			
			
			//Add some constant strings in Server.log and Viewer.log
			//These three error infos are added when simulator devices are added, so we need to ignore these infos
			string strConstantError = "Error configuring web card for";
			string strConstantErrorCode = "ErrorCode=10061";
			string strConstantErrorPerforming = "Error performing the request";
			string strError = "Error";
			bool bContains = false;
			
			
			System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
   			startInfo.FileName = "notepad.exe";
   			startInfo.Arguments = " " + strPath;
   			System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo); 
   			string strLogFile = repo.ExternalApp.NotePad.MainContext.TextValue;
   			if(strLogFile.LastIndexOf(strError)!=-1)
   			{
	   			string strLogOne = strLogFile.Substring(strLogFile.LastIndexOf(strError), strConstantError.Length);
	   			string strLogTwo = strLogFile.Substring(strLogFile.LastIndexOf(strError), strConstantErrorCode.Length);
	   			string strLogThree = strLogFile.Substring(strLogFile.LastIndexOf(strError), strConstantErrorPerforming.Length);
	   			
	   			if((strConstantError!=strLogOne)&&(strConstantErrorCode!=strLogTwo)&&(strConstantErrorPerforming!=strLogThree))
	   			   bContains = true;
   			}
   			   
   			Delay.Milliseconds(6000);
			process.Kill();
		
			if(flag.Equals("True"))
				Validate.AreEqual(bContains,true);
			else
				Validate.AreEqual(bContains,false);
		}
Beispiel #30
0
 //**********************************************************************
 /// <summary>
 /// Form action: Login in.
 /// </summary>
 public static void Login(LxScriptItem item)
 {
     repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Username.PressKeys(item.getArgText());
     repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Password.PressKeys(item.getArg2Text());
     repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.ServerCombo.PressKeys(item.getArg3Text());
     repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Login.Click();
     Delay.Milliseconds(3000);
     if (repo.NFormApp.LogintoLiebertNformWindow.FormEvaluation_Period_Expiration.OKInfo.Exists())
     {
         repo.NFormApp.LogintoLiebertNformWindow.FormEvaluation_Period_Expiration.OK.Click();
     }
 }
Beispiel #31
0
        //**********************************************************************
        /// <summary>
        /// Open excel file, verify content contains or not contains given string.
        /// </summary>
        public static void VerifyExcelfileValues(LxScriptItem item)
        {
            string strPath = item.getArgText();
            string strFileName = strPath.Substring(strPath.LastIndexOf("/") + 1,strPath.Length - strPath.LastIndexOf("/") -1);
            string mark = item.getArg3Text();  // flag=true, contains; flag=false, not contains.

            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
               			startInfo.FileName = "excel.exe";
               			startInfo.Arguments = " " + strPath;
               			System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo);
               			RepoItemInfo targetCellInfo = new RepoItemInfo(repo.ExternalApp.FormExcel.TableEntityInfo.ParentFolder, "variableCell",
                                                                   repo.ExternalApp.FormExcel.TableEntityInfo.Path + "/row/cell[@text='"+ item.getArg2Text() +"']",
                                                                   10000, null, System.Guid.NewGuid().ToString());

               			Delay.Milliseconds(6000);
               			bool bExists = targetCellInfo.Exists();
            process.Kill();
            if(mark.Equals("True"))
                Validate.AreEqual(bExists,true);
            else
                Validate.AreEqual(bExists,false);
        }
Beispiel #32
0
 //**********************************************************************
 /// <summary>
 /// Form action: Del device.
 /// </summary>
 public static void Del_Device(LxScriptItem item)
 {
     repo.NFormApp.NformG2Window.FormMain.Configure.Click();
     repo.NFormApp.NformG2Window.FormMain.Devices.Click();
     if(item.getArgText() == "SingleDel")
     {
         repo.myCustom = item.getArg2Text();
         repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.CellVariables.Click();
         repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Delete.Click();
         repo.NFormApp.ManagedDevicesWindow.FormConfirm_Device_Delete.Yes.Click();
     }
     if(item.getArgText() == "AllDel")
     {
         repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Managed_device_table.Click();
         repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Managed_device_table.PressKeys("{CONTROL down}{Akey}{CONTROL up}");
         repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Delete.Click();
         repo.NFormApp.ManagedDevicesWindow.FormConfirm_Device_Delete.Yes.Click();
         Delay.Duration(5000);
     }
     repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Close.Click();
 }