protected static bool IsElementVisible(PageElement pageElement, TimeSpan?maxWaitTime = null) { pageElement.GoToFrame(); return(SeleniumUtility .WebDriverWait(ExpectedConditions.ElementIsVisible(pageElement.Locator), maxWaitTime ?? Default5Seconds) .Displayed); }
protected static void Click(PageElement pageElement, TimeSpan?maxWaitTime = null) { pageElement.GoToFrame(); SeleniumUtility .WebDriverWait( ExpectedConditions.ElementToBeClickable(SeleniumDriver.Driver.FindElement(pageElement.Locator)), maxWaitTime).Click(); }
protected static void RightClick(PageElement pageElement, TimeSpan?maxWaitTime = null) { pageElement.GoToFrame(); var actions = new OpenQA.Selenium.Interactions.Actions(SeleniumDriver.Driver); actions.ContextClick(SeleniumUtility.WebDriverWait(ExpectedConditions.ElementIsVisible(pageElement.Locator), maxWaitTime ?? Default5Seconds)).Build().Perform(); }
protected static void ClickMultipleElements(PageElement pageElement) { pageElement.GoToFrame(); foreach (var element in SeleniumDriver.Driver.FindElements(pageElement.Locator)) { SeleniumUtility.WebDriverWait(ExpectedConditions.ElementToBeClickable(element), Default5Seconds) .Click(); } }
protected static void Type(PageElement pageElement, string input) { pageElement.GoToFrame(); var element = SeleniumUtility.WebDriverWait(ExpectedConditions.ElementToBeClickable(pageElement.Locator)); element.Clear(); element.SendKeys(input);// Assert.AreEqual(input, ExtractText(pageElement, Default5Seconds)); }
private string WaitForElementToDisplay(int index, TimeSpan?maxWaitTime = null) { var locator = $"{this}{AddIndex(index)}"; if (SeleniumUtility.WebDriverWait(driver => driver.ExecuteJavaScript <string>(locator).IsBlank(), maxWaitTime ?? Default5Seconds)) { throw new NotFoundException($"Did not find element within {maxWaitTime ?? Default5Seconds}: {locator}"); } return(locator); }
private void scrapeButton_Click(object sender, EventArgs e) { foreach (var site in sites) { Task.Run(async() => { var driver = SeleniumUtility.CreateDefaultFirefoxDriver(); activeDrivers.TryAdd(site.SiteName, driver); await site.ScrapeAsync(driver); lock (lockObj) { driver.Quit(); } activeDrivers.TryRemove(site.SiteName, out driver); }); } }
protected static string ExtractText(PageElement pageElement, TimeSpan?maxWaitTime) { try { pageElement.GoToFrame(); var element = SeleniumUtility.WebDriverWait( ExpectedConditions.ElementIsVisible(pageElement.Locator), maxWaitTime ?? Default5Seconds); var text = GetTextByType(pageElement.ElementType, element); if (text == null) { throw new NotFoundException($"{TextNotFound} Element: {pageElement}"); } return(text); } catch (Exception e) { throw new NotFoundException($"Error getting value: {e.StackTrace}"); } }
private void CurrentOnExit(object sender, ExitEventArgs exitEventArgs) { SeleniumUtility.KillSeleniumProcesses(DriverService.ProcessId); }
protected static bool IsElementNotVisible(PageElement pageElement, TimeSpan?maxWaitTime = null) { pageElement.GoToFrame(); return(SeleniumUtility.WebDriverWait(ExpectedConditions.InvisibilityOfElementLocated(pageElement.Locator), maxWaitTime ?? Default5Seconds)); }
public static IWebDriver SwitchToFrame(string name, TimeSpan?maxWaitTime) { return(SeleniumUtility.WebDriverWait(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(name), maxWaitTime)); }