private LocatedWebElement(IWebElement element, ElementLocator locator, IReportLogger logger, int defaultTimeoutInSeconds = 4)
 {
     _defaultTimeoutInSeconds = defaultTimeoutInSeconds;
     Element = element;
     Locator = locator;
     Logger  = logger;
     TestId  = Element.GetTestId();
 }
        public static IWebElement WaitFor(this IWebDriver driver, string selector, int waitSeconds = 4)
        {
            var wait = new WebDriverWait(driver, new TimeSpan(0, 0, waitSeconds));
            var by   = ElementLocator.HowToGetElement(selector);
            var elem = wait.Until(ExpectedConditions.ElementExists(by));

            return(elem);
        }
Exemple #3
0
 /// <summary>
 /// Initialisiert WebDriverFixture mit einem WebDriver
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="webSiteBaseUrl"> </param>
 /// <param name="logger"></param>
 /// <param name="defaultTimeOut"></param>
 public WebDriverFixture(IWebDriver driver, string webSiteBaseUrl, IReportLogger logger, int defaultTimeOut = 20)
 {
     _webSiteBaseUrl = webSiteBaseUrl;
     _instance       = driver;
     Locator         = new ElementLocator(driver, this);
     Logger          = logger;
     WaitSeconds     = defaultTimeOut;
     Click           = new ClickLocator(Locator);
 }
        public static IWebElement WaitForText(this IWebDriver driver, string selector, string text, int waitSeconds = 4)
        {
            var wait = new WebDriverWait(driver, new TimeSpan(0, 0, waitSeconds));
            var by   = ElementLocator.HowToGetElement(selector);
            var elem = wait.Until(ExpectedConditions.ElementIsVisible(by));

            wait.Until(ExpectedConditions.TextToBePresentInElement(elem, text));
            return(elem);
        }
 public ILocatedWebElement WaitFor(string selector, string message = null)
 {
     try
     {
         var wait = new WebDriverWait(Locator.Driver, new TimeSpan(0, 0, _defaultTimeoutInSeconds));
         var by   = ElementLocator.HowToGetElement(selector);
         var elem = wait.Until(driver => Element.FindElement(by));
         return(new LocatedWebElement(elem, Locator, Logger));
     }
     catch (TimeoutException)
     {
         Logger.Log(ReportLogStatus.Warning, $"Couldn't find element with selector '{selector}' within timeout-span of {_defaultTimeoutInSeconds} sec.");
         return(null);
     }
 }
 public ILocatedWebElement ClickAndWaitFor(string selector, string message = null)
 {
     try
     {
         Click(message);
         var wait = new WebDriverWait(Locator.Driver, new TimeSpan(0, 0, _defaultTimeoutInSeconds));
         var by   = ElementLocator.HowToGetElement(selector);
         var elem = wait.Until(ExpectedConditions.ElementExists(by));
         Logger.AddScreenShot("After waiting for element.");
         return(new LocatedWebElement(elem, Locator, Logger));
     }
     catch (TimeoutException)
     {
         Logger.Log(ReportLogStatus.Warning, $"Couldn't find element with selector '{selector}' within timeout-span of {_defaultTimeoutInSeconds} sec.");
         return(null);
     }
 }
Exemple #7
0
        public ILocatedWebElement WaitForTextChange(string selector, string message = null, int seconds = -1)
        {
            var wait    = new WebDriverWait(_instance, new TimeSpan(0, 0, seconds));
            var by      = ElementLocator.HowToGetElement(selector);
            var elem    = wait.Until(ExpectedConditions.ElementIsVisible(by));
            var text    = elem.Text;
            var oldText = text;
            var waitSum = 0;

            while (oldText == text && waitSum < WaitSeconds * 1000)
            {
                Thread.Sleep(100);
                waitSum += 100;
                elem     = wait.Until(ExpectedConditions.ElementIsVisible(by));
                text     = elem.Text;
            }
            return(LocatedWebElement.CreateLocatedWebElement(elem, Locator, Logger, WaitSeconds));
        }
        public ILocatedWebElement ClickAndWaitForTextChange(string selector, string message = null)
        {
            var wait    = new WebDriverWait(Locator.Driver, new TimeSpan(0, 0, _defaultTimeoutInSeconds));
            var by      = ElementLocator.HowToGetElement(selector);
            var elem    = wait.Until(ExpectedConditions.ElementExists(by));
            var text    = elem.Text;
            var oldText = text;
            var waitSum = 0;

            Click(message);
            while (oldText == text && waitSum < _defaultTimeoutInSeconds * 1000)
            {
                Thread.Sleep(100);
                waitSum += 100;
                elem     = wait.Until(ExpectedConditions.ElementExists(by));
                text     = elem.Text;
            }
            return(new LocatedWebElement(elem, Locator, Logger, _defaultTimeoutInSeconds));
        }
 public static LocatedWebElement CreateLocatedWebElement(IWebElement element, ElementLocator locator, IReportLogger logger, int defaultTimeoutInSeconds = 4)
 {
     return(new LocatedWebElement(element, locator, logger, defaultTimeoutInSeconds));
 }