Se(17)---三種等待

package test;

成都創(chuàng)新互聯(lián)公司長期為成百上千客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為雙鴨山企業(yè)提供專業(yè)的網(wǎng)站建設(shè)、成都做網(wǎng)站雙鴨山網(wǎng)站改版等技術(shù)服務(wù)。擁有10年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.support.ui.ExpectedCondition;

import org.openqa.selenium.support.ui.WebDriverWait;

import org.testng.annotations.Test;

public class buttongroup {

@Test

public void test() throws InterruptedException{

System.setProperty("webdriver.chrome.driver", "D:/01 Learn WebDriver/chromedriver.exe");

WebDriver dr = new ChromeDriver();

dr.manage().window().maximize();

        dr.get("file:///C:/Users/fengchuanyun/Desktop/1/%E8%87%AA%E5%8A%A8%E5%8C%96%E7%BB%83%E4%B9%A0/status.html");

      

        //1.強(qiáng)制等待

        //Thread.sleep(2000);

        

        //2.顯性等待,wait類,總共等10秒,每1秒檢查一次,通常只寫前兩個參數(shù)

        /*(new WebDriverWait(dr,10,1)).until(new ExpectedCondition<Boolean>() {

@Override

public Boolean apply(WebDriver d) {

//timeout異常

//return d.findElement(By.xpath("http://*[@name='display']")).isDisplayed();

//可以找到

return d.findElement(By.xpath("http://*[@name='radio']")).isDisplayed();

}

});

        

        dr.findElement(By.xpath("http://*[@name='radio']")).click();

        

        

        System.out.println(dr.findElement(By.name("radio")).isDisplayed());*/

        

        //3.隱形等待

        //定位元素 超時設(shè)置

        dr.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

        //頁面初始化超時

        //dr.manage().timeouts().pageLoadTimeout(3, TimeUnit.SECONDS);

        

        System.out.print("hhh");

        

        

//dr.quit();

}

}

        

    

分享標(biāo)題:Se(17)---三種等待
文章來源:http://bm7419.com/article46/pssphg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、品牌網(wǎng)站建設(shè)、、網(wǎng)站改版ChatGPT、企業(yè)網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化