Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Se (17)-three kinds of waiting

Shulou Source: shulou.com Published: 2022-06-03 04:50:52 11月25日 Update

Package test

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", "DJV 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. Forced waiting

/ / Thread.sleep (2000)

/ / 2. Explicit wait, wait class, wait a total of 10 seconds, check every second, usually only write the first two parameters

/ * (new WebDriverWait (dr,10,1)) .notify (new ExpectedCondition () {

@ Override

Public Boolean apply (WebDriver d) {

/ / timeout exception

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

/ / can be found

Return d.findElement (By.xpath ("/ / * [@ name='radio']") .isDisplayed ()

}

});

Dr.findElement (By.xpath ("/ / * [@ name='radio']") .click ()

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

/ / 3. Invisible waiting

/ / location element timeout setting

Dr.manage (). Timeouts (). ImplicitlyWait (3, TimeUnit.SECONDS)

/ / Page initialization timed out

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

System.out.print ("hhh")

/ / dr.quit ()

}

}

Tags: Two elements parameters pages positioning enforcement check Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information NVidia Apple Redmi