Beispiel #1
0
 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");
     }
 }
Beispiel #2
0
 //To Get selected Text from a DropDownList
 public static string ExtendedGetTxtDDL(this IWebElement element)
 {
     if (InitialAssertion.IfElementIsVisible(element) == true)
     {
         return(new SelectElement(element).AllSelectedOptions.SingleOrDefault().Text);
     }
     else
     {
         return(String.Empty);
     }
 }
 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);
     }
 }
Beispiel #4
0
        //************************************************************

        //**************Extended Library method*****************
        //To Get Text from a Text box
        public static string ExtendedGetTxt(this IWebElement element)
        {
            if (InitialAssertion.IfElementIsVisible(element) == true)
            {
                return(element.GetAttribute("value"));
                //SeleniumReporting.WriteResults(true, element.GetAttribute("value"));
                //return true;
            }
            else
            {
                return(String.Empty);
            }
        }
Beispiel #5
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);
     }
 }
Beispiel #6
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);
            }
        }
Beispiel #7
0
//******INNER_METHODS*****************************************************************************************************************************************

        public GACShip_Agent_LandingPage GACShipLogin()
        {
            GACShip_Agent_LoginPage loginPage = new GACShip_Agent_LoginPage();
            Excel excel = new Excel(@"C:\Users\DTH6HD2\.jenkins\workspace\Build SLN\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());

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