Пример #1
0
        /// <summary>
        /// The active event radio button.
        /// </summary>
        /// <param name="diagnosticEvent">
        /// The diagnostic event.
        /// </param>
        /// <returns>
        /// The <see cref="RadioButton"/>.
        /// </returns>
        public Element ActiveEventRadioButton(string diagnosticEvent)
        {
            Element      eventElement;
            RepoItemInfo eventElementInfo = this.repository.EventElementInfo;
            RxPath       modifiedPath     = new RxPath(eventElementInfo.AbsolutePath.ToString().Replace("REPLACEACCESSIBLENAME", diagnosticEvent));

            Host.Local.TryFindSingle(this.mdiClientPath + modifiedPath, DefaultValues.iTimeoutLong, out eventElement);

            if (eventElement != null)
            {
                string controlNameOfEventElement = eventElement.GetAttributeValueText("Controlname");
                controlNameOfEventElement = controlNameOfEventElement.Replace("Label_", "Value_");

                Element      activeEventElement;
                RepoItemInfo activeEventElementsInfo = this.repository.ActiveEventRadioButtonInfo;
                RxPath       modifiedElementPath     = new RxPath(activeEventElementsInfo.AbsolutePath.ToString().Replace("REPLACECONTROLNAME", controlNameOfEventElement));
                Host.Local.TryFindSingle(this.mdiClientPath + modifiedElementPath, DefaultValues.iTimeoutLong, out activeEventElement);

                if (activeEventElement != null)
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), string.Format("Active radio button for event [{0}] found.", diagnosticEvent));
                    return(activeEventElement);
                }

                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), string.Format("Radio buttons were not found."));
                return(null);
            }

            Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), string.Format("Event was not found on GUI."));
            return(null);
        }
 public T ZnajdzWKontenerzeLubOknie <T>(RxPath path) where T : Adapter
 {
     if (_znajdzWKontenerze)
     {
         return(_container.FindSingle <T>(path));
     }
     return(_okno.FindSingle <T>(path));
 }
Пример #3
0
        /// <summary>
        /// The event label.
        /// </summary>
        /// <param name="diagnosticEvent">
        /// The diagnostic event.
        /// </param>
        /// <returns>
        /// The <see cref="Element"/>.
        /// </returns>
        public Element EventLabel(string diagnosticEvent)
        {
            Element      eventElement;
            RepoItemInfo eventElementInfo = this.repository.EventElementInfo;
            RxPath       modifiedPath     = new RxPath(eventElementInfo.AbsolutePath.ToString().Replace("REPLACEACCESSIBLENAME", diagnosticEvent));

            Host.Local.TryFindSingle(this.mdiClientPath + modifiedPath, DefaultValues.iTimeoutLong, out eventElement);
            return(eventElement);
        }
Пример #4
0
        public static void ConfirmContinue(RxPath objPath)
        {
            DialogResult confirm = ConfirmMessage("Finner ikke objektet. Har du fortsatt ønsker at testen skal fortsette?");

            if (confirm == DialogResult.No)
            {
                Report.Failure("Object Check", "Kan ikke finne objektet");
                throw new ElementNotFoundException("Kan ikke finne objektet", objPath);
            }
        }
        /// <summary>
        /// The configurable area combo box.
        /// </summary>
        /// <param name="bitNumber">
        /// The bit number.
        /// </param>
        /// <returns>
        /// The <see cref="Element"/>.
        /// </returns>
        public Element ConfigurableAreaComboBox(string bitNumber)
        {
            Element      element;
            RepoItemInfo comboBoxInfo = this.repository.ConfigurableArea.ComboBoxInfo;
            string       buffer       = comboBoxInfo.AbsolutePath.ToString().Replace("BIT#", bitNumber);
            RxPath       modifiedPath = new RxPath(buffer);

            Host.Local.TryFindSingle(this.mdiClientPath + "/" + modifiedPath, out element);
            return(element);
        }
        /// <summary>
        /// The status 1 area check box.
        /// </summary>
        /// <param name="pathToEventCheckBox">
        /// The path To Event Check Box.
        /// </param>
        /// <returns>
        /// The <see cref="Element"/>.
        /// </returns>
        public CheckBox Status1AreaCheckBox(string pathToEventCheckBox)
        {
            CheckBox     checkBox;
            RepoItemInfo checkBoxInfo = this.repository.Status1Area.CheckBoxInfo;
            string       modifiedPathToEventCheckBox = pathToEventCheckBox.Replace("//", ".");
            RxPath       modifiedPath = new RxPath(checkBoxInfo.AbsolutePath.ToString().Replace("REPLACETHIS", modifiedPathToEventCheckBox));

            Host.Local.TryFindSingle(this.mdiClientPath + "/" + modifiedPath, out checkBox);
            return(checkBox);
        }
