예제 #1
0
        public static void setTestClassStart(String testClassName, String dateTime)
        {
            try
            {
                SAFINCALog.Info("Executing Test Cases for Class Started for Class : " + testClassName);

                errorTestResultFilePath = null;

                //For Directory
                if (!Directory.Exists(resultFolderPath))
                {
                    resultFolderPath = resultFolderPath + "_" + dateTime;
                    Directory.CreateDirectory(resultFolderPath);
                    System.IO.File.Copy(@Environment.CurrentDirectory + "\\Test_Results_Template.xlsx", resultFolderPath + "\\Test_Results" + "_" + dateTime + ".xlsx");
                }

                testResultFilePath = resultFolderPath + "\\Test_Results" + "_" + dateTime + ".xlsx";

                testResultFile = new FileInfo(testResultFilePath);

                excelPackage = new ExcelPackage(testResultFile);

                testCaseWorkSheet = excelPackage.Workbook.Worksheets.First();

                testStepWorkSheet = excelPackage.Workbook.Worksheets.Last();
            }

            catch (Exception e)
            {
                SAFINCALog.TestCaseErrorMessage(e);
            }
        }
예제 #2
0
        public static void setTestClassFinish(String testClassName)
        {
            try

            {
                SAFINCALog.Info("Executing Test Cases Finished for Class  : " + testClassName);

                excelPackage.SaveAs(testResultFile);

                excelPackage.Dispose();

                // excelPackage.Load(holdingStream);

                SAFINCALog.Info("Saving Test Results for Class : " + testClassName + " in path -> " + testResultFilePath);
            }
            catch (Exception e)
            {
                SAFINCALog.TestCaseErrorMessage(e);
            }
            finally
            {
                //tc_RowIndex = 7; ts_RowIndex = 7; testCaseIDCounter = 1;
                testStepIDCounter = 1;
            }
        }
예제 #3
0
        //Verify the table row data on the main panel
        public bool verifyTableRowData(String className, String text)
        {
            IWebElement webelement = findWebDriverElement.waitForElementByClassName(null, null, className);
            Boolean     flag       = false;
            IReadOnlyCollection <IWebElement> elementDivList = webelement.FindElements(By.TagName("tbody"));

            //Dictionary<String, String> attributeList = new Dictionary<string, string>();

            try
            {
                foreach (IWebElement elementTable in elementDivList)
                {
                    IReadOnlyCollection <IWebElement> elementTrList = elementTable.FindElements(By.TagName("tr"));
                    foreach (IWebElement elementTr in elementTrList)
                    {
                        IReadOnlyCollection <IWebElement> elementTdList = elementTr.FindElements(By.TagName("td"));
                        foreach (IWebElement elementTd in elementTdList)
                        {
                            if (elementTd.GetAttribute("innerHTML").Contains(text))
                            {
                                SAFINCALog.Info("Verified and passed");
                                flag = true;
                                return(flag);
                            }
                        }

                        // if (flag) { break; }
                    }
                    // if (flag) { break; }
                }
                return(flag);
            }
            catch (Exception e) { SAFINCALog.TestCaseErrorMessage(e); }
            return(flag);
        }
예제 #4
0
        //Verify Table row Div data
        public bool verifyTableRowDivData(String className, String text)
        {
            IWebElement webelement = findWebDriverElement.waitForElementByClassName(null, null, className);
            Boolean     flag       = false;
            IReadOnlyCollection <IWebElement> elementDivList = webelement.FindElements(By.TagName("tbody"));

            try
            {
                foreach (IWebElement elementTable in elementDivList)
                {
                    IReadOnlyCollection <IWebElement> elementTrList = elementTable.FindElements(By.TagName("tr"));
                    foreach (IWebElement elementTr in elementTrList)
                    {
                        IReadOnlyCollection <IWebElement> elementTdList = elementTr.FindElements(By.TagName("td"));
                        foreach (IWebElement elementTd in elementTdList)
                        {
                            if (elementTd.Text == text)
                            {
                                SAFINCALog.Info("Status is " + text + " and as expected");
                                //break;
                                return(flag);
                            }
                        }

                        // if (flag) { break; }
                    }
                    // if (flag) { break; }
                }
                return(flag);
            }
            catch (Exception e) { SAFINCALog.TestCaseErrorMessage(e); }
            return(flag);
        }
