use of com.ruiyun.jvppeteer.options.WaitForSelectorOptions in project epic4j by huisunan.
the class SelectorUtil method timeout.
public WaitForSelectorOptions timeout(Integer timeout) {
WaitForSelectorOptions options = new WaitForSelectorOptions();
options.setTimeout(timeout);
return options;
}
use of com.ruiyun.jvppeteer.options.WaitForSelectorOptions in project epic4j by huisunan.
the class SelectorUtil method timeout.
public WaitForSelectorOptions timeout(Integer timeout) {
WaitForSelectorOptions options = new WaitForSelectorOptions();
options.setTimeout(timeout);
return options;
}
use of com.ruiyun.jvppeteer.options.WaitForSelectorOptions in project epic4j by huisunan.
the class PageUtil method findSelectors.
/**
* 在指定范围时间内,遍历查找
*
* @param page page
* @param timeout 超时时间
* @param ignore true忽略异常
* @param timeoutBack 超时后回调
* @param selectItems 要查询的元素
*/
@SneakyThrows
public void findSelectors(Page page, Integer timeout, Boolean ignore, SelectItem.SelectCallBack timeoutBack, SelectItem... selectItems) {
WaitForSelectorOptions options = new WaitForSelectorOptions();
options.setTimeout(timeout);
// 100ms
int interval = 100;
for (int i = 0; i < timeout; i += interval) {
for (SelectItem selectItem : selectItems) {
boolean flag = false;
try {
flag = selectItem.getPagePredicate().test(page, selectItem);
} catch (Exception e) {
if (ignore)
log.debug("ignore exception", e);
else
throw e;
}
if (flag) {
boolean isContinue = selectItem.getCallback().run();
if (!isContinue) {
return;
}
}
}
TimeUnit.MILLISECONDS.sleep(interval);
}
if (timeoutBack != null) {
timeoutBack.run();
}
}
Aggregations