Пример #7
0
        public void StartPopupWatcherTest_WithoutParameters_ThrowsException()
        {
            //Arrange
            var parentFolder = Substitute.For <RepoGenBaseFolder>("Form1", "/notExistent", null, Duration.Zero, true);
            var repoItemInfo = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null);

            //Act + Assert
            Assert.Throws <ArgumentNullException>(() => PopupWatcherLibrary.StartPopupWatcher(repoItemInfo, null));
            Assert.Throws <ArgumentNullException>(() => PopupWatcherLibrary.StartPopupWatcher(null, repoItemInfo));
        }
Пример #8
0
        public static bool CheckContainerText(Container container, string textToFind)
        {
            bool            response      = false;
            RxPath          containerPath = container.GetPath();
            IList <RawText> rawTextList   = container.Find <RawText>(containerPath + "/?/?/rawtext[@rawtext='" + textToFind + "']");

            if (rawTextList.Count > 0)
            {
                response = true;
            }
            return(response);
        }
Пример #9
0
 public static bool IsProgramOpen(RxPath programPath)
 {
     try
     {
         Host.Local.FindSingle <Ranorex.Form>(programPath, 1000);
         return(true);
     }
     catch (ElementNotFoundException)
     {
         return(false);
     }
 }
Пример #10
0
        public void StopPopupWatcherTest_StopWithoutStart_ReportsFail()
        {
            //Arrange
            var parentFolder = Substitute.For <RepoGenBaseFolder>("Form1", "/notExistent", null, Duration.Zero, true);
            var repoItemInfo = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null, Guid.NewGuid().ToString());

            //Act
            PopupWatcherLibrary.StopPopupWatcher(repoItemInfo, repoItemInfo);

            //Assert
            Assert.AreEqual("The popup watcher you tried to remove does not exist.", logger.LastLogMessage);
        }
Пример #11
0
        public void StartPopupWatcherTest_Single_Success()
        {
            //Arrange
            var parentFolder = Substitute.For <RepoGenBaseFolder>("Form1", "/notExistent", null, Duration.Zero, true);
            var repoItemInfo = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null);

            //Act
            var watcher = PopupWatcherLibrary.StartPopupWatcher(repoItemInfo, repoItemInfo);

            //Assert
            Assert.IsNotNull(watcher);
            Assert.AreEqual("Popup watcher started.", logger.LastLogMessage);
        }
        /// <summary>
        /// The status 2 area check box.
        /// </summary>
        /// <param name="pathToEventCheckBox">
        /// The path To Event Check Box.
        /// </param>
        /// <returns>
        /// The <see cref="Element"/>.
        /// </returns>
        public CheckBox Status2AreaCheckBox(string pathToEventCheckBox)
        {
            CheckBox     checkBox;
            RepoItemInfo checkBoxInfo = this.repository.Status2Area.CheckBoxInfo;

            string[] seperator = { "//" };
            string[] pathParts = pathToEventCheckBox.Split(seperator, StringSplitOptions.None);
            string   bitNumber = pathParts[0];
            string   modifiedPathToEventCheckBox = pathParts[1];
            string   buffer = checkBoxInfo.AbsolutePath.ToString().Replace("BIT#", bitNumber);

            buffer = buffer.Replace("REPLACETHIS", modifiedPathToEventCheckBox);
            RxPath modifiedPath = new RxPath(buffer);

            Host.Local.TryFindSingle(this.mdiClientPath + "/" + modifiedPath, out checkBox);
            return(checkBox);
        }
Пример #13
0
        public void StopAllPopupWatcherTest_RemovesAllEntries_Success()
        {
            //Arrange
            var parentFolder  = Substitute.For <RepoGenBaseFolder>("Form1", "/notExistent", null, Duration.Zero, true);
            var repoItemInfo1 = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null, Guid.NewGuid().ToString());
            var repoItemInfo2 = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null, Guid.NewGuid().ToString());

            PopupWatcherLibrary.StartPopupWatcher(repoItemInfo1, repoItemInfo1);
            PopupWatcherLibrary.StartPopupWatcher(repoItemInfo2, repoItemInfo2);

            //Act
            PopupWatcherLibrary.StopAllPopupWatchers();

            //Assert
            Assert.AreEqual("Popup watcher stopped.", logger.LastLogMessage);
            Assert.AreEqual(0, PopupWatcherLibrary.Watchers.Count);
        }
