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"); } }
public void CloseBrowser() { PropertyCollection.ChildTest = PropertyCollection.ExtentTest.CreateNode(GetActions.GetMyMethodName()); SeleniumReporting.WriteResults(true, "Browser Close"); PropertyCollection.ExtentReports.Flush(); //PropertyCollection.Driver.Quit(); PropertyCollection.Driver.Close(); }
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); } }
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); } }
/* 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!"); } }
//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); } }
//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); } }
//******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()); //************************************************************************************************************************************************************************ }