/** * Switch to the inner frame (last child frame in given sequence) */ public WebDriver innerFrame(String... frames) { delegate.defaultContent(); for (String frame : frames) { try { String selector = String.format("frame#%1$s,frame[name=%1$s],iframe#%1$s,iframe[name=%1$s]", frame); Wait().until(frameToBeAvailableAndSwitchToIt_fixed(By.cssSelector(selector))); } catch (NoSuchElementException | TimeoutException e) { throw new NoSuchFrameException("No frame found with id/name = " + frame, e); } } return webDriver; }
private boolean checkIfGptSlotHasCreativeContent(WebElement element, String hopAdType) { String slotName = element.getAttribute("id").replace("wikia_gpt", ADS_IFRAME); String iframeSelector = "iframe[id*='" + slotName + "_0']"; String adTypeScriptXpath = String.format("//script[contains(text(), \"%s\")]", hopAdType); WebElement iframe = element.findElement(By.cssSelector(iframeSelector)); driver.switchTo().frame(iframe); List<WebElement> adTypeScripts = driver.findElements(By.xpath(adTypeScriptXpath)); driver.switchTo().defaultContent(); return !adTypeScripts.isEmpty(); }
private <T> T withinIframe(Callable<T> callable) throws Exception { try { driver.waitUntilElementIsLocated(GADGET_VIEW_IFRAME); driver.switchTo().frame(driver.findElement(GADGET_VIEW_IFRAME)); return callable.call(); } finally { driver.switchTo().defaultContent(); } } }
public boolean hasError() { try { getDriver().switchTo().frame("iframe"); List<WebElement> errors = getDriver().findElementsWithoutWaiting(By.className("less-error-message")); return !errors.isEmpty(); } finally { getDriver().switchTo().defaultContent(); } } }
@Override protected String getElementCSSValue(final By locator, String attribute) { try { getDriver().switchTo().frame("iframe"); WebElement element = getDriver().findElement(locator); return element.getCssValue(attribute); } finally { getDriver().switchTo().defaultContent(); } }
@Override public void switchToDefaultFrame() { driver.switchTo().defaultContent(); } }
public <T> T frameScope(Supplier<T> frameScopedSupplier) { try { webDriver.switchTo().frame(frameElement); return frameScopedSupplier.get(); } finally { webDriver.switchTo().defaultContent(); } } }
protected String getSlotImageAd(WebElement slot) { WebElement iframeWithAd = slot.findElement(By.cssSelector("div > iframe:not([id*='hidden'])")); driver.switchTo().frame(iframeWithAd); String imageAd = driver.findElement(By.cssSelector("img")).getAttribute("src"); driver.switchTo().defaultContent(); return imageAd; }
public void typeCaption(String text) { waitForDialogVisible(); wait.forElementVisible(captionEditArea); captionEditArea.sendKeys(text); Log.log("typeCaption", "Typed " + text + " in caption area", true); driver.switchTo().defaultContent(); }
public void submitQuote() { driver.switchTo().defaultContent(); scrollAndClick(driver.findElement(firstMessageWrapperBy).findElement(replyButtonBy)); wait.forElementNotPresent(By.cssSelector(".new-reply.loading")); Log.log("submitQuote", "message quote submitted", true); }
public void typeInContent(String content) { wait.forElementVisible(iFrame); driver.switchTo().frame(iFrame); wait.forElementVisible(bodyContent); bodyContent.sendKeys(content); Log.log("typeInContent", "content " + bodyContent.getText() + " - type into article body", true, driver ); driver.switchTo().defaultContent(); }
public String getCommentText() { driver.switchTo().frame("wysiwygTextarea_ifr"); RichEditorForm richEditorForm = pageBinder.bind(RichEditorForm.class); String text = richEditorForm.tinyMceElement.getText(); driver.switchTo().defaultContent(); return text; }
private boolean frameContains(String locator, String text) { WebElement el = finder.find(locator); driver.switchTo().frame(el); LOG.info(String.format("Searching for text from frame '%s'.", locator)); boolean found = textIsPresent(text); driver.switchTo().defaultContent(); return found; }
private void preventTheEvil() { // get out of any IFrame webDriver.switchTo().defaultContent(); // just make it WOOOORK finder.find(body()).javascript().execute("window.onbeforeunload=null;"); }
/** * Switches to default frame and puts the frame on FrameSwitcher's stack. */ @Override public WebDriver defaultContent() { frameSwitcher.putDefaultFramePathOnStack(); return targetLocator.defaultContent(); }
/** * Closes the Gadget view and returns the WebDriver context back to the default content * Which is usually the Dashboard content. */ public void close() { driver.switchTo().defaultContent(); }
protected void switchToFrame(String frameNameOrId) { if (frameNameOrId == null) { driver.switchTo().defaultContent(); } else { try { driver.switchTo().frame(frameNameOrId); } catch (NoSuchFrameException exception) { handleNoSuchFrameException(exception); } } }
public String getContentWithinIframe(By selector, Function<PageElement, String> contentExtractor) { String frameName = iframe.getAttribute("name"); driver.switchTo().frame(frameName); PageElement content = pageElementFinder.find(selector); waitUntilTrue(content.timed().isVisible()); String value = contentExtractor.apply(content); driver.switchTo().defaultContent(); return value; } }
public void insertSymbol(String symbol) { try { driver.switchTo().frame(INSERT_SYMBOL_FRAME_ID); PageElement pageElement = pageElementFinder.find(By.linkText(symbol)); pageElement.click(); driver.switchTo().defaultContent(); waitUntilHidden(); } finally { driver.switchTo().defaultContent(); } } }
@Override public WebDriver defaultContent() { return delegate.defaultContent(); }