本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.getCurrentWindow()
方法的一些代码示例,展示了WebClient.getCurrentWindow()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.getCurrentWindow()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:getCurrentWindow
[英]Returns the "current" window for this client. This window (or its top window) will be used when getPage(...) is called without specifying a window.
[中]返回此客户端的“当前”窗口。此窗口(或其顶部窗口)将在getPage(…)时使用在不指定窗口的情况下调用。
代码示例来源:origin: org.seleniumhq.selenium/selenium-htmlunit-driver
protected void pickWindow() {
// TODO(simon): HtmlUnit tries to track the current window as the frontmost. We don't
if (currentWindow == null) {
currentWindow = getWebClient().getCurrentWindow();
}
}
代码示例来源:origin: stackoverflow.com
URL url = new URL("http://www.example.com");
InputStream is = this.getClass().getClassLoader().getResourceAsStream("myPageXmlFile.xml");
String xmlPageString = IOUtils.toString(is);
StringWebResponse response = new StringWebResponse(xmlPageString, url);
WebClient client = WebClientConnector.createWebClient(false); // helper method for creating a WebClient instance
HtmlPage page = HTMLParser.parseXHtml(response, client.getCurrentWindow());
代码示例来源:origin: org.jboss.jsfunit/jboss-jsfunit-core
/**
* Get the latest content page returned from the server. This page may
* have been changed by javascript or direct manipulation of the DOM.
*
* @return The Page.
*/
public Page getContentPage()
{
return webClient.getCurrentWindow().getEnclosedPage();
}
代码示例来源:origin: net.sourceforge.jwebunit/jwebunit-htmlunit-plugin
/**
* Close the current window.
*/
@Override
public void closeWindow() {
if (win != null) {
((TopLevelWindow) win.getTopWindow()).close();
win = wc.getCurrentWindow();
form = null;
}
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Open a new window with the specified name. If the URL is non-null then attempt to load
* a page from that location and put it in the new window.
*
* @param url the URL to load content from or null if no content is to be loaded
* @param windowName the name of the new window
* @return the new window
*/
public WebWindow openWindow(final URL url, final String windowName) {
WebAssert.notNull("windowName", windowName);
return openWindow(url, windowName, getCurrentWindow());
}
代码示例来源:origin: net.sourceforge.jwebunit/jwebunit-htmlunit-plugin
/**
* Get the last WebResponse from HtmlUnit.
*/
public WebResponse getWebResponse() {
return wc.getCurrentWindow().getEnclosedPage().getWebResponse();
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Open a new window with the specified name. If the URL is non-null then attempt to load
* a page from that location and put it in the new window.
*
* @param url the URL to load content from or null if no content is to be loaded
* @param windowName the name of the new window
* @return the new window
*/
public WebWindow openWindow(final URL url, final String windowName) {
WebAssert.notNull("windowName", windowName);
return openWindow(url, windowName, getCurrentWindow());
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Open a new window with the specified name. If the URL is non-null then attempt to load
* a page from that location and put it in the new window.
*
* @param url the URL to load content from or null if no content is to be loaded
* @param windowName the name of the new window
* @return the new window
*/
public WebWindow openWindow(final URL url, final String windowName) {
WebAssert.notNull("windowName", windowName);
return openWindow(url, windowName, getCurrentWindow());
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Open a new window with the specified name. If the URL is non-null then attempt to load
* a page from that location and put it in the new window.
*
* @param url the URL to load content from or null if no content is to be loaded
* @param windowName the name of the new window
* @return the new window
*/
public WebWindow openWindow(final URL url, final String windowName) {
WebAssert.notNull("windowName", windowName);
return openWindow(url, windowName, getCurrentWindow());
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
/**
* Open a new window with the specified name. If the URL is non-null then attempt to load
* a page from that location and put it in the new window.
*
* @param url the URL to load content from or null if no content is to be loaded
* @param windowName the name of the new window
* @return the new window
*/
public WebWindow openWindow(final URL url, final String windowName) {
WebAssert.notNull("windowName", windowName);
return openWindow(url, windowName, getCurrentWindow());
}
代码示例来源:origin: net.sourceforge.jwebunit/jwebunit-htmlunit-plugin
@Override
public InputStream getInputStream() {
try {
return wc.getCurrentWindow().getEnclosedPage().getWebResponse()
.getContentAsStream();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-htmlunit
public WebDriver frame(int frameIndex) {
HtmlPage page = (HtmlPage) webClient.getCurrentWindow().getEnclosedPage();
try {
currentWindow = page.getFrames().get(frameIndex);
} catch (IndexOutOfBoundsException e) {
throw new NoSuchFrameException("Cannot find frame: " + frameIndex);
}
return HtmlUnitDriver.this;
}
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-htmlunit
protected void pickWindow() {
currentWindow = webClient.getCurrentWindow();
Page page = webClient.getCurrentWindow().getEnclosedPage();
if (page == null)
return;
if (!(page instanceof HtmlPage))
return;
if (((HtmlPage) page).getFrames().size() > 0) {
FrameWindow frame = ((HtmlPage) page).getFrames().get(0);
if (!(frame.getFrameElement() instanceof HtmlInlineFrame))
switchTo().frame(0);
}
}
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-htmlunit
public String getWindowHandle() {
WebWindow window = webClient.getCurrentWindow();
if (window.getName() == null || "".equals(window.getName())) {
nameWindow(window);
}
return window.getName();
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Convenient method to load a URL into the current top WebWindow as it would be done
* by {@link #getPage(WebWindow, WebRequestSettings)}.
* @param url the URL of the new content
* @param <P> the page type
* @return the new page
* @throws FailingHttpStatusCodeException if the server returns a failing status code AND the property
* {@link #setThrowExceptionOnFailingStatusCode(boolean)} is set to true.
* @throws IOException if an IO problem occurs
*/
@SuppressWarnings("unchecked")
public <P extends Page> P getPage(final URL url) throws IOException, FailingHttpStatusCodeException {
return (P) getPage(getCurrentWindow().getTopWindow(), new WebRequestSettings(url));
}
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-htmlunit
protected WebDriver findActiveWindow() {
WebWindow window = webClient.getCurrentWindow();
HtmlPage page = (HtmlPage) window.getEnclosedPage();
if (page != null && page.getFrames().size() > 0) {
FrameWindow frame = page.getFrames().get(0);
if (!(frame.getFrameElement() instanceof HtmlInlineFrame))
return new HtmlUnitDriver(isJavascriptEnabled(), frame);
}
if (currentWindow != null && currentWindow.equals(window))
return this;
return new HtmlUnitDriver(isJavascriptEnabled(), window);
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
/**
* Sets the object as active without setting focus to the object.
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536738.aspx">MSDN documentation</a>
*/
public void jsxFunction_setActive() {
final Window window = getWindow();
final HTMLDocument document = window.jsxGet_document();
document.setActiveElement(this);
if (window.getWebWindow() == window.getWebWindow().getWebClient().getCurrentWindow()) {
final HtmlElement element = getDomNodeOrDie();
((HtmlPage) element.getPage()).setFocusedElement(element);
}
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Sets the object as active without setting focus to the object.
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536738.aspx">MSDN documentation</a>
*/
public void jsxFunction_setActive() {
final Window window = getWindow();
final HTMLDocument document = window.jsxGet_document();
document.setActiveElement(this);
if (window.getWebWindow() == window.getWebWindow().getWebClient().getCurrentWindow()) {
final HtmlElement element = getDomNodeOrDie();
((HtmlPage) element.getPage()).setFocusedElement(element);
}
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Sets the object as active without setting focus to the object.
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536738.aspx">MSDN documentation</a>
*/
public void jsxFunction_setActive() {
final Window window = getWindow();
final HTMLDocument document = window.jsxGet_document();
document.setActiveElement(this);
if (window.getWebWindow() == window.getWebWindow().getWebClient().getCurrentWindow()) {
final HtmlElement element = getDomNodeOrDie();
((HtmlPage) element.getPage()).setFocusedElement(element);
}
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Sets the object as active without setting focus to the object.
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536738.aspx">MSDN documentation</a>
*/
@JsxFunction(IE)
public void setActive() {
final Window window = getWindow();
final HTMLDocument document = (HTMLDocument) window.getDocument();
document.setActiveElement(this);
if (window.getWebWindow() == window.getWebWindow().getWebClient().getCurrentWindow()) {
final HtmlElement element = getDomNodeOrDie();
((HtmlPage) element.getPage()).setFocusedElement(element);
}
}
内容来源于网络,如有侵权,请联系作者删除!