public Object transform(final Object obj) { if (obj instanceof BaseFrame) { return ((BaseFrame) obj).getEnclosedWindow(); } return ((FrameWindow) obj).getFrameElement().getEnclosedWindow(); } }
/** * Returns the (i)frame in which the window is contained. * @return <code>null</code> for a top level window */ public Object jsxGet_frameElement() { final WebWindow window = getWebWindow(); if (window instanceof FrameWindow) { return ((FrameWindow) window).getFrameElement().getScriptObject(); } return null; }
/** * Returns the (i)frame in which the window is contained. * @return <code>null</code> for a top level window */ public Object jsxGet_frameElement() { final WebWindow window = getWebWindow(); if (window instanceof FrameWindow) { return ((FrameWindow) window).getFrameElement().getScriptObject(); } return null; }
/** * Returns the (i)frame in which the window is contained. * @return <code>null</code> for a top level window */ public Object jsxGet_frameElement() { final WebWindow window = getWebWindow(); if (window instanceof FrameWindow) { return ((FrameWindow) window).getFrameElement().getScriptObject(); } return null; }
public Object transform(final Object obj) { if (obj instanceof BaseFrame) { return ((BaseFrame) obj).getEnclosedWindow(); } return ((FrameWindow) obj).getFrameElement().getEnclosedWindow(); } }
public Object transform(final Object obj) { if (obj instanceof BaseFrame) { return ((BaseFrame) obj).getEnclosedWindow(); } return ((FrameWindow) obj).getFrameElement().getEnclosedWindow(); } }
HtmlPage page = client.getPage("http://example.com/"); List<FrameWindow> frames = page.getFrames(); for (FrameWindow frame : frames) { if (frame.getFrameElement().getId().equals("frameContent")) { page = (HtmlPage) frame.getEnclosedPage(); } }
@Override protected Scriptable getScriptableForElement(final Object obj) { final WebWindow window; if (obj instanceof BaseFrameElement) { window = ((BaseFrameElement) obj).getEnclosedWindow(); } else { window = ((FrameWindow) obj).getFrameElement().getEnclosedWindow(); } return window.getScriptableObject(); }
/** * Returns the (i)frame in which the window is contained. * @return {@code null} for a top level window */ @JsxGetter public Object getFrameElement() { final WebWindow window = getWebWindow(); if (window instanceof FrameWindow) { return ((FrameWindow) window).getFrameElement().getScriptableObject(); } return null; }
/** * Returns the (i)frame in which the window is contained. * @return {@code null} for a top level window */ @JsxGetter public Object getFrameElement() { final WebWindow window = getWebWindow(); if (window instanceof FrameWindow) { return ((FrameWindow) window).getFrameElement().getScriptableObject(); } return null; }
@Override protected Scriptable getScriptableForElement(final Object obj) { final WebWindow window; if (obj instanceof BaseFrameElement) { window = ((BaseFrameElement) obj).getEnclosedWindow(); } else { window = ((FrameWindow) obj).getFrameElement().getEnclosedWindow(); } return window.getScriptableObject(); }
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); }
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); } }
/** * {@inheritDoc} */ @Override public void setEnclosedPage(final Page page) { super.setEnclosedPage(page); // we have updated a frame window by javascript write(); // so we have to disable future updates during initialization // see com.gargoylesoftware.htmlunit.html.HtmlPage.loadFrames() final WebResponse webResponse = page.getWebResponse(); if (webResponse instanceof StringWebResponse) { final StringWebResponse response = (StringWebResponse) webResponse; if (response.isFromJavascript()) { final BaseFrameElement frame = getFrameElement(); frame.setContentLoaded(); } } }
/** * {@inheritDoc} */ @Override public void setEnclosedPage(final Page page) { super.setEnclosedPage(page); // we have updated a frame window by javascript write(); // so we have to disable future updates during initialization // see com.gargoylesoftware.htmlunit.html.HtmlPage.loadFrames() final WebResponse webResponse = page.getWebResponse(); if (webResponse instanceof StringWebResponse) { final StringWebResponse response = (StringWebResponse) webResponse; if (response.isFromJavascript()) { final BaseFrameElement frame = getFrameElement(); frame.setContentLoaded(); } } }
/** * Loads the content of the contained frames. This is done after the page is completely loaded, to allow script * contained in the frames to reference elements from the page located after the closing </frame> tag. * @throws FailingHttpStatusCodeException if the server returns a failing status code AND the property * {@link WebClient#setThrowExceptionOnFailingStatusCode(boolean)} is set to <tt>true</tt> */ void loadFrames() throws FailingHttpStatusCodeException { for (final FrameWindow w : getFrames()) { final BaseFrame frame = w.getFrameElement(); // test if the frame should really be loaded: // if a script has already changed its content, it should be skipped // use == and not equals(...) to identify initial content (versus URL set to "about:blank") if (frame.getEnclosedPage().getWebResponse().getRequestSettings().getUrl() == WebClient.URL_ABOUT_BLANK) { frame.loadInnerPage(); } } }
/** * Returns the current selection. * @return the current selection */ @JsxFunction public Selection getSelection() { final WebWindow webWindow = getWebWindow(); // return null if the window is in a frame that is not displayed if (webWindow instanceof FrameWindow) { final FrameWindow frameWindow = (FrameWindow) webWindow; if (getBrowserVersion().hasFeature(JS_WINDOW_SELECTION_NULL_IF_INVISIBLE) && !frameWindow.getFrameElement().isDisplayed()) { return null; } } return getSelectionImpl(); }
/** * Returns the current selection. * @return the current selection */ @JsxFunction public Selection getSelection() { final WebWindow webWindow = getWebWindow(); // return null if the window is in a frame that is not displayed if (webWindow instanceof FrameWindow) { final FrameWindow frameWindow = (FrameWindow) webWindow; if (getBrowserVersion().hasFeature(JS_WINDOW_SELECTION_NULL_IF_INVISIBLE) && !frameWindow.getFrameElement().isDisplayed()) { return null; } } return getSelectionImpl(); }
/** * Loads the content of the contained frames. This is done after the page is completely loaded, to allow script * contained in the frames to reference elements from the page located after the closing </frame> tag. * @throws FailingHttpStatusCodeException if the server returns a failing status code AND the property * {@link WebClient#setThrowExceptionOnFailingStatusCode(boolean)} is set to {@code true} */ void loadFrames() throws FailingHttpStatusCodeException { for (final FrameWindow w : getFrames()) { final BaseFrameElement frame = w.getFrameElement(); // test if the frame should really be loaded: // if a script has already changed its content, it should be skipped // use == and not equals(...) to identify initial content (versus URL set to "about:blank") if (frame.getEnclosedWindow() != null && WebClient.URL_ABOUT_BLANK == frame.getEnclosedPage().getUrl() && !frame.isContentLoaded()) { frame.loadInnerPage(); } } }
/** * Loads the content of the contained frames. This is done after the page is completely loaded, to allow script * contained in the frames to reference elements from the page located after the closing </frame> tag. * @throws FailingHttpStatusCodeException if the server returns a failing status code AND the property * {@link WebClient#setThrowExceptionOnFailingStatusCode(boolean)} is set to <tt>true</tt> */ void loadFrames() throws FailingHttpStatusCodeException { for (final FrameWindow w : getFrames()) { final BaseFrame frame = w.getFrameElement(); // test if the frame should really be loaded: // if a script has already changed its content, it should be skipped // use == and not equals(...) to identify initial content (versus URL set to "about:blank") if (frame.getEnclosedPage().getWebResponse().getRequestSettings().getUrl() == WebClient.URL_ABOUT_BLANK) { frame.loadInnerPage(); } } }