Java 如何在测试中进行延迟以使页面完全加载?
我使用,如何在测试第一个复选框后进行延迟?以下是测试:Java 如何在测试中进行延迟以使页面完全加载?,java,junit,Java,Junit,我使用,如何在测试第一个复选框后进行延迟?以下是测试: @Test public void produrtTest(){ onSite().onMainPage().getButton().findElement(By.xpath("//*[@id=\"-category-section\"]/div/ul/li[1]/label/span")).click(); onSite().onMainPage().getButton().
@Test
public void produrtTest(){
onSite().onMainPage().getButton().findElement(By.xpath("//*[@id=\"-category-section\"]/div/ul/li[1]/label/span")).click();
onSite().onMainPage().getButton().findElement(By.xpath("//*[@id=\"-
category-section\"]/div/ul/li[2]/label/span")).click();
}
我使用了@Retry注释(timeout=20,polling=5000)
等待20秒以加载页面,但没有暂停
如何使用waitUntil()方法也不清楚。在您正在使用的工具的最前端有以下部分:
正在等待页面加载。有一个特殊的shouldUrl(匹配器)
url),它在条件下等待页面的当前url和
document.readyState标志
以及
等待单个元素的条件。AtlasWebElement有两个
不同的等待扩展方法
First-Waitill(Matcher Matcher),它使用可配置的
在已传递的匹配器中的某个条件下超时和轮询,引发
如果条件未满足,则为java.lang.RuntimeException
Second-should(Matcher-Matcher),它以相同的方式等待传递的数据
matcher,但抛出java.lang.AssertionError
其中一个应该可以满足您的需要,具体取决于您正在等待的内容(您没有指定)。我使用了site().onMainPage().getButton().waitunt(DisplayedMatcher.displayed(),10)。findElement(By.xpath(“/*[@id=\”-category section\”]/div/ul/li[1]/label/span”)。单击();
@BaseUrl("http://www.base.url/search")
public interface SearchPage extends WebPage {
@Description("Account button")
@FindBy("//div[@class = 'account-button']")
AtlasWebElement accountButton();
}
@BaseUrl("http://www.base.url/account")
public interface AccountPage extends WebPage {
//elements for account page here
}