Пример #14
0
        public void WaitForElementToBeDisplayed(RxPath rxPath, Duration timeInterval)
        {
            Duration waitTime     = 3000;
            Duration totalTimeout = 0;
            Element  webElement   = null;

            while (!
                   (Host.Local.TryFindSingle
                        (rxPath, waitTime, out webElement)))
            {
                System.Threading.Thread.Sleep(waitTime.Milliseconds);
                totalTimeout = totalTimeout + waitTime;
                if (totalTimeout.Milliseconds > timeInterval.Milliseconds)
                {
                    throw new ElementNotFoundException("Elemet not found");
                }
            }
        }
Пример #15
0
        public void StopPopupWatcherTest_Single_Success()
        {
            //Arrange
            var parentFolder = Substitute.For <RepoGenBaseFolder>("Form1", "/form", null, Duration.Zero, true);
            var repoItemInfo = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null, Guid.NewGuid().ToString());
            var logger       = new TestReportLogger();

            Report.AttachLogger(logger);
            var watcher = PopupWatcherLibrary.StartPopupWatcher(repoItemInfo, repoItemInfo);

            //Act
            PopupWatcherLibrary.StopPopupWatcher(repoItemInfo, repoItemInfo);

            //Assert
            Report.DetachLogger(logger);
            Assert.IsNotNull(watcher);
            Assert.AreEqual("Popup watcher stopped.", logger.LastLogMessage);
        }
Пример #16
0
        /// <summary>
        /// The event.
        /// </summary>
        /// <param name="pathToDiagnosticEventRadioButton">
        /// The path To Diagnostic Event Radio Button.
        /// </param>
        /// <returns>
        /// The <see cref="RadioButton"/>.
        /// </returns>
        public RadioButton EventRadioButton(string pathToDiagnosticEventRadioButton)
        {
            string[] seperator = { "//" };
            string[] pathParts = pathToDiagnosticEventRadioButton.Split(seperator, StringSplitOptions.None);
            if (pathParts.Length < 2)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), string.Format("Path to diagnostic event radio button [{0}] contains to less information.", pathToDiagnosticEventRadioButton));
                return(null);
            }

            string diagnosticEvent    = pathParts[0];
            string diagnosticCategory = pathParts[1];

            Element      eventElement;
            RepoItemInfo eventElementInfo = this.repository.EventElementInfo;
            RxPath       modifiedPath     = new RxPath(eventElementInfo.AbsolutePath.ToString().Replace("REPLACEACCESSIBLENAME", diagnosticEvent));

            Host.Local.TryFindSingle(this.mdiClientPath + modifiedPath, DefaultValues.iTimeoutLong, out eventElement);

            if (eventElement != null)
            {
                string controlNameOfEventElement = eventElement.GetAttributeValueText("Controlname");
                controlNameOfEventElement  = controlNameOfEventElement.Replace("Label_", "Value_");
                controlNameOfEventElement += "." + diagnosticCategory;

                RadioButton  eventRadioButton;
                RepoItemInfo eventRadioButtonInfo    = this.repository.EventRadioButtonInfo;
                RxPath       modifiedRadioButtonPath = new RxPath(eventRadioButtonInfo.AbsolutePath.ToString().Replace("REPLACECONTROLNAME", controlNameOfEventElement));
                Host.Local.TryFindSingle(this.mdiClientPath + modifiedRadioButtonPath, DefaultValues.iTimeoutLong, out eventRadioButton);

                if (eventRadioButton != null)
                {
                    eventRadioButton.MoveTo(500);
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), string.Format("Event radio button on category [{0}] was found.", diagnosticCategory));
                    return(eventRadioButton);
                }

                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), string.Format("Event radio button on category [{0}] was not found.", diagnosticCategory));
                return(null);
            }

            Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), string.Format("Diagnostic event [{0}] was not found.", diagnosticEvent));
            return(null);
        }
