如何在测试中进行延迟以使页面完全加载

  • 本文关键字:加载 延迟 测试 java junit
  • 更新时间 :
  • 英文 :


我使用io.qameta.atlas,在测试第一个复选框后如何进行延迟?测试如下:

@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 annotation(timeout = 20, polling = 5000)等待20秒以加载页面,但没有暂停。

如何使用waitUntil((方法也不清楚。

在您正在使用的工具的首页有以下部分:

正在等待页面加载有一个特殊的shouldUrl(匹配器url(,等待页面当前url的条件,以及document.readyState标志。

@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
}

以及

正在等待单个元素的条件AtlasWebElement有两个不同的扩展方法等待。

First-waitUntil(Matcher Matcher(,使用可配置的在通过的比赛中,在某些条件下暂停和轮询,投掷java.lang.RuntimeException(如果条件未得到满足(。

第二个应该(Matcher Matcher(,它以相同的方式等待通过的matcher,但却抛出java.lang.AssertionError。

其中一个应该能满足您的需求,这取决于您在等待什么(您没有指定(。

最新更新