本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.waitForBackgroundJavaScriptStartingBefore()
方法的一些代码示例,展示了WebClient.waitForBackgroundJavaScriptStartingBefore()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.waitForBackgroundJavaScriptStartingBefore()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:waitForBackgroundJavaScriptStartingBefore
[英]Experimental API: May be changed in next release and may not yet work perfectly!
This method blocks until all background JavaScript tasks scheduled to start executing before (now + delayMillis) have finished executing. Background JavaScript tasks are JavaScript tasks scheduled for execution via window.setTimeout, window.setInterval or asynchronous XMLHttpRequest.
If there is no background JavaScript task currently executing, and there is no background JavaScript task scheduled to start executing within the specified time, this method returns immediately -- even if there are tasks scheduled to be executed after (now + delayMillis).
Note that the total time spent executing a background JavaScript task is never known ahead of time, so this method makes no guarantees as to how long it will block.
Use this method instead of #waitForBackgroundJavaScript(long) if you know roughly when your background JavaScript is supposed to start executing, but you're not necessarily sure how long it will take to execute.
[中]实验API:可能会在下一个版本中更改,可能还不能完美工作!
此方法会一直阻止,直到所有计划在(现在+延迟毫秒)之前开始执行的后台JavaScript任务完成执行。后台JavaScript任务是计划通过Windows执行的JavaScript任务。设定超时,窗口。setInterval或异步XMLHttpRequest。
如果当前没有正在执行的后台JavaScript任务,并且没有计划在指定时间内开始执行的后台JavaScript任务,则此方法立即返回——即使有计划在(现在+延迟毫秒)之后执行的任务也是如此。
请注意,执行后台JavaScript任务所花费的总时间永远不会提前知道,因此该方法不保证它将阻塞多长时间。
如果您大致知道背景JavaScript应该何时开始执行,但不一定确定执行需要多长时间,请使用此方法,而不是#waitForBackgroundJavaScript(long)。
代码示例来源:origin: mrdear/JavaWEB
public List<ConfigsBean> fetch(WebClient webClient) throws IOException, InterruptedException {
webClient.waitForBackgroundJavaScriptStartingBefore(1000);
//拿到整个页面
final HtmlPage page = webClient.getPage(HOME_PAGE);
//等待js执行
Thread.sleep(500);
//开始解析
List<ConfigsBean> lists = new ArrayList<>();
for (int i = 0; i < 4; i++) {
ConfigsBean config = parsePage(page,i);
lists.add(config);
}
//移除null元素
lists.removeIf(configsBean -> configsBean==null);
return lists;
}
代码示例来源:origin: com.atlassian.integrationtesting/atlassian-integrationtesting-lib
public int waitForAsyncEventsThatBeginWithin(long delayMillis)
{
checkCurrentPage();
return webClient.waitForBackgroundJavaScriptStartingBefore(delayMillis);
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
return waitForBackgroundJavaScriptStartingBefore(newDelay);
代码示例来源:origin: HtmlUnit/htmlunit
return waitForBackgroundJavaScriptStartingBefore(newDelay);
代码示例来源:origin: org.jvnet.hudson/htmlunit
return waitForBackgroundJavaScriptStartingBefore(newDelay);
代码示例来源:origin: com.github.albfernandez.test-jsf/jsf-test-scriptunit
protected void setupQunit(FrameworkMethod method, Object target) throws FailingHttpStatusCodeException, IOException {
URL URL = new URL(DEFAULT_URL+"/");
setupWebClient();
String content = buildContent(method,target);
mockConnection.setResponse(URL, content);
page = webClient.getPage(URL);
webClient.waitForBackgroundJavaScriptStartingBefore(4 * 60 * 1000);
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
return waitForBackgroundJavaScriptStartingBefore(newDelay);
代码示例来源:origin: org.jenkins-ci/htmlunit
return waitForBackgroundJavaScriptStartingBefore(newDelay);
代码示例来源:origin: stackoverflow.com
@Test
public void TestCall() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setUseInsecureSSL(true); //ignore ssl certificate
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
String url = "https://www.wearvr.com/#game_id=game_4";
HtmlPage myPage = webClient.getPage(url);
webClient.waitForBackgroundJavaScriptStartingBefore(200);
webClient.waitForBackgroundJavaScript(20000);
//do stuff on page ex: myPage.getElementById("main")
//myPage.asXml() <- tags and elements
System.out.println(myPage.asText());
}
代码示例来源:origin: stackoverflow.com
@Test
public void TestCall() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setUseInsecureSSL(true); //ignore ssl certificate
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
String url = "https://www.wearvr.com/#game_id=game_4";
HtmlPage myPage = webClient.getPage(url);
webClient.waitForBackgroundJavaScriptStartingBefore(200);
webClient.waitForBackgroundJavaScript(20000);
//do stuff on page ex: myPage.getElementById("main")
//myPage.asXml() <- tags and elements
System.out.println(myPage.asText());
}
代码示例来源:origin: net.wetheinter/gwt-user
try {
Page page = webClient.getPage(url);
webClient.waitForBackgroundJavaScriptStartingBefore(2000);
if (treeLogger.isLoggable(TreeLogger.SPAM)) {
treeLogger.log(TreeLogger.SPAM, "getPage returned "
代码示例来源:origin: com.vaadin.external.gwt/gwt-user
try {
Page page = webClient.getPage(url);
webClient.waitForBackgroundJavaScriptStartingBefore(2000);
if (treeLogger.isLoggable(TreeLogger.SPAM)) {
treeLogger.log(TreeLogger.SPAM, "getPage returned "
内容来源于网络,如有侵权,请联系作者删除!