当前位置: 首页>>代码示例>>C#>>正文


C# WebDriverWait类代码示例

本文整理汇总了C#中WebDriverWait的典型用法代码示例。如果您正苦于以下问题:C# WebDriverWait类的具体用法?C# WebDriverWait怎么用?C# WebDriverWait使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WebDriverWait类属于命名空间,在下文中一共展示了WebDriverWait类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Wait

 public static void Wait(int miliseconds, int maxTimeOutSeconds = 60)
 {
     var wait = new WebDriverWait(Driver, new TimeSpan(0, 0, 1, maxTimeOutSeconds));
     var delay = new TimeSpan(0, 0, 0, 0, miliseconds);
     var timestamp = DateTime.Now;
     wait.Until(webDriver => (DateTime.Now - timestamp) > delay);
 }
开发者ID:AlexMoll91,项目名称:SeleniumExample,代码行数:7,代码来源:SeleniumHelper.cs

示例2: GetPageFilterList

 public string GetPageFilterList()
 {
     driver.SwitchTo().Frame(investigationFRAME);
     WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
     IWebElement element = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#crmGrid_rta_systemuser_rta_inv_case_investigatorid_SavedNewQuerySelector>span")));
     return element.Text;
 }
开发者ID:pjagga,项目名称:SeleniumMSTestVS2013,代码行数:7,代码来源:UserPage.cs

示例3: ShouldMoveAvatar

        public void ShouldMoveAvatar()
        {
            IWebDriver driver = Tools.CreateDriver();
            try
            {
                driver.Navigate().GoToUrl(
                    "http://localhost/projects/test-client/client.xhtml#FIVESTesting&OverrideServerPort=34837");
                Tools.Login(driver, "1", "");

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                IJavaScriptExecutor jsExecutor = driver as IJavaScriptExecutor;

                // Wait for the FIVES.AvatarEntityGuid to become available.
                string avatarGuid = (string)wait.Until(d => jsExecutor.ExecuteScript("return FIVES.AvatarEntityGuid"));

                // Wait until avatar's transform element becomes available.
                IWebElement avatarTransform = wait.Until(d => d.FindElement(By.Id("transform-" + avatarGuid)));

                string startTranslation = avatarTransform.GetAttribute("translation");

                jsExecutor.ExecuteScript("$(document).trigger({type: 'keydown', which: 87, keyCode: 87})");

                // Wait until avatar starts to move.
                wait.Until(d => avatarTransform.GetAttribute("translation") != startTranslation);
            }
            finally
            {
                driver.Quit();
            }
        }
开发者ID:FaisalZ,项目名称:FiVES,代码行数:30,代码来源:AvatarTests.cs

示例4: LoginProfile

        public static void LoginProfile()
        {
            BaseTest.BaseUrl = GooglePage.HomePageUrl;
            BaseTest.Setup(BaseTest.BaseUrl);

            WebDriverWait wait = new WebDriverWait(BaseTest.BaseDriver, TimeSpan.FromSeconds(5));
            wait.Until((d) => { return d.Title.StartsWith("Google"); });

            GooglePage.AreAllElementShown();

            // login btn
            GooglePage.LoginBtn.Click();
            // login page
            // Sign in - Google Accounts
            Thread.Sleep(1500);
            Assert.AreEqual("Вход – Google Профили", BaseTest.BaseDriver.Title);

            Assert.IsTrue(GooglePage.EmailInput.Displayed);
            GooglePage.EmailInput.Clear();
            GooglePage.EmailInput.SendKeys("testqaexam");
            Assert.IsTrue(GooglePage.PasswordInput.Displayed);
            GooglePage.PasswordInput.Clear();
            GooglePage.PasswordInput.SendKeys("TestPass");
            Assert.IsTrue(GooglePage.SigninBtn.Displayed);
            GooglePage.SigninBtn.Click();
            Thread.Sleep(1500);
        }
开发者ID:ekostadinov,项目名称:MyProjects,代码行数:27,代码来源:GoogleLoginTest.cs

示例5: RunTest

        public static void RunTest([NotNull] string url,
		                           [NotNull] string initialPageTitle,
		                           [CanBeNull] IEnumerable<Action<IWebDriver>> testSteps)
        {
            Console.WriteLine(url);

            var steps = new List<Action<IWebDriver>>
                            {
                                b => b.Navigate().GoToUrl(url),
                                b =>
                                    {
                                        if (!String.IsNullOrEmpty(initialPageTitle))
                                        {
                                            var wait = new WebDriverWait(b, TimeSpan.FromSeconds(30));
                                            wait.Until(x => b.Title.Equals(initialPageTitle));

                                            b.Title.ShouldBeEqualTo(initialPageTitle, "incorrect page title");
                                        }
                                    }
                            };
            if (testSteps != null)
            {
                steps.AddRange(testSteps);
            }

            var notification = _runner.PassesTest(steps) ?? new Notification();
            notification.Success.ShouldBeTrue(notification.ToString());
        }
开发者ID:mvbalaw,项目名称:FluentWebUITesting,代码行数:28,代码来源:UITestRunner.cs

示例6: NavigateToDraftFolder

 public static void NavigateToDraftFolder()
 {
     Console.WriteLine("Navigating to Draft folder...");
     driver.FindElement(By.XPath("//*[@id='b-nav_folders']/div/div[3]/a/span")).Click();
     wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
     wait.Until(d => d.FindElement(By.Id("b-letters")));
 }
开发者ID:AlexNaryzhny,项目名称:helloci,代码行数:7,代码来源:TestMailRu.cs

示例7: TestSportsRu

        public void TestSportsRu()
        {
            Console.WriteLine("Test started!");
            const string mailUrl = "https://10minutemail.net";
            const string sportsUrl = "https://sports.ru/";
            using (D)
            {
                D.Navigate().GoToUrl(mailUrl);

                var wait = new WebDriverWait(D, TimeSpan.FromSeconds(30));
                wait.Until(ExpectedConditions.ElementIsVisible(By.Id("fe_text")));

                D.FindElement(By.Id("fe_text")).Click();

                var email = D.FindElement(By.Id("fe_text")).GetAttribute("value");
                var username = email.Split('@').First();
                var password = "www12342";

                D.RegSportsRu(sportsUrl, email, password, username);
                
                D.Navigate().GoToUrl(mailUrl);

                Thread.Sleep(5000);
            }
        }
开发者ID:elv1s42,项目名称:Sandbox,代码行数:25,代码来源:TestSite.cs

示例8: ScrollElement

 public ScrollElement(ScrollerItems item)
 {
     ImageDropName = itemsdrop[item];
     ImageDragName = itemsdrag[item];
     locator = itempath[item];
     var wait = new WebDriverWait(Browser.GetDriver(), TimeSpan.FromMilliseconds(Convert.ToDouble(Configuration.GetTimeout())));
     try
     {
         wait.Until(waiting =>
         {
             try
             {
                 return Browser.GetDriver().FindElement(locator).GetAttribute("style").Contains("background-image: url");
             }
             catch (Exception)
             {
                 return false;
             }
         });
     }
     catch (WebDriverTimeoutException)
     {
         Assert.Fail("Cannot wait until image displayed");
     }
 }
开发者ID:MixolydianBY,项目名称:AutomationDemo,代码行数:25,代码来源:ScrollElement.cs

示例9: WebBlock

 public WebBlock(Session session) : base(session)
 {
     // Wait for the DOM to start changing so we can START waiting for the new element
     this.Pause(200);
     Wait = new WebDriverWait(Session.Driver, new TimeSpan(3000));
     Tag = Wait.Until(driver => driver.GetElement(By.TagName("body")));
 }
开发者ID:Bumblebee,项目名称:Bumblebee.Examples,代码行数:7,代码来源:WebBlock.cs

示例10: WaitUntilElementsPresent

    public static IEnumerable<IWebElement> WaitUntilElementsPresent(this IWebDriver driver, By selector)
    {
      var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
      wait.Until(ExpectedConditions.ElementExists(selector));

      return driver.FindElements(selector);
    }
开发者ID:mikeedwards83,项目名称:Habitat,代码行数:7,代码来源:SeleniumExtensions.cs

示例11: ClickAddNewTenancyRequestButton

 public void ClickAddNewTenancyRequestButton()
 {
     RefreshPageFrame.RefreshPage(driver, frameId);
     this.driver.SwitchTo().Frame(FRAMETenancyRequest);
     WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
     wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("img[alt='Add New Tenancy Request']"))).Click();
 }
开发者ID:pjagga,项目名称:SeleniumMSTestVS2013,代码行数:7,代码来源:AddressDetailPage.cs

示例12: sumi

        public void sumi()
        {
            IWebElement element;
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

            // webpegeを表示
            driver.Navigate().GoToUrl("https://www.f-aspit.com/aspit/portal/login.asp");
            driver.FindElement(By.Name("KigyoCD")).SendKeys("99990005");
            driver.FindElement(By.Name("UserID")).SendKeys("goen9995");
            driver.FindElement(By.Name("Password")).SendKeys("354959");
            driver.FindElement(By.CssSelector("img[id='img01']")).Click();

            driver.SwitchTo().Frame("fraNews");
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
            wait.Until(ExpectedConditions.ElementToBeClickable(By.Name("btnMenu0")));
            element = driver.FindElement(By.Name("btnMenu0"));
            element.SendKeys(Keys.Enter);
            wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.Name("btnMenu0")));
            wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt("main"));
            element = driver.FindElement(By.LinkText("受注照会"));
            element.SendKeys(Keys.Enter);
            driver.FindElement(By.Name("selFromDay")).Click();
            driver.FindElement(By.XPath("//span[@id='idTargetKikanArea_From_Day']/select//option[1]")).Click();
            driver.FindElement(By.Id("imgDownload")).Click();
            //ここにダウンロード処理を入れる
            driver.Quit();
        }
开发者ID:shigusa,项目名称:Senri,代码行数:27,代码来源:aspit_joune_sumi.cs

示例13: WaitForPageToLoad

        public static void WaitForPageToLoad(this IWebDriver driver)
        {
            TimeSpan timeout = new TimeSpan(0, 0, 100);
            WebDriverWait wait = new WebDriverWait(driver, timeout);
            IJavaScriptExecutor javaScript = driver as IJavaScriptExecutor;
            if (javaScript == null)
                throw new ArgumentException("driver", "driver must support javascript execution");

            wait.Until((d) =>
            {
                try
                {
                    string readyState =
                        javaScript.ExecuteScript("if (document.readyState) return document.readystate;").ToString();
                    return readyState.ToLower() == "complete";
                }
                catch (InvalidOperationException e)
                {
                    //Window is no lonfer available
                    return e.Message.ToLower().Contains("unable to get browser");
                }
                catch (WebDriverException e)
                {
                    //Browser is no longer available
                    return e.Message.ToLower().Contains("unable to connect");
                }
                catch (Exception)
                {
                    return false;
                }
            });
        }
开发者ID:venkatakumar9,项目名称:AKEcommerceAutomationTesting,代码行数:32,代码来源:WaitFor.cs

示例14: SearchNotExistingBug

        public void SearchNotExistingBug()
        {
            BaseTest.BaseUrl = BugTrackerPage.HomePageUrl;
            BaseTest.Setup(BaseTest.BaseUrl);

            WebDriverWait wait = new WebDriverWait(BaseTest.BaseDriver, TimeSpan.FromSeconds(5));
            wait.Until((d) => { return d.Title.StartsWith("BugTracker"); });

            BugTrackerPage.AreAllElementShown();

            BugTrackerPage.BugIdTextInput.Clear();
            BugTrackerPage.BugIdTextInput.SendKeys("123abc");
            BugTrackerPage.GotoIdBtn.Click();

            try
            {
                Assert.IsTrue(BugTrackerPage.ErrorMsgLabel.Displayed);
            }
            catch (NoSuchElementException nsee)
            {
                Thread.Sleep(1500);
                Assert.IsTrue(BugTrackerPage.ErrorMsgLabel.Displayed);
            }

            string expectedErrMsg = "Error: Bug ID must be an integer.";
            Assert.AreEqual(expectedErrMsg, BugTrackerPage.ErrorMsgLabel.Text);

            BaseTest.TearDown();
        }
开发者ID:ekostadinov,项目名称:MyProjects,代码行数:29,代码来源:SearchNotExistingBugId.cs

示例15: TestExplicitWait

        public void TestExplicitWait()
        {
            IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver");
            driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/AjaxDemo.html");

            try
            {
             			    IWebElement page4button = driver.FindElement(By.LinkText("Page 4"));
             			    page4button.Click();

               WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
               IWebElement message = wait.Until<IWebElement>((d) =>
               {
                    return d.FindElement(By.Id("page4"));
               });

             			    Assert.IsTrue(message.Text.Contains("Nunc nibh tortor"));

             		    }
            catch (NoSuchElementException e)
            {
             			    Assert.Fail("Element not found!!");
             		    } finally {
             			    driver.Close();
             		    }
        }
开发者ID:oluk68,项目名称:SELENIUM2,代码行数:26,代码来源:ExplicitWaitTests.cs


注:本文中的WebDriverWait类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。