Пример #17
0
        public void StartPopupWatcherTest_Twice_ThrowsException()
        {
            //Arrange
            var parentFolder = Substitute.For <RepoGenBaseFolder>("Form1", "/notExistent", null, Duration.Zero, true);
            var repoItemInfo = new RepoItemInfo(parentFolder, "self", RxPath.Parse(string.Empty), Duration.Zero, null, Guid.NewGuid().ToString());

            //Act
            try
            {
                PopupWatcherLibrary.StartPopupWatcher(repoItemInfo, repoItemInfo);
                PopupWatcherLibrary.StartPopupWatcher(repoItemInfo, repoItemInfo);
                //Assert
                Assert.Fail();
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("Popup watcher with given parameters already exists.", ex.Message);
            }
        }
 /// <summary>
 /// The table cell.
 /// </summary>
 /// <param name="row">
 /// The row.
 /// </param>
 /// <param name="column">
 /// The column.
 /// </param>
 /// <returns>
 /// The <see cref="Cell"/>.
 /// </returns>
 public Element TableCell(int row, int column)
 {
     try
     {
         RepoItemInfo itemInfo     = this.concentration.LiquidProperties.SingleCellInfo;
         string       modifiedPath = itemInfo.AbsolutePath.ToString();
         modifiedPath = modifiedPath.Replace("REPLACEROW", row.ToString(CultureInfo.InvariantCulture));
         modifiedPath = modifiedPath.Replace("REPLACECOLUMN", column.ToString(CultureInfo.InvariantCulture));
         RxPath  modifiedRxPath = new RxPath(modifiedPath);
         Element singleCell     = null;
         Host.Local.TryFindSingle(this.mdiClientPath + modifiedPath, DefaultValues.iTimeoutModules, out singleCell);
         return(singleCell);
     }
     catch (Exception exception)
     {
         Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Failed to access specific cells " + exception.Message);
         return(null);
     }
 }
        /// <summary>
        /// The close tab page.
        /// </summary>
        /// <param name="functionName">
        /// The function name.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private static bool CloseTabPage(string functionName)
        {
            Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name);

            DeviceCareApplication repo = DeviceCareApplication.Instance;
            Button button;
            string path = repo.ApplicationArea.ModuleSelection.ModuleCloseButtonInfo.AbsolutePath.ToString();

            path = path.Replace("MODULENAME", functionName);
            RxPath ranorexPath = path;

            Host.Local.TryFindSingle(ranorexPath, out button);
            if (button != null)
            {
                button.Press();
                Reporting.Debug(string.Format("Module {0} close button found and pressed.", functionName));
                return(true);
            }

            Reporting.Error(string.Format("Could not access module {0} close button.", functionName));
            return(false);
        }
        /// <summary>
        /// The select dtm functions.
        /// </summary>
        /// <param name="functionName">
        /// The function name.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public static bool SelectDtmFunctions(string functionName)
        {
            Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name);

            DeviceCareApplication repo = DeviceCareApplication.Instance;
            TabPage tabPage;
            string  path = repo.ApplicationArea.ModuleSelection.ModuleTabPageInfo.AbsolutePath.ToString();

            path = path.Replace("MODULENAME", functionName);
            RxPath ranorexPath = path;

            Host.Local.TryFindSingle(ranorexPath, out tabPage);
            if (tabPage != null)
            {
                tabPage.Select();
                Reporting.Debug(string.Format("Module {0} found and selected.", functionName));
                return(true);
            }

            Reporting.Error(string.Format("Could not find module {0} to select.", functionName));
            return(false);
        }
        /// <summary>
        /// The open dtm function.
        /// </summary>
        /// <param name="functionName">
        /// The function name.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public static bool OpenDtmFunction(string functionName)
        {
            Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name);

            if (OpenMenu())
            {
                DeviceCareApplication repo = DeviceCareApplication.Instance;
                Text   text;
                string path = repo.MenuArea.MainMenu.DTMFunctionMenuItems.MenuItemInfo.AbsolutePath.ToString();
                path = path.Replace("MODULENAME", functionName);
                RxPath ranorexPath = path;
                Host.Local.TryFindSingle(ranorexPath, Common.DefaultValues.GeneralTimeout, out text);
                if (text != null && text.Visible)
                {
                    text.Click();
                    Reporting.Debug(string.Format("Menu item {0} found and clicked.", functionName));
                    return(true);
                }
            }

            Reporting.Error(string.Format("Could not access menu item {0}.", functionName));
            return(false);
        }
