本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.getTopLevelWindows()
方法的一些代码示例,展示了WebClient.getTopLevelWindows()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.getTopLevelWindows()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:getTopLevelWindows
[英]Returns an immutable list of open top level windows. This is a snapshot; future changes are not reflected by this list.
The list is ordered by age, the oldest one first.
[中]返回打开的顶层窗口的不可变列表。这是一张快照;此列表不反映未来的变化。
这份名单是按年龄排序的,最老的排在第一位。
代码示例来源:origin: org.seleniumhq.selenium/selenium-htmlunit-driver
@Override
public Set<String> getWindowHandles() {
final Set<String> allHandles = Sets.newHashSet();
for (final WebWindow window : getWebClient().getTopLevelWindows()) {
allHandles.add(String.valueOf(System.identityHashCode(window)));
}
return allHandles;
}
代码示例来源:origin: stackoverflow.com
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) {
// disable caching
webClient.getCache().setMaxSize(0);
// Get the first page
final HtmlPage page1 = webClient.getPage(url);
final HtmlForm form = page1.getFormByName(formName);
final HtmlTextInput taxCodeTextField = form.getInputByName(taxCodeTextFieldName);
HtmlCheckBoxInput checkboxInput = form.getInputByName(checkboxInputName);
taxCodeTextField.type(taxCode);
checkboxInput.click();
//wait a little
Thread.sleep(2000);
//get the main page
HtmlPage page2 = (HtmlPage) webClient.getTopLevelWindows().get(0).getEnclosedPage();
HtmlSubmitInput confirmButton = page2.getFormByName(formName).getInputByName(confirmButtonName);
final HtmlPage page3 = confirmButton.click();
System.out.println(page3.asText());
}
内容来源于网络,如有侵权,请联系作者删除!