use of com.ruiyun.jvppeteer.core.page.ElementHandle in project epic4j by huisunan.
the class PageUtil method waitForTextChange.
@SneakyThrows
public void waitForTextChange(Page page, String selector, String text, Integer timeout, Integer interval) {
timer(timeout, interval, i -> {
ElementHandle elementHandle = page.$(selector);
log.trace("wait {} text change count {}", selector, i);
if (elementHandle != null) {
String textContent = getElementStrProperty(elementHandle, "textContent");
log.trace("textContent:{}", textContent);
return !text.equalsIgnoreCase(textContent);
}
return false;
}, () -> {
throw new TimeException("wait text change timeout :" + text);
});
}
use of com.ruiyun.jvppeteer.core.page.ElementHandle in project epic4j by huisunan.
the class PageUtil method elementHandle.
@SneakyThrows
public void elementHandle(Page page, String selector, Integer timeout, Integer interval, EConsumer<ElementHandle> consumer) {
timer(timeout, interval, i -> {
log.trace("[{}]wait for selector:{}", i, selector);
ElementHandle elementHandle = page.$(selector);
if (elementHandle != null) {
log.trace("start consumer");
consumer.accept(elementHandle);
log.trace("end consumer");
// 点击后延迟2秒等待处理
TimeUnit.SECONDS.sleep(2);
return true;
}
return false;
}, () -> {
throw new TimeoutException("wait for selector " + selector + " time out");
});
}
use of com.ruiyun.jvppeteer.core.page.ElementHandle in project epic4j by huisunan.
the class PageUtil method elementHandle.
@SneakyThrows
public void elementHandle(Page page, String selector, Integer timeout, Integer sleep, EConsumer<ElementHandle> consumer) {
ElementHandle elementHandle = page.waitForSelector(selector, SelectorUtil.timeout(ObjectUtil.defaultIfNull(timeout, 30000)));
consumer.accept(elementHandle);
TimeUnit.MILLISECONDS.sleep(ObjectUtil.defaultIfNull(sleep, 2000));
}
use of com.ruiyun.jvppeteer.core.page.ElementHandle in project epic4j by huisunan.
the class PageUtil method waitForTextChange.
@SneakyThrows
public Boolean waitForTextChange(Page page, String selector, String text, Integer timeout, Integer interval) {
for (int i = 0; i < timeout; i += interval) {
ElementHandle elementHandle = page.$(selector);
log.trace("wait {} text change count {}", selector, i);
if (elementHandle != null) {
String textContent = getElementStrProperty(elementHandle, "textContent");
if (!text.equals(textContent)) {
return true;
}
}
TimeUnit.MILLISECONDS.sleep(interval);
}
throw new TimeException("wait text change timeout :" + text);
}
Aggregations