@Override public WebDriver frame(int index) { Page page = lastPage(); if (page instanceof HtmlPage) { try { currentWindow = ((HtmlPage) page).getFrames().get(index); } catch (IndexOutOfBoundsException ignored) { throw new NoSuchFrameException("Cannot find frame: " + index); } } return HtmlUnitDriver.this; }
/** * Returns the first frame contained in this page with the specified name. * @param name the name to search for * @return the first frame found * @exception ElementNotFoundException If no frame exist in this page with the specified name. */ public FrameWindow getFrameByName(final String name) throws ElementNotFoundException { for (final FrameWindow frame : getFrames()) { if (frame.getName().equals(name)) { return frame; } } throw new ElementNotFoundException("frame or iframe", "name", name); }
/** * Returns the first frame contained in this page with the specified name. * @param name the name to search for * @return the first frame found * @exception ElementNotFoundException If no frame exist in this page with the specified name. */ public FrameWindow getFrameByName(final String name) throws ElementNotFoundException { for (final FrameWindow frame : getFrames()) { if (frame.getName().equals(name)) { return frame; } } throw new ElementNotFoundException("frame or iframe", "name", name); }
/** * Returns the first frame contained in this page with the specified name. * @param name the name to search for * @return the first frame found * @exception ElementNotFoundException If no frame exist in this page with the specified name. */ public FrameWindow getFrameByName(final String name) throws ElementNotFoundException { for (final FrameWindow frame : getFrames()) { if (frame.getName().equals(name)) { return frame; } } throw new ElementNotFoundException("frame or iframe", "name", name); }
/** * Returns the first frame contained in this page with the specified name. * @param name the name to search for * @return the first frame found * @exception ElementNotFoundException If no frame exist in this page with the specified name. */ public FrameWindow getFrameByName(final String name) throws ElementNotFoundException { for (final FrameWindow frame : getFrames()) { if (frame.getName().equals(name)) { return frame; } } throw new ElementNotFoundException("frame or iframe", "name", name); }
/** * Returns the first frame contained in this page with the specified name. * @param name the name to search for * @return the first frame found * @exception ElementNotFoundException If no frame exist in this page with the specified name. */ public FrameWindow getFrameByName(final String name) throws ElementNotFoundException { for (final FrameWindow frame : getFrames()) { if (frame.getName().equals(name)) { return frame; } } throw new ElementNotFoundException("frame or iframe", "name", name); }
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(); } }
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); } }
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; }
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); }
/** * Return the given frame in the current conversation. * * @param frameNameOrId Frame name or ID. * @return The frame found or null. */ private WebWindow getFrame(String frameNameOrId) { // First try ID for (FrameWindow frame : getCurrentPage().getFrames()) { if (frameNameOrId.equals(frame.getFrameElement().getId())) { return frame; } } // Now try with Name for (FrameWindow frame : getCurrentPage().getFrames()) { if (frameNameOrId.equals(frame.getName())) { return frame; } } // Nothing was found. return null; }
/** * Deregister frames that are no longer in use. */ public void deregisterFramesIfNeeded() { for (final WebWindow window : getFrames()) { getWebClient().deregisterWebWindow(window); final Page page = window.getEnclosedPage(); if (page != null && page.isHtmlPage()) { // seems quite silly, but for instance if the src attribute of an iframe is not // set, the error only occurs when leaving the page ((HtmlPage) page).deregisterFramesIfNeeded(); } } }
/** * Deregister frames that are no longer in use. */ public void deregisterFramesIfNeeded() { for (final WebWindow window : getFrames()) { getWebClient().deregisterWebWindow(window); final Page page = window.getEnclosedPage(); if (page != null && page.isHtmlPage()) { // seems quite silly, but for instance if the src attribute of an iframe is not // set, the error only occurs when leaving the page ((HtmlPage) page).deregisterFramesIfNeeded(); } } }
/** * Deregister frames that are no longer in use. */ public void deregisterFramesIfNeeded() { for (final WebWindow window : getFrames()) { getWebClient().deregisterWebWindow(window); if (window.getEnclosedPage() instanceof HtmlPage) { final HtmlPage page = (HtmlPage) window.getEnclosedPage(); if (page != null) { // seems quite silly, but for instance if the src attribute of an iframe is not // set, the error only occurs when leaving the page page.deregisterFramesIfNeeded(); } } } }
/** * Deregister frames that are no longer in use. */ public void deregisterFramesIfNeeded() { for (final WebWindow window : getFrames()) { getWebClient().deregisterWebWindow(window); if (window.getEnclosedPage() instanceof HtmlPage) { final HtmlPage page = (HtmlPage) window.getEnclosedPage(); if (page != null) { // seems quite silly, but for instance if the src attribute of an iframe is not // set, the error only occurs when leaving the page page.deregisterFramesIfNeeded(); } } } }
/** * Deregister frames that are no longer in use. */ public void deregisterFramesIfNeeded() { for (final WebWindow window : getFrames()) { getWebClient().deregisterWebWindow(window); if (window.getEnclosedPage() instanceof HtmlPage) { final HtmlPage page = (HtmlPage) window.getEnclosedPage(); if (page != null) { // seems quite silly, but for instance if the src attribute of an iframe is not // set, the error only occurs when leaving the page page.deregisterFramesIfNeeded(); } } } }
/** * 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(); } } }
/** * 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(); } } }
/** * 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 {@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(); } } }