예제 #5
0
        //Click the table on the main panel using class
        public void clickTableRowUsingClassAndInput(String className, String text)
        {
            IWebElement webelement = findWebDriverElement.waitForElementByClassName(null, null, className);
            Boolean     flag       = false;
            IReadOnlyCollection <IWebElement> elementDivList = webelement.FindElements(By.TagName("tbody"));

            //Dictionary<String, String> attributeList = new Dictionary<string, string>();

            try
            {
                foreach (IWebElement elementTable in elementDivList)
                {
                    IReadOnlyCollection <IWebElement> elementTrList = elementTable.FindElements(By.TagName("tr"));
                    foreach (IWebElement elementTr in elementTrList)
                    {
                        IReadOnlyCollection <IWebElement> elementTdList = elementTr.FindElements(By.TagName("td"));
                        foreach (IWebElement elementTd in elementTdList)
                        {
                            IReadOnlyCollection <IWebElement> elementInputList = elementTr.FindElements(By.TagName("input"));
                            foreach (IWebElement elementInput in elementInputList)
                            {
                                if (elementInput.GetAttribute("value") == text)
                                {
                                    elementInput.Click();
                                    flag = true;
                                    break;
                                }
                            }
                            if (flag)
                            {
                                break;
                            }
                        }

                        if (flag)
                        {
                            break;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
            }
            catch (Exception e) { SAFINCALog.TestCaseErrorMessage(e); }
        }
예제 #6
0
        // Click the menu from the left side of the panel
        public void clickLeftPanelMenu(String id, String param)
        {
            IWebElement webelement = findWebDriverElement.waitForElementById(null, null, id);
            Boolean     flag       = false;
            IReadOnlyCollection <IWebElement> elementLiList = webelement.FindElements(By.TagName("li"));

            try
            {
                foreach (IWebElement elementLi in elementLiList)
                {
                    IReadOnlyCollection <IWebElement> elementUlList = elementLi.FindElements(By.TagName("ul"));

                    foreach (IWebElement elementUl in elementUlList)
                    {
                        IReadOnlyCollection <IWebElement> elementList = elementLi.FindElements(By.TagName("li"));

                        foreach (IWebElement subelementList in elementList)
                        {
                            IReadOnlyCollection <IWebElement> anchorElementList = subelementList.FindElements(By.TagName("a"));

                            foreach (IWebElement anchorElement in anchorElementList)
                            {
                                if (anchorElement.Text == param)
                                {
                                    anchorElement.Click();
                                    flag = true;
                                    break;
                                }
                            }
                            if (flag)
                            {
                                break;
                            }
                        }
                        if (flag)
                        {
                            break;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
            }
            catch (Exception e) { SAFINCALog.TestCaseErrorMessage(e); }
        }
예제 #7
0
        //Verify the table row div data(column as index) using xpath on the main panel
        public bool verifyTableDivDataUsingXpath(String xpath, int index, String verifyText)
        {
            IWebElement webelement = findWebDriverElement.WaitForElementByXPath(null, null, xpath);
            Boolean     flag       = false;
            IReadOnlyCollection <IWebElement> elementDivList = webelement.FindElements(By.TagName("tbody"));

            Dictionary <String, String> attributeList = new Dictionary <string, string>();

            try
            {
                foreach (IWebElement elementTable in elementDivList)
                {
                    IReadOnlyCollection <IWebElement> elementTrList = elementTable.FindElements(By.TagName("tr"));
                    foreach (IWebElement elementTr in elementTrList)
                    {
                        IReadOnlyCollection <IWebElement> elementTdList = elementTr.FindElements(By.TagName("td"));
                        int counter = 0;
                        foreach (IWebElement elementTd in elementTdList)
                        {
                            if (counter == index)
                            {
                                if (elementTd.Text == verifyText)
                                {
                                    SAFINCALog.Info("Results are not expected");
                                    flag = true;
                                    return(flag);
                                    //break;
                                }
                            }
                            counter++;
                        }


                        //if (flag) { break; }
                    }
                    //if (flag) { break; }
                }
                return(flag);
            }
            catch (Exception e) { SAFINCALog.TestCaseErrorMessage(e); }
            return(flag);
        }
예제 #8
0
        //Click the table row using xpath with condition on the main panel
        public void clickTableRowUsingXpathWithCondition(String xpath, String verifyText, String clickText)
        {
            IWebElement webelement = findWebDriverElement.WaitForElementByXPath(null, null, xpath);
            Boolean     flag       = false;
            IReadOnlyCollection <IWebElement> elementDivList = webelement.FindElements(By.TagName("tbody"));

            Dictionary <String, String> attributeList = new Dictionary <string, string>();

            try
            {
                foreach (IWebElement elementTable in elementDivList)
                {
                    IReadOnlyCollection <IWebElement> elementTrList = elementTable.FindElements(By.TagName("tr"));
                    foreach (IWebElement elementTr in elementTrList)
                    {
                        if (elementTr.GetAttribute("innerHTML").Contains(verifyText))
                        {
                            IReadOnlyCollection <IWebElement> elementTdList = elementTr.FindElements(By.TagName("td"));
                            foreach (IWebElement elementTd in elementTdList)
                            {
                                if (elementTd.GetAttribute("innerHTML").Contains(clickText))
                                {
                                    elementTd.Click();
                                    flag = true;
                                    break;
                                }
                            }
                        }

                        if (flag)
                        {
                            break;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
            }
            catch (Exception e) { SAFINCALog.TestCaseErrorMessage(e); }
        }
예제 #9
0
        //Verify the table row data using Class with condition to verify on the main panel
        public bool verifyTableRowDataUsingClassWithCondition(String className, String verifyText, String clickText)
        {
            IWebElement webelement = findWebDriverElement.waitForElementByClassName(null, null, className);
            Boolean     flag       = false;
            IReadOnlyCollection <IWebElement> elementDivList = webelement.FindElements(By.TagName("tbody"));

            try
            {
                foreach (IWebElement elementTable in elementDivList)
                {
                    IReadOnlyCollection <IWebElement> elementTrList = elementTable.FindElements(By.TagName("tr"));
                    foreach (IWebElement elementTr in elementTrList)
                    {
                        if (elementTr.GetAttribute("innerHTML").Contains(verifyText))
                        {
                            IReadOnlyCollection <IWebElement> elementTdList = elementTr.FindElements(By.TagName("td"));
                            foreach (IWebElement elementTd in elementTdList)
                            {
                                if (elementTd.GetAttribute("innerHTML").Contains(clickText))
                                {
                                    SAFINCALog.Info("Status is " + clickText + " which is as expected");
                                    flag = true;
                                    return(flag);
                                    //break;
                                }
                            }
                        }

                        //if (flag) { break; }
                    }
                    // if (flag) { break; }
                }
                return(flag);
            }
            catch (Exception e)
            {
                SAFINCALog.TestCaseErrorMessage(e);
            }
            return(flag);
        }
예제 #10
0
 public static void setTestCaseErrorMessage(Exception e)
 {
     SAFINCALog.TestCaseErrorMessage(e);
 }