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


C# WebDriverWait.Until方法代码示例

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


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

示例1: 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

示例2: GoogleSearch

        public GoogleSearch(IWebDriver driver, string p1, string p2)
        {
            try
            {
                driver.Navigate().GoToUrl("http://www.google.pt");

                driver.FindElement(By.Name("q")).SendKeys(p1);
                Logger.Out("Driver title before send keys enter =" + driver.Title);
                //get the suggestions box from google
                Logger.Out(DateTime.Now.ToString());
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
                 wait.Until((d) => { return d.FindElement(By.ClassName("gssb_e")).Displayed; });
                IWebElement resultsDiv = driver.FindElement(By.ClassName("gssb_e"));
                Logger.Out(DateTime.Now.ToString());
                //// If results have been returned, the results are displayed in a drop down.
                if (resultsDiv.Displayed)
                {
                    Logger.Out("Suggestions appeared");
                }
                else
                    throw new Exception("No suggestions");
                driver.FindElement(By.Name("q")).SendKeys(Keys.Enter);
                Logger.Out("before wait"+driver.Title);
                wait.Until((d) => { return d.Title.StartsWith("banana"); });
                //Check that the Title is what we are expecting
                Assert.AreEqual(p1+" - Pesquisa do Google", driver.Title);
                Logger.Out("after wait & assert- "+driver.Title);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:jpita,项目名称:seleniumDotNetTests,代码行数:33,代码来源:GoogleSearch.cs

示例3: Main

        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl(@"http://www.weibo.com");

            WebDriverWait waitPageOpen = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
            IWebElement inpt_username = waitPageOpen.Until<IWebElement>((d) => { return d.FindElement(By.Name("username")); });
            waitPageOpen.Until((d) => { return inpt_username.Displayed; });
            inpt_username.SendKeys(@"[email protected]");

            IWebElement inpt_pwd = driver.FindElement(By.Name("password"));
            inpt_pwd.SendKeys(@"kodakpdc2000");

            IWebElement btn_login = driver.FindElement(By.ClassName("W_btn_g"));
            btn_login.Click();

            waitPageOpen.Until((d)=>{return d.Title.StartsWith("我的首页");});

            //IList<IWebElement> personInfos = driver.FindElements(By.ClassName("user_atten"));
            //if (personInfos.Count == 1)
            //{ personInfos[0].FindElement(By.PartialLinkText("粉丝")).Click(); }

            IWebElement temp = driver.FindElement(By.PartialLinkText("粉丝"));
            temp.Click();

            Console.Read();
        }
开发者ID:AnnikaXiao,项目名称:SeleniumWeibo2,代码行数:28,代码来源:Program.cs

示例4: SetPageFilterList

 public void SetPageFilterList(string value)
 {
     WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
     wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#crmGrid_SavedNewQuerySelector>span"))).Click();
     IWebElement parent = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("Dialog_0")));
     parent.FindElement(By.XPath("//li[a[contains(@title,'"+value+"')]]")).Click();
 }
开发者ID:pjagga,项目名称:SeleniumMSTestVS2013,代码行数:7,代码来源:QueueSearchPage.cs

示例5: OpenPayPal

 public static bool OpenPayPal()
     {
         var wait = new WebDriverWait(Drivers.Driver, TimeSpan.FromSeconds(5));
         wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("a[class='btn btn-warning ex en']"))).Click();
         bool openpaypal = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("billingBox"))).Displayed;
         return openpaypal;
      }
开发者ID:katyushin,项目名称:Automation-Auto_Course-CSharp-a.katyushin-MyProject,代码行数:7,代码来源:Payment.cs

示例6: GoToCard

 public static bool GoToCard()
 {
     var wait = new WebDriverWait(Drivers.Driver, TimeSpan.FromSeconds(40));
     wait.Until(ExpectedConditions.ElementIsVisible(By.Id("headerShoppingCart"))).Click();
     bool goods = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(".row.rounded.productLists"))).Displayed;
     return goods;
 }
开发者ID:katyushin,项目名称:Automation-Auto_Course-CSharp-a.katyushin-MyProject,代码行数:7,代码来源:Orders.cs

示例7: Execute

        public override void Execute(IWebDriver driver, dynamic context)
        {
            var resolvedSelector = Test.ResolveMacros(Selector);

            var wait = new WebDriverWait(driver, TimeSpan.FromMilliseconds(Timeout == 0 ? 5000 : Timeout));

            try
            {
                if (WaitForVisible)
                {
                    wait.Until(d => ExpectedConditions.ElementIsVisible(By.CssSelector(resolvedSelector))(d));
                }
                else
                {
                    wait.Until(d => d.FindElement(By.CssSelector(resolvedSelector)));
                }
                if (IsFalseExpected)
                    throw new InvalidOperationException("Element with selector '" + Selector + "' exists.");
            }
            catch (WebDriverTimeoutException)
            {
                if (!IsFalseExpected)
                    throw;
            }
        }
开发者ID:MGetmanov,项目名称:Selenite,代码行数:25,代码来源:DoWaitForElementCommand.cs

示例8: 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

示例9: Lookup

            /// <summary>
            /// Lookup a reference field value.
            /// </summary>
            /// <param name="driver"></param>
            /// <param name="by">A mechanism by which to find the desired reference field within the current document.</param>
            /// <param name="sendKeys">A property value of the current reference field.</param>
            public static void Lookup(this IWebDriver driver, By by, string sendKeys)
            {
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));

                IWebElement lookup = wait.Until(ExpectedConditions.ElementIsVisible(by));
                lookup.Click();

                string currentWindowHandle = driver.CurrentWindowHandle;
                string searchWindow = driver.WindowHandles.First(o => o != currentWindowHandle);
                driver.SwitchTo().Window(searchWindow);

                IWebElement searchFor = wait.Until(ExpectedConditions.ElementExists(By.ClassName("list_search_text")));
                searchFor.Click();
                searchFor.Clear();
                searchFor.SendKeys(sendKeys);

                var selects = driver.FindElements(By.ClassName("list_search_select"));
                IWebElement search = selects.First(o => o.GetAttribute("id").Contains("_select"));
                driver.SelectOption(search, "Name"); //"for text");

                wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("img[title='Go']"))).Click();

                IWebElement item = wait.Until(ExpectedConditions.ElementExists(By.LinkText(sendKeys)));

                item.Click();

                driver.SwitchTo().Window(currentWindowHandle);
                driver.SwitchTo().Frame("gsft_main");
            }
开发者ID:rburkitt,项目名称:ServiceNowWebDriverExtensions,代码行数:35,代码来源:WebDriverExtensions.cs

示例10: Myaccount

 public static void Myaccount()
 {
     var wait = new WebDriverWait(Drivers.Driver, TimeSpan.FromSeconds(5));
     wait.Until(ExpectedConditions.ElementIsVisible(By.LinkText("My Account"))).Click();
     wait.Until(ExpectedConditions.ElementIsVisible(By.LinkText("Address"))).Click();
     wait.Until(ExpectedConditions.ElementIsVisible(By.LinkText("Add new address"))).Click();
 }
开发者ID:katyushin,项目名称:Automation-Auto_Course-CSharp-a.katyushin-MyProject,代码行数:7,代码来源:AddAdress.cs

示例11: AddProject

        public void AddProject()
        {
            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();

            Assert.AreEqual("BugTracker.NET - bugs", BaseTest.BaseDriver.Title);
            // add new bug
            BugTrackerPage.AddNewBugBtn.Click();

            wait.Until((d) => { return d.Title.StartsWith("BugTracker.NET - Create Bug"); });

            try
            {
                Assert.AreEqual("Project:", BugTrackerPage.ProjectTextLabel.Text);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Assert.IsTrue(BugTrackerPage.ProjectSelect.Displayed);
            var select = new SelectElement(BugTrackerPage.ProjectSelect);
            select.SelectByText("HasCustomFieldsProject");
            //BaseTest.BaseDriver.FindElement(By.XPath("//option[@value='3']")).Click();
            Assert.AreEqual("Project-specific", BugTrackerPage.ProjectSpecificLabel.Text);
            Assert.IsTrue(BugTrackerPage.ProjectSpecificSelect.Displayed);

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

示例12: GoTo

 public static void GoTo()
 {
     Drivers.Driver.Navigate().GoToUrl(Drivers.BaseAddress);
     var wait = new WebDriverWait(Drivers.Driver, TimeSpan.FromSeconds(5));
     wait.Until(ExpectedConditions.ElementIsVisible(By.LinkText("Sign In"))).Click();
     wait.Until(ExpectedConditions.ElementIsVisible(By.Id("login-form")));
 }
开发者ID:katyushin,项目名称:Automation-Auto_Course-CSharp-a.katyushin-MyProject,代码行数:7,代码来源:LoginPage.cs

示例13: PayPal

 public static bool PayPal()
 {
     Drivers.Driver.FindElement(By.Id("batchRemove")).Click();
     var wait = new WebDriverWait(Drivers.Driver, TimeSpan.FromSeconds(10));
     wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("a[class='btn btn-warning ex ru']"))).Click();
     bool paypal = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("billingBox"))).Displayed;
     return paypal;
 }
开发者ID:katyushin,项目名称:Automation-Auto_Course-CSharp-a.katyushin-MyProject,代码行数:8,代码来源:Orders.cs

示例14: Quantity

 public static void Quantity()
 {
 //________________________________Выбор кол-ва товара_____________________________
 var wait = new WebDriverWait(Drivers.Driver, TimeSpan.FromSeconds(10));
 wait.Until(ExpectedConditions.ElementIsVisible(By.Id("quantity"))).SendKeys("\b10");
 wait.Until(ExpectedConditions.ElementIsVisible(By.Id("addToCart"))).Click();
     Drivers.Driver.FindElement(By.Id("addToCart")).Click();
 }
开发者ID:katyushin,项目名称:Automation-Auto_Course-CSharp-a.katyushin-MyProject,代码行数:8,代码来源:Orders.cs

示例15: ClickAvailabilityList

 public void ClickAvailabilityList()
 {
     WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
     IWebElement elem = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#FormTitle>h1")));
     string title = elem.GetAttribute("title");
     wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#rta_availability>div"))).Click();
     wait.Until(ExpectedConditions.ElementIsVisible(By.Id("rta_availability_i"))).GetAttribute("id");
 }
开发者ID:pjagga,项目名称:SeleniumMSTestVS2013,代码行数:8,代码来源:ClientPhoneNumberPage.cs


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