public static void ButtonClick(IWebDriver driver, GlobalEnums.Locators locatorType, string locatorValue) { try { switch (locatorType) { case GlobalEnums.Locators.XPath: GenericHelpers.WaitForElements(driver, locatorType, locatorValue); driver.FindElement(By.XPath(locatorValue)).Click(); break; } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static void WaitForElements(IWebDriver driver, GlobalEnums.Locators locatorType, string locatorValue) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); try { switch (locatorType) { case GlobalEnums.Locators.XPath: wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(locatorValue))); wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(locatorValue))); break; } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static string GetUrl(IWebDriver driver, GlobalEnums.Locators locatorType, string locatorValue) { try { switch (locatorType) { case GlobalEnums.Locators.XPath: GenericHelpers.WaitForElements(driver, locatorType, locatorValue); string url = driver.FindElement(By.XPath(locatorValue)).GetAttribute("href"); return(url); break; default: return(null); } } catch (Exception ex) { throw new Exception(ex.Message); } }