標籤: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等待機制