作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在测试一个网页,它的一些内容加载了 XMLHttpRequest
.我需要检查我的 <table>
在 Ajax 调用之后包含 2 行(因为页面在加载时已经包含 1 行)。
我的测试:
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
driver.get("http://localhost/index.html");
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
}
@Test
public void testIfPartnerListPageIsPresent() {
driver.findElement(By.id("123")).click();
List<WebElement> rawList = driver.findElement(By.id("id-213"))
.findElements(By.tagName("tr"));
assertTrue("More than 1 raw", rawList.size() > 1);
}
我如何要求 Selenium 等待我表中的其他行?
最佳答案
此函数将等到表至少包含给定的行数
public void waitUntilRowPopulates(WebElement element, final int rowCount) {
final WebElement table = element;
new FluentWait<WebDriver>(driver)
.withTimeout(60, TimeUnit.SECONDS)
.pollingEvery(10, TimeUnit.MILLISECONDS)
.until(new Predicate<WebDriver>() {
public boolean apply(WebDriver d) {
List<WebElement> rawList = table.findElements(By.tagName("tr"));
return (rawList.size() >= rowCount);
}
});
}
关于java - 如何等待一定数量的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22707284/
我正在尝试开发右边框/Angular 具有特定 Angular (30°) 的表格。我见过一些类似的解决方案,但它们都无法在一定程度上发挥作用。如果我想从 30° 改变到 20°,我不想花太多力气。
我是一名优秀的程序员,十分优秀!