public static void PopulateCollectionByRow(IWebElement table)
 {
     //Iterate through the rows and columns of the table
     if (InitialAssertion.IfElementIsVisible(table) == true)
     {
         var columns  = table.FindElements(By.TagName("th"));
         var rows     = table.FindElements(By.TagName("tr"));
         int rowIndex = 0;
         foreach (var row in rows)
         {
             int colIndex = 0;
             var colData  = row.FindElements(By.TagName("td"));
             foreach (var colValue in colData)
             {
                 _TableDataCollection.Add(new TableDataCollection
                 {
                     RowNumber = rowIndex,
                     ColName   = columns[colIndex].Text,
                     ColValue  = colValue.Text
                 });
                 colIndex++;
             }
             rowIndex++;
         }
     }
     else
     {
         SeleniumReporting.WriteResults(false, "Table is not available to fetch and compare the given search text");
     }
 }
Exemple #2
0
 public void CloseBrowser()
 {
     PropertyCollection.ChildTest = PropertyCollection.ExtentTest.CreateNode(GetActions.GetMyMethodName());
     SeleniumReporting.WriteResults(true, "Browser Close");
     PropertyCollection.ExtentReports.Flush();
     //PropertyCollection.Driver.Quit();
     PropertyCollection.Driver.Close();
 }
Exemple #3
0
 public static void ClickButton(string element, string ButtonName)
 {
     if (InitialAssertion.ifElementIsPresentandVisible(element) == true)
     {
         PropertyCollection.Driver.FindElement(By.XPath(element)).Click();
         SeleniumReporting.clickButton(true, ButtonName);
     }
     else
     {
         SeleniumReporting.clickButton(false, ButtonName);
     }
 }
Exemple #4
0
 public static bool VerifyIfElementIsPresent(IWebDriver driver, PropertyName propertyName, IWebElement element)
 {
     if (InitialAssertion.ifElementIsAvailable(element) == true)
     {
         SeleniumReporting.WriteResults(true, "Type Text");
         return(true);
     }
     else
     {
         SeleniumReporting.WriteResults(false, "TypeText");
         return(false);
     }
 }
Exemple #5
0
 //To Get Text from a Text box
 public static bool ExtendedCompareTxt(this IWebElement element, string SearchString)
 {
     if (ExtendedGetTxt(element).Contains(SearchString) == true)
     {
         //Console.WriteLine("Text available in the UI : " + ExtendedGetTxt(element));
         SeleniumReporting.WriteResults(true, "Compare Text : '" + SearchString + "' with '" + ExtendedGetTxt(element) + "'");
         return(true);
     }
     else
     {
         SeleniumReporting.WriteResults(false, "Compare Text : '" + SearchString + "' with '" + ExtendedGetTxt(element) + "'");
         return(false);
     }
 }
        /*  public static bool checkCountMatch(string element, string element2)
         * {
         *    if (element == element2)
         *    {
         *        return true;
         *    }
         *    else
         *    {
         *        SeleniumReporting.WriteResults(false, "Verify Job Count Matches Row Count!  Unmatched Values Found!    ");
         *        throw new Exception("Values Do Not Match!");
         *    }
         * }
         */

        public static void WaitForElementLoad(By by, int timeoutInSeconds)
        {
            if (timeoutInSeconds > 0)
            {
                WebDriverWait wait = new WebDriverWait(PropertyCollection.Driver, TimeSpan.FromSeconds(timeoutInSeconds));
                wait.Until(ExpectedConditions.ElementIsVisible(by));
            }

            else
            {
                SeleniumReporting.WriteResults(false, "Element not found!");
                throw new Exception("Element not found!");
            }
        }
Exemple #7
0
        //To Compare value from a cell with the searchstring
        public static bool ExtendedCellTextCopare(this IWebElement element, string SearchString, int RowNumber, string ColumnName)
        {
            string UIValue = TableDataUtility.ReadCellData(RowNumber, ColumnName);

            if (InitialAssertion.IfElementIsVisible(element) == true && UIValue == SearchString)
            {
                //Console.WriteLine("Text available in the UI : " + ExtendedGetTxt(element));
                SeleniumReporting.WriteResults(true, "Compare Text : '" + SearchString + "' with '" + UIValue + "'");
                return(true);
            }
            else
            {
                SeleniumReporting.WriteResults(false, "Compare Text : '" + SearchString + "' with '" + UIValue + "'");
                return(false);
            }
        }
Exemple #8
0
//******INNER_METHODS*****************************************************************************************************************************************

        public GACShip_Agent_LandingPage GACShipLoginToApplication()
        {
            GACShip_Agent_LoginPage loginPage = new GACShip_Agent_LoginPage();
            Excel excel = new Excel(@"C:\Users\edqu01\Documents\GAC Automation\GACShip Agent Automation - August-31\ConsoleApp1\TestData\GACShipTestData.xlsx", "LogIn");

            PropertyCollection.ChildTest = PropertyCollection.ExtentTest.CreateNode(GetActions.GetMyMethodName());

            //Checks first if element is present then type in the Username
            if (InitialAssertion.ifElementIsPresentandVisible(loginPage.Username) == true)
            {
                SetActions.FillInTextField((excel.ReadDatabyColumnName("GACShip", "UserName")), loginPage.Username);
                SeleniumReporting.ElementPresentVerification(true, "UserName Text Field");
                SeleniumReporting.WriteMessageOnTheReport("Username was typed in the text field.");
            }
            else
            {
                SeleniumReporting.ElementPresentVerification(false, "UserName Text Field");
            }

            //Checks first if element is present then type in the Password
            if (InitialAssertion.ifElementIsPresentandVisible(loginPage.Password) == true)
            {
                SetActions.FillInTextField((excel.ReadDatabyColumnName("GACShip", "Password")), loginPage.Password);
                SeleniumReporting.ElementPresentVerification(true, "PassWord Text Field");
                SeleniumReporting.WriteMessageOnTheReport("Password was typed in the text field.");
            }
            else
            {
                SeleniumReporting.ElementPresentVerification(false, "PassWord Text Field");
            }

            SetActions.ClickButton(loginPage.LogInButton, "LogIn");
            excel.Close();

            GACShip_Agent_LandingPage landingPage = new GACShip_Agent_LandingPage();

            InitialAssertion.WaitForElementLoad(By.XPath(LandingPageHeader), 30);

            return(new GACShip_Agent_LandingPage());

//************************************************************************************************************************************************************************
        }