private void switchToDefaultContentOfWindow(WebWindow window) { Page page = window.getEnclosedPage(); if (page instanceof HtmlPage) { currentWindow = window; } }
LoadJob(final WebRequest request, final WebWindow requestingWindow, final String target, final URL urlWithOnlyHashChange) { request_ = request; requestingWindow_ = requestingWindow; target_ = target; response_ = null; urlWithOnlyHashChange_ = urlWithOnlyHashChange; originalPage_ = new WeakReference<>(requestingWindow.getEnclosedPage()); }
LoadJob(final WebRequest request, final WebWindow requestingWindow, final String target, final WebResponse response) { request_ = request; requestingWindow_ = requestingWindow; target_ = target; response_ = response; urlWithOnlyHashChange_ = null; originalPage_ = new WeakReference<>(requestingWindow.getEnclosedPage()); }
/** * Return the page title of the current response page, encoded as specified by the current * {@link net.sourceforge.jwebunit.util.TestContext}. */ public String getCurrentPageTitle() { if (win.getEnclosedPage() instanceof HtmlPage) { return ((HtmlPage) win.getEnclosedPage()).getTitleText(); } return ""; }
private HtmlForm getForm(String nameOrID) { try { return (HtmlForm) ((HtmlPage) win.getEnclosedPage()) .getHtmlElementById(nameOrID); } catch (ElementNotFoundException e) { } try { return ((HtmlPage) win.getEnclosedPage()).getFormByName(nameOrID); } catch (ElementNotFoundException e) { } return null; }
private HtmlAnchor getLinkWithText(String linkText, int index) { List<HtmlAnchor> lnks = ((HtmlPage) win.getEnclosedPage()).getAnchors(); int count = 0; for (HtmlAnchor lnk : lnks) { if ((lnk.asText().indexOf(linkText) >= 0) && (count++ == index)) { return lnk; } } return null; }
private HtmlAnchor getLinkWithExactText(String linkText, int index) { List<HtmlAnchor> lnks = ((HtmlPage) win.getEnclosedPage()).getAnchors(); int count = 0; for (HtmlAnchor lnk : lnks) { if ((lnk.asText().equals(linkText)) && (count++ == index)) { return lnk; } } return null; }
/** * Initializes the object. * * @param window the window that this location belongs to */ public void initialize(final Window window) { window_ = window; if (window_ != null && window_.getWebWindow().getEnclosedPage() != null) { setHash(window_.getWebWindow().getEnclosedPage().getUrl().getRef()); } }
/** * Indicates if the action still needs to be executed. * @return {@code true} if the action needs to be executed */ public boolean isStillAlive() { final Page owningPage = getOwningPage(); return owningPage != null && owningPage == owningPage.getEnclosingWindow().getEnclosedPage(); }
/** * Returns the live collection of frames contained by this window. * @return the live collection of frames contained by this window */ private HTMLCollection getFrames() { final HtmlPage page = (HtmlPage) getWebWindow().getEnclosedPage(); return new HTMLCollectionFrames(page); }
/** * Returns this location's current URL. * @return this location's current URL */ private URL getUrl() { return window_.getWebWindow().getEnclosedPage().getUrl(); }
/** * Get the last WebResponse from HtmlUnit. */ public WebResponse getWebResponse() { return wc.getCurrentWindow().getEnclosedPage().getWebResponse(); }
/** * Initializes the object. * * @param window the window that this location belongs to */ public void initialize(final Window window) { window_ = window; if (window_ != null && window_.getWebWindow().getEnclosedPage() != null) { hash_ = window_.getWebWindow().getEnclosedPage().getWebResponse().getRequestSettings().getUrl().getRef(); } }
@Override public InputStream getInputStream() { try { return wc.getCurrentWindow().getEnclosedPage().getWebResponse() .getContentAsStream(); } catch (IOException e) { throw new RuntimeException(e); } }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br/> * * Removes a window from the list of available windows. * * @param webWindow the window to remove */ public void deregisterWebWindow(final WebWindow webWindow) { WebAssert.notNull("webWindow", webWindow); windows_.remove(webWindow); fireWindowClosed(new WebWindowEvent(webWindow, WebWindowEvent.CLOSE, webWindow.getEnclosedPage(), null)); }
private static XmlPage createParserErrorXmlPage(final String message, final WebWindow webWindow) throws IOException { final String xml = "<parsererror xmlns=\"http://www.mozilla.org/newlayout/xml/parsererror.xml\">\n" + message + "\n" + "<sourcetext></sourcetext>\n" + "</parsererror>"; final WebResponse webResponse = new StringWebResponse(xml, webWindow.getEnclosedPage().getUrl()); return new XmlPage(webResponse, webWindow, false); }
/** * Sets the text from the status line. * @param message the status line text */ public void jsxSet_status(final String message) { status_ = message; final StatusHandler statusHandler = webWindow_.getWebClient().getStatusHandler(); if (statusHandler != null) { statusHandler.statusMessageChanged(webWindow_.getEnclosedPage(), message); } }
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); }
/** * Sets the text from the status line. * @param message the status line text */ @JsxSetter public void setStatus(final String message) { status_ = message; final StatusHandler statusHandler = webWindow_.getWebClient().getStatusHandler(); if (statusHandler != null) { statusHandler.statusMessageChanged(webWindow_.getEnclosedPage(), message); } }
/** * JavaScript constructor. */ @JsxConstructor({CHROME, FF, EDGE}) public void jsConstructor() { final SgmlPage page = (SgmlPage) getWindow().getWebWindow().getEnclosedPage(); final DomElement fake = HTMLParser.getFactory(HtmlImage.TAG_NAME).createElement(page, HtmlImage.TAG_NAME, new AttributesImpl()); setDomNode(fake); }