/** * Gives a basic representation for debugging purposes. * @return a basic representation */ @Override public String toString() { return "FrameWindow[name=\"" + getName() + "\"]"; }
/** * Gives a basic representation for debugging purposes. * @return a basic representation */ @Override public String toString() { return "FrameWindow[name=\"" + getName() + "\"]"; } }
/** * Gives a basic representation for debugging purposes. * @return a basic representation */ @Override public String toString() { return "FrameWindow[name=\"" + getName() + "\"]"; }
/** * Gives a basic representation for debugging purposes. * @return a basic representation */ @Override public String toString() { return "FrameWindow[name=\"" + getName() + "\"]"; } }
/** * Gives a basic representation for debugging purposes. * @return a basic representation */ @Override public String toString() { return "FrameWindow[name=\"" + getName() + "\"]"; } }
/** * 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); }
/** * 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; }
window = frameWindow; break; } else if (frameName.equals(frameWindow.getName())) { window = frameWindow; break;
@Override public WebDriver frame(final String nameOrId) { Page page = lastPage(); if (page instanceof HtmlPage) { // First check for a frame with the matching name. for (final FrameWindow frameWindow : ((HtmlPage) page).getFrames()) { if (frameWindow.getName().equals(nameOrId)) { currentWindow = frameWindow; return HtmlUnitDriver.this; } } } // Next, check for a frame with a matching ID. For simplicity, assume the ID is unique. // Users can still switch to frames with non-unique IDs using a WebElement switch: // WebElement frameElement = driver.findElement(By.xpath("//frame[@id=\"foo\"]")); // driver.switchTo().frame(frameElement); try { HtmlUnitWebElement element = (HtmlUnitWebElement) HtmlUnitDriver.this.findElementById(nameOrId); DomElement domElement = element.getElement(); if (domElement instanceof BaseFrameElement) { currentWindow = ((BaseFrameElement) domElement).getEnclosedWindow(); return HtmlUnitDriver.this; } } catch (NoSuchElementException ignored) { } throw new NoSuchFrameException("Unable to locate frame with name or ID: " + nameOrId); }