Пример #1
0
        public void AnimateResizeWidthAndHeight()
        {
            var resizablePage = new ResizablePage(this.driver);

            resizablePage.AnimateIncreaseWidthAndHeightBy(250, 200);
            resizablePage.AssertAnimation();
            DefaultWait <IWebElement> wait = new DefaultWait <IWebElement>(resizablePage.AnimateResizeWindow);

            wait.Timeout         = TimeSpan.FromMinutes(2);
            wait.PollingInterval = TimeSpan.FromMilliseconds(250);

            Func <IWebElement, bool> waiter = new Func <IWebElement, bool>((IWebElement ele) =>
            {
                String styleAttrib = resizablePage.AnimateResizeWindow.GetAttribute("style");
                if (!styleAttrib.Contains("overflow"))
                {
                    return(true);
                }
                return(false);
            });

            wait.Until(waiter);

            resizablePage.AssertAnimateNewSize(250, 200);

            /*Stop script for some time
             *
             * Thread.Sleep(6000);
             * driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(50);
             * driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(500);
             * driver.Manage().Timeouts().PageLoad =TimeSpan.FromSeconds(500);
             *
             * Case 1 (wait):
             *
             * WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.id(“myId")));
             *
             * WebDriverWait wait = new WebDriverWait(this.Driver, TimeSpan.FromSeconds(10));
             * wait.until(ExpectedConditions.visibilityOfElementLocated(By.tagName("input")));
             *
             * wait.Until(driver => driver.FindElement(By.Id("someLabelId")).Text == "expectedValue")
             *
             * Case 2 (wait):
             *
             * WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMinutes(1));
             * Func<IWebDriver, bool> waitForElement = new Func<IWebDriver, bool>((IWebDriver Web) =>
             * {
             *  Console.WriteLine(Web.FindElement(By.Id("target")).GetAttribute("innerHTML"));
             *  return true;
             * });
             * wait.Until(waitForElement);
             *
             * Case 3 (wait):
             *
             * IWebElement element = driver.FindElement(By.Id("colorVar"));
             * DefaultWait<IWebElement> wait = new DefaultWait<IWebElement>(element);
             * wait.Timeout = TimeSpan.FromMinutes(2);
             * wait.PollingInterval = TimeSpan.FromMilliseconds(250);
             *
             * Func<IWebElement, bool> waiter = new Func<IWebElement, bool>((IWebElement ele) =>
             *  {
             *      String styleAttrib = element.GetAttribute("style");
             *      if (styleAttrib.Contains("red"))
             *      {
             *          return true;
             *      }
             *      Console.WriteLine("Color is still " + styleAttrib);
             *       return false;
             *  });
             * wait.Until(waiter);
             */

            resizablePage.AnimateIncreaseWidthAndHeightBy(100);
            resizablePage.AssertAnimation();
            wait.Timeout         = TimeSpan.FromMinutes(2);
            wait.PollingInterval = TimeSpan.FromMilliseconds(250);
            wait.Until(waiter);
            resizablePage.AssertAnimateNewSize(100, 100);

            resizablePage.AnimateIncreaseWidthBy(100);
            resizablePage.AssertAnimation();
            wait.Timeout         = TimeSpan.FromMinutes(2);
            wait.PollingInterval = TimeSpan.FromMilliseconds(250);
            wait.Until(waiter);
            resizablePage.AssertAnimateNewSize(100, 0);

            resizablePage.AnimateIncreaseHeightBy(100);
            resizablePage.AssertAnimation();
            wait.Timeout         = TimeSpan.FromMinutes(2);
            wait.PollingInterval = TimeSpan.FromMilliseconds(250);
            wait.Until(waiter);
            resizablePage.AssertAnimateNewSize(0, 100);
        }