Пример #22
0
        /// <summary>
        /// Create excel contains all dependent values for creating select list
        /// </summary>
        public void generateFormValDependList(string fileName)
        {
            NformRepository repo = NformRepository.Instance;

            string excelPath = "keywordscripts/" + fileName + ".xlsx";

            excelPath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                               excelPath);

            LxXlsOper opXls = new LxXlsOper();

            // opXls.open("c:/test.xlsx");
            opXls.create(excelPath);

            object oMissing = System.Reflection.Missing.Value;

            Excel.Workbook  xBook           = opXls.xBook;
            Excel.Worksheet xSheet          = opXls.xSheet;
            Excel.Worksheet xSheetComponent = (Excel.Worksheet)xBook.Worksheets[1];
            Excel.Worksheet xSheetActions   = (Excel.Worksheet)xBook.Worksheets[2];

            Type objType       = repo.GetType();
            int  iFormRow      = 1;
            int  iComponentRow = 1;
            int  iComponentCol = 2;
            int  iActionsCol   = 1;

            object       obj = repo;
            PropertyInfo pi  = objType.GetProperty("NFormApp");

            obj     = pi.GetValue(repo, null);
            objType = obj.GetType();
            PropertyInfo[] piArrLev1 = objType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            foreach (PropertyInfo piLev1 in piArrLev1)
            {
                if (piLev1.Name.CompareTo("UseCache") == 0)
                {
                    continue;
                }
                object objLogicGroup = piLev1.GetValue(obj, null);
                objType = objLogicGroup.GetType();
                PropertyInfo[] piArrLev2 = objType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
                foreach (PropertyInfo piLev2 in piArrLev2)
                {
                    if (piLev2.Name.Substring(0, 4).CompareTo("Form") != 0)
                    {
                        continue;
                    }
                    opXls.writeCell(iFormRow++, 1, piLev2.Name);

                    // MessageBox.Show(objLogicGroup.ToString());
                    object objWindows = piLev2.GetValue(objLogicGroup, null);
                    objType = objWindows.GetType();
                    PropertyInfo[] piArrComp = objType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
                    foreach (PropertyInfo piCom in piArrComp)
                    {
                        object objComponetInfo = null;
                        if (piCom.Name == "Self" || piCom.Name == "SelfInfo" || piCom.Name == "BasePath" ||
                            piCom.Name == "ParentFolder" || piCom.Name == "AbsoluteBasePath" ||
                            piCom.Name == "SearchTimeout" || piCom.Name == "UseCache")
                        {
                            continue;
                        }

                        if (piCom.Name.Length > 4 && piCom.Name.Substring(piCom.Name.Length - 4, 4) == "Info")
                        {
                            objComponetInfo = piCom.GetValue(objWindows, null);
                            PropertyInfo rxPath             = objComponetInfo.GetType().GetProperty("AbsolutePath");
                            RxPath       componentRxPath    = (RxPath)rxPath.GetValue(objComponetInfo, null);
                            string       strComponentRxPath = componentRxPath.ToString();
                            string       strComponentType   = "";
                            if (strComponentRxPath.LastIndexOf("[") - strComponentRxPath.LastIndexOf("/") > 0)
                            {
                                strComponentType = strComponentRxPath.Substring(
                                    strComponentRxPath.LastIndexOf("/") + 1, strComponentRxPath.LastIndexOf("[") - strComponentRxPath.LastIndexOf("/") - 1);
                            }
                            else
                            {
                                strComponentType = strComponentRxPath.Substring(strComponentRxPath.LastIndexOf("/") + 1, strComponentRxPath.Length - strComponentRxPath.LastIndexOf("/") - 1);
                            }

                            string comName = piCom.Name.Substring(0, piCom.Name.Length - 4);

                            if (strComponentType == "button")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "text")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "InputKeys";
                                xSheetActions.Cells[3, iActionsCol] = "SetTextValue";
                                xSheetActions.Cells[4, iActionsCol] = "Exists";
                                xSheetActions.Cells[5, iActionsCol] = "NotExists";
                                xSheetActions.Cells[6, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[7, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "combobox")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Select";
                                xSheetActions.Cells[3, iActionsCol] = "SetTextValue";
                                xSheetActions.Cells[4, iActionsCol] = "Exists";
                                xSheetActions.Cells[5, iActionsCol] = "NotExists";
                                xSheetActions.Cells[6, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[7, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "treeitem")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "menuitem")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "tabpage")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "indicator")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "menubar")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "list")
                            {
                                xSheetActions.Cells[1, iActionsCol]  = "Click";
                                xSheetActions.Cells[2, iActionsCol]  = "ClickItem";
                                xSheetActions.Cells[3, iActionsCol]  = "DoubleClickItem";
                                xSheetActions.Cells[4, iActionsCol]  = "MoveTo";
                                xSheetActions.Cells[5, iActionsCol]  = "Exists";
                                xSheetActions.Cells[6, iActionsCol]  = "NotExists";
                                xSheetActions.Cells[7, iActionsCol]  = "VerifyProperty";
                                xSheetActions.Cells[8, iActionsCol]  = "VerifyToolTips";
                                xSheetActions.Cells[9, iActionsCol]  = "VerifyContains";
                                xSheetActions.Cells[10, iActionsCol] = "VerifyNotContains";
                            }
                            else if (strComponentType == "table")
                            {
                                xSheetActions.Cells[1, iActionsCol]  = "Click";
                                xSheetActions.Cells[2, iActionsCol]  = "ClickItem";
                                xSheetActions.Cells[3, iActionsCol]  = "DoubleClickItem";
                                xSheetActions.Cells[4, iActionsCol]  = "ClickCell";
                                xSheetActions.Cells[5, iActionsCol]  = "InputKeys";
                                xSheetActions.Cells[6, iActionsCol]  = "MoveTo";
                                xSheetActions.Cells[7, iActionsCol]  = "Exists";
                                xSheetActions.Cells[8, iActionsCol]  = "NotExists";
                                xSheetActions.Cells[9, iActionsCol]  = "VerifyProperty";
                                xSheetActions.Cells[10, iActionsCol] = "VerifyToolTips";
                                xSheetActions.Cells[11, iActionsCol] = "VerifyContains";
                                xSheetActions.Cells[12, iActionsCol] = "VerifyNotContains";
                                xSheetActions.Cells[12, iActionsCol] = "InputCell";
                            }
                            else if (strComponentType == "tree")
                            {
                                xSheetActions.Cells[1, iActionsCol]  = "Click";
                                xSheetActions.Cells[2, iActionsCol]  = "ClickItem";
                                xSheetActions.Cells[3, iActionsCol]  = "DoubleClickItem";
                                xSheetActions.Cells[4, iActionsCol]  = "MoveTo";
                                xSheetActions.Cells[5, iActionsCol]  = "Expand";
                                xSheetActions.Cells[6, iActionsCol]  = "Collapse";
                                xSheetActions.Cells[7, iActionsCol]  = "Exists";
                                xSheetActions.Cells[8, iActionsCol]  = "NotExists";
                                xSheetActions.Cells[9, iActionsCol]  = "VerifyProperty";
                                xSheetActions.Cells[10, iActionsCol] = "VerifyToolTips";
                                xSheetActions.Cells[11, iActionsCol] = "VerifyContains";
                                xSheetActions.Cells[12, iActionsCol] = "VerifyNotContains";
                            }
                            else if (strComponentType == "listitem")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "DoubleClick";
                                xSheetActions.Cells[3, iActionsCol] = "Exists";
                                xSheetActions.Cells[4, iActionsCol] = "NotExists";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[6, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "checkbox")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Set";
                                xSheetActions.Cells[3, iActionsCol] = "Clear";
                                xSheetActions.Cells[4, iActionsCol] = "Exists";
                                xSheetActions.Cells[5, iActionsCol] = "NotExists";
                                xSheetActions.Cells[6, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[7, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "cell")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "DoubleClick";
                                xSheetActions.Cells[3, iActionsCol] = "InputKeys";
                                xSheetActions.Cells[4, iActionsCol] = "SetTextValue";
                                xSheetActions.Cells[5, iActionsCol] = "CellContentClick";
                                xSheetActions.Cells[6, iActionsCol] = "Exists";
                                xSheetActions.Cells[7, iActionsCol] = "NotExists";
                                xSheetActions.Cells[8, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[9, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "datetime")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "InputKeys";
                                xSheetActions.Cells[3, iActionsCol] = "Exists";
                                xSheetActions.Cells[4, iActionsCol] = "NotExists";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[6, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "radiobutton")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "row")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "picture")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "slider")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "link")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "Exists";
                                xSheetActions.Cells[3, iActionsCol] = "NotExists";
                                xSheetActions.Cells[4, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips";
                            }
                            else if (strComponentType == "container")
                            {
                                xSheetActions.Cells[1, iActionsCol] = "Click";
                                xSheetActions.Cells[2, iActionsCol] = "RightClick";
                                xSheetActions.Cells[3, iActionsCol] = "Exists";
                                xSheetActions.Cells[4, iActionsCol] = "NotExists";
                                xSheetActions.Cells[5, iActionsCol] = "VerifyProperty";
                                xSheetActions.Cells[6, iActionsCol] = "VerifyToolTips";
                            }
                            else
                            {
                                MessageBox.Show(comName.ToString() + "     " + strComponentType);
                            }
                            Excel.Range rmgForAction = (Excel.Range)xSheetActions.Cells[1, iActionsCol];
                            rmgForAction.EntireColumn.Name = piLev2.Name + comName;
                            iActionsCol++;
                            // MessageBox.Show(comName.ToString() + "     " + strComponentType);
                        }
                        else
                        {
                            opXls.writeCell(iComponentRow++, iComponentCol, piCom.Name);
                        }
                    }

                    if (piLev2.Name == "FormManaged_Devices")
                    {
                        opXls.writeCell(iComponentRow++, iComponentCol, "Add_Device");
                        opXls.writeCell(iComponentRow++, iComponentCol, "Del_Device");
                    }

                    iComponentRow = 1;
                    iComponentCol++;
                }
            }

            opXls.writeCell(iFormRow++, 1, "Pause");
            for (int iPuaseNum = 1; iPuaseNum <= 60; iPuaseNum++)
            {
                opXls.writeCell(iComponentRow++, iComponentCol, iPuaseNum.ToString());
            }
            opXls.writeCell(iFormRow++, 1, "VerifyTxtfileValues");
            opXls.writeCell(iFormRow++, 1, "VerifyExcelfileValues");
            opXls.writeCell(iFormRow++, 1, "SendCommandToSimulator");

            xSheet.Name        = "Form DataValDepend";
            xSheetActions.Name = "Action DataValDepend";

            //Excel.Range rmg = (Excel.Range)xSheet.Cells[1,1];
            //rmg.EntireColumn.Name = "Forms";
            Excel.Range rmg = xSheetComponent.get_Range(xSheetComponent.Cells[1, 1], xSheetComponent.Cells[iFormRow, 1]);
            rmg.Name = "Forms";

            int    countRows = 1;
            string formName  = opXls.readCell(countRows, 1);

            while (formName != "")
            {
                rmg      = (Excel.Range)xSheet.Cells[1, countRows + 1];
                rmg.Name = formName;
                rmg.EntireColumn.Name = formName + "Col";

                formName = opXls.readCell(++countRows, 1);
            }

            Excel.Worksheet myScriptsSheet = (Excel.Worksheet)xBook.Sheets.Add(oMissing, oMissing, oMissing, oMissing);
            myScriptsSheet.Name = "Scripts";
            Excel.Worksheet extraSheet = (Excel.Worksheet)xBook.Worksheets["Sheet3"];
            extraSheet.Delete();

            opXls.close();
        }
Пример #23
0
        /// <summary>
        /// Opens a new browser window of the specified browserProduct with the specified default uri.
        /// Initializes the handle field of this class to the native window handle of the new window.
        /// </summary>
        /// <param name="url">The default uri for the opened browser.</param>
        /// <param name="browserProduct">The Lynda.Test.Browsers.Browser.BrowserProduct such as IE, Firefox, Chrome or Safari.</param>
        /// <param name="rxPathBrowserWindow">A Ranorex.RxPath instance used to find the window.</param>
        /// <example><code>OpenBrowser("www.lynda.com", Lynda.Test.Browsers.Browser.BrowserProduct.IE.ToString(), new RxPath("/form[@class='IEFrame']"));</code></example>
        protected void OpenBrowser(string uri, string browserProduct, RxPath rxPathBrowserWindow)
        {
            if (!String.IsNullOrEmpty(uri))
            {
                ValidateUri(uri);
            }

            //1. Find all browser windows before opening a new one
            Hashtable hashTableWindowsBefore = new Hashtable();
            IList<Ranorex.NativeWindow> browserWindowsBefore = null;
            browserWindowsBefore = Host.Local.Find<Ranorex.NativeWindow>(rxPathBrowserWindow);
            foreach (Ranorex.NativeWindow window in browserWindowsBefore)
            {
                hashTableWindowsBefore.Add(window.Handle, true);
            }

            //2. Open new window
            try
            {
                Host.Local.OpenBrowser(uri, browserProduct, "", false, true);
            }
            catch (RanorexException e)
            {
                //e.g. e.InnerException.Message=="Failed to run application 'safari'."
                if (e.InnerException.Message.StartsWith("Failed to run application '"))
                {
                    throw new Exception(String.Format("Failed to open browser {0}. It may not be installed.", browserProduct.ToString()), e);
                }
                else
                {
                    throw e;
                }
            }

            //3. Wait for new window to open: Keep searching for browser windows until the total found is greater than the total before a new one has opened,
            //because only doing one search after Host.Local.OpenBrowser doesn't immediately find the new window
            IList<Ranorex.NativeWindow> browserWindowsNow = null;
            while (browserWindowsNow == null || browserWindowsNow.Count <= browserWindowsBefore.Count)
            {
                browserWindowsNow = Host.Local.Find<Ranorex.NativeWindow>(rxPathBrowserWindow);
            }

            //4. Store the window handle of the new browser window; new window is the one whose handle is not in hashTableWindowsBefore
            bool foundNewWindow = false;
            foreach (Ranorex.NativeWindow window in browserWindowsNow)
            {
                if (!hashTableWindowsBefore.Contains(window.Handle))
                {
                    handle = window.Handle;
                    foundNewWindow = true;
                    break;
                }
            }
            if (!foundNewWindow)
            {
                StringBuilder sB = new StringBuilder("Handles of windows before opening new window: ");
                ICollection handlesBefore = hashTableWindowsBefore.Keys;

                foreach (IntPtr windowHandleBefore in handlesBefore)
                {
                    sB.Append(windowHandleBefore.ToString());
                    sB.Append(" ");
                }

                sB.Append("Handles of windows after opening new window: ");
                foreach (Ranorex.NativeWindow window in browserWindowsNow)
                {
                    sB.Append(window.Handle);
                    sB.Append(" ");
                }

                throw new Exception(String.Format("Failed to find handle of the new browser window. {0}.", sB));
            }
        }
Пример #24
0
        /// <summary>
        /// Opens a new browser window of the specified browserProduct with the specified default uri.
        /// Initializes the handle field of this class to the native window handle of the new window.
        /// </summary>
        /// <param name="url">The default uri for the opened browser.</param>
        /// <param name="browserProduct">The Lynda.Test.Browsers.Browser.BrowserProduct such as IE, Firefox, Chrome or Safari.</param>
        /// <param name="rxPathBrowserWindow">A Ranorex.RxPath instance used to find the window.</param>
        /// <example><code>OpenBrowser("www.lynda.com", Lynda.Test.Browsers.Browser.BrowserProduct.IE.ToString(), new RxPath("/form[@class='IEFrame']"));</code></example>
        protected void OpenBrowser(string uri, string browserProduct, RxPath rxPathBrowserWindow)
        {
            if (!String.IsNullOrEmpty(uri))
            {
                ValidateUri(uri);
            }

            //1. Find all browser windows before opening a new one
            Hashtable hashTableWindowsBefore = new Hashtable();
            IList <Ranorex.NativeWindow> browserWindowsBefore = null;

            browserWindowsBefore = Host.Local.Find <Ranorex.NativeWindow>(rxPathBrowserWindow);
            foreach (Ranorex.NativeWindow window in browserWindowsBefore)
            {
                hashTableWindowsBefore.Add(window.Handle, true);
            }

            //2. Open new window
            try
            {
                Host.Local.OpenBrowser(uri, browserProduct, "", false, true);
            }
            catch (RanorexException e)
            {
                //e.g. e.InnerException.Message=="Failed to run application 'safari'."
                if (e.InnerException.Message.StartsWith("Failed to run application '"))
                {
                    throw new Exception(String.Format("Failed to open browser {0}. It may not be installed.", browserProduct.ToString()), e);
                }
                else
                {
                    throw e;
                }
            }

            //3. Wait for new window to open: Keep searching for browser windows until the total found is greater than the total before a new one has opened,
            //because only doing one search after Host.Local.OpenBrowser doesn't immediately find the new window
            IList <Ranorex.NativeWindow> browserWindowsNow = null;

            while (browserWindowsNow == null || browserWindowsNow.Count <= browserWindowsBefore.Count)
            {
                browserWindowsNow = Host.Local.Find <Ranorex.NativeWindow>(rxPathBrowserWindow);
            }

            //4. Store the window handle of the new browser window; new window is the one whose handle is not in hashTableWindowsBefore
            bool foundNewWindow = false;

            foreach (Ranorex.NativeWindow window in browserWindowsNow)
            {
                if (!hashTableWindowsBefore.Contains(window.Handle))
                {
                    handle         = window.Handle;
                    foundNewWindow = true;
                    break;
                }
            }
            if (!foundNewWindow)
            {
                StringBuilder sB            = new StringBuilder("Handles of windows before opening new window: ");
                ICollection   handlesBefore = hashTableWindowsBefore.Keys;

                foreach (IntPtr windowHandleBefore in handlesBefore)
                {
                    sB.Append(windowHandleBefore.ToString());
                    sB.Append(" ");
                }

                sB.Append("Handles of windows after opening new window: ");
                foreach (Ranorex.NativeWindow window in browserWindowsNow)
                {
                    sB.Append(window.Handle);
                    sB.Append(" ");
                }

                throw new Exception(String.Format("Failed to find handle of the new browser window. {0}.", sB));
            }
        }
Пример #25
0
 public T ZnajdzWKontenerzeLubOknie <T>(RxPath path) where T : Adapter
 {
     return(_okno.FindSingle <T>(path));
 }
Пример #26
0
 public IList <T> ZnajdzWKontenerzeLubOknieWszystkie <T>(RxPath path) where T : Adapter
 {
     return(_okno.Find <T>(path));
 }