selenium(Java)WebDriverWait等待機制

來源:互聯網
上載者:User

標籤:nstat   nts   driver   value   不可   contains   下拉   ted   text   

       //標題是不是“百度一下,你就知道”18         new WebDriverWait(driver,5).until(ExpectedConditions.titleIs("百度一下,你就知道"));19         //標題是不是包含“百度一下”20         new WebDriverWait(driver,5).until(ExpectedConditions.titleContains("百度一下"));21         //判斷該元素是否被載入在DOM中,並不代表該元素一定可見        22         new WebDriverWait(driver,5).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=‘kw‘]")));23         //判斷元素(定位後)是否可見24         new WebDriverWait(driver,5).until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@id=‘kw‘]"))));25         //判斷元素是否可見(非隱藏,並且元素的寬和高都不等以0)26         new WebDriverWait(driver,5).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=‘kw‘]")));27         //只要存在一個就是true28         ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//*[@id=‘kw‘]"));29         //元素中的text是否包含參數中的的字串30         ExpectedConditions.textToBePresentInElementLocated(By.xpath("//*[@id=‘kw‘]"), "百度一下");31         //元素的value屬性中是否包含參數中的字串32         ExpectedConditions.textToBePresentInElementValue(By.xpath("//*[@id=‘kw‘]"), "***");33         //判斷該表單是否可以切過去,可以就切過去並返回true,否則放回false34         ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("**"));35         //判斷某個元素是否不存在於DOM或不可見36         ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@id=‘kw‘]"));37         //判斷元素是否可以點擊38         ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=‘kw‘]"));39         //等到一個元素從DOM中移除40         ExpectedConditions.stalenessOf(driver.findElement(By.xpath("//*[@id=‘kw‘]")));41         //判斷某個元素是否被選中,一般用在下拉式清單42         ExpectedConditions.elementToBeSelected(By.xpath("//*[@id=‘kw‘]"));43         //判斷某個元素的選中狀態是否符合預期44         ExpectedConditions.elementSelectionStateToBe(By.xpath("//*[@id=‘kw‘]"), true);45         //判斷某個元素(已定位)的選中狀態是否符合預期46         ExpectedConditions.elementSelectionStateToBe(driver.findElement(By.xpath("//*[@id=‘kw‘]")), false);47         //判斷頁面中是否存在alert48         new WebDriverWait(driver,5).until(ExpectedConditions.alertIsPresent());

selenium(Java)WebDriverWait等待機制

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.