Example usage for org.openqa.selenium.support.ui ExpectedConditions frameToBeAvailableAndSwitchToIt

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions frameToBeAvailableAndSwitchToIt

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui ExpectedConditions frameToBeAvailableAndSwitchToIt.

Prototype

public static ExpectedCondition<WebDriver> frameToBeAvailableAndSwitchToIt(final WebElement frameLocator) 

Source Link

Document

An expectation for checking whether the given frame is available to switch to.

Usage

From source file:com.seleniumtests.it.driver.support.pages.DriverTestPageNativeActions.java

License:Apache License

public void switchToFrameWithExpectedConditionsByIndex() {
    new WebDriverWait(driver, 5).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(0));
}

From source file:com.twiceagain.mywebdriver.generators.implementations.Yopmail.java

License:Open Source License

/**
 * Initialize with the provided username.
 *
 * @param user//w w w.j  av  a 2  s.c o  m
 */
@Override
public void init(String user) {
    wd.get("http://www.yopmail.com?" + user);

    // Wait for message frame to appear, and switch to it
    try {
        (new WebDriverWait(wd, maxWaitSeconds))
                .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(ifInbox));
    } catch (Exception ex) {
        LOG.warning(ex.getLocalizedMessage());
    }
    // wd now points to the inbox frame.
    // Wait for at least 1 message to appear
    try {
        (new WebDriverWait(wd, maxWaitSeconds))
                .until(ExpectedConditions.presenceOfElementLocated(By.xpath(xpDocuments)));
    } catch (Exception ex) {
        LOG.warning(ex.getLocalizedMessage());
    }
    super.preloadElements();

}

From source file:jscover.server.WebDriverJasmineTestBase.java

License:Open Source License

@Test
public void shouldRunJasmineTestAndStoreResult() throws IOException {
    File jsonFile = new File(getReportDir() + "/jscoverage.json");
    if (jsonFile.exists())
        jsonFile.delete();//from  w ww .j  a  v a  2 s . c o m
    webClient.get("http://localhost:8081/jscoverage.html?" + getTestUrl());

    String handle = webClient.getWindowHandle();
    new WebDriverWait(webClient, 1).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("browserIframe"));
    new WebDriverWait(webClient, 1)
            .until(ExpectedConditions.presenceOfElementLocated(By.className("duration")));
    new WebDriverWait(webClient, 1)
            .until(ExpectedConditions.textToBePresentInElement(By.className("duration"), "finished"));
    verifyJasmineTestsPassed();

    webClient.switchTo().window(handle);

    new WebDriverWait(webClient, 1).until(ExpectedConditions.elementToBeClickable(By.id("storeTab")));
    webClient.findElement(By.id("storeTab")).click();

    new WebDriverWait(webClient, 1).until(ExpectedConditions.elementToBeClickable(By.id("storeButton")));
    webClient.findElement(By.id("storeButton")).click();
    new WebDriverWait(webClient, 2)
            .until(ExpectedConditions.textToBePresentInElement(By.id("storeDiv"), "Coverage data stored at"));

    webClient.get(format("http://localhost:8081/%s/jscoverage.html", getReportDir()));
    verifyTotal(webClient, 100, 0, 100);
}

From source file:org.apache.syncope.fit.console.reference.ReportITCase.java

License:Apache License

@Test
public void readReportlet() {
    seleniumDriver.findElement(By.xpath("//img[@alt=\"Reports\"]")).click();

    wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='tabs']")));
    seleniumDriver.findElement(By.xpath("//table/tbody/tr/td[8]/div/span[13]/a")).click();

    wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//iframe")));
    seleniumDriver.switchTo().frame(0);/*from w w  w .j  a  va2s. c  om*/

    wait.until(ExpectedConditions
            .presenceOfElementLocated(By.xpath("//div[2]/form/div[2]/div/div/span/div/div/div/span")));

    seleniumDriver.findElement(By.xpath("//div[2]/form/div[2]/div/div/span/div/div[5]/div[2]/div/div[2]/div/a"))
            .click();
    wait.until(ExpectedConditions.presenceOfElementLocated(
            By.xpath("//div[2]/form/div[2]/div/div/span/div/div[5]/div[2]/div/div/select")));

    Select select = new Select(seleniumDriver
            .findElement(By.xpath("//div[2]/form/div[2]/div/div/span/div/div[5]/div[2]/div/div/select")));
    select.selectByVisibleText("testUserReportlet");

    seleniumDriver.findElement(By.xpath("//div[2]/form/div[2]/div/div/span/div/div[5]/div[2]/div[2]/div[2]/a"))
            .click();

    seleniumDriver.switchTo().defaultContent();
    wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(
            By.xpath("//div[7]/form/div/div[2]/div/div/div/div[2]/div/div/iframe")));

    wait.until(ExpectedConditions.presenceOfElementLocated(By.name("reportletClass:dropDownChoiceField")));

    select = new Select(seleniumDriver.findElement(By.name("reportletClass:dropDownChoiceField")));
    select.selectByVisibleText(StaticReportletConf.class.getName());

    seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/input")).click();

    seleniumDriver.switchTo().defaultContent();

    seleniumDriver.findElement(By.xpath("//a[@class='w_close']")).click();
}

From source file:org.eclipse.che.selenium.factory.CheckWelcomePanelOnCodenvyTest.java

License:Open Source License

private void checkWelcomePanel() {
    String expectedTextFragment = "Runbook\n"
            + "This article provides specific performance and security guidance for Codenvy on-premises installations based on our experience running";
    webDriverWait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("greetingFrame")));
    webDriverWait.until(// www.ja v  a  2s. com
            ExpectedConditions.textToBePresentInElementLocated(By.tagName("body"), expectedTextFragment));
}

From source file:org.eclipse.che.selenium.pageobject.Ide.java

License:Open Source License

public void switchFromDashboard() {
    new WebDriverWait(seleniumWebDriver, EXPECTED_MESS_IN_CONSOLE_SEC)
            .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("ide-application-iframe")));
}

From source file:org.jitsi.meet.test.EtherpadTest.java

License:Apache License

/**
 * Write some text and check on the other side, whether the text
 * is visible./*from w w  w.j a v  a2  s  . c o  m*/
 */
public void writeTextAndCheck() {
    if (!enabled) {
        return;
    }

    System.err.println("Start writeTextAndCheck.");

    WebDriver owner = ConferenceFixture.getOwner();
    try {

        WebDriverWait wait = new WebDriverWait(owner, 30);
        wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("etherpadIFrame")));

        wait = new WebDriverWait(owner, 30);
        wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.name("ace_outer")));

        wait = new WebDriverWait(owner, 30);
        wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.name("ace_inner")));

        String textToEnter = "SomeTestText";

        owner.findElement(By.id("innerdocbody")).sendKeys(textToEnter);

        TestUtils.waitMillis(2000);

        // now search and check the text
        String txt = owner.findElement(By.xpath("//span[contains(@class, 'author')]")).getText();

        assertEquals("Texts do not match", textToEnter, txt);
    } finally {
        owner.switchTo().defaultContent();
    }
}

From source file:org.jitsi.meet.test.EtherpadTests.java

License:Apache License

/**
 * Write some text and check on the other side, whether the text
 * is visible.//from   w  w w  .  j  av a  2s.  c om
 */
public void writeTextAndCheck() {
    try {
        WebDriverWait wait = new WebDriverWait(ConferenceFixture.getOwner(), 30);
        wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.tagName("iframe")));

        wait = new WebDriverWait(ConferenceFixture.getOwner(), 30);
        wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.name("ace_outer")));

        wait = new WebDriverWait(ConferenceFixture.getOwner(), 30);
        wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.name("ace_inner")));

        String textToEnter = "SomeTestText";

        ConferenceFixture.getOwner().findElement(By.id("innerdocbody")).sendKeys(textToEnter);

        TestUtils.waits(2000);

        // now search and check the text
        String txt = ConferenceFixture.getOwner().findElement(By.xpath("//span[contains(@class, 'author')]"))
                .getText();

        assertEquals("Texts do not match", textToEnter, txt);
    } finally {
        ConferenceFixture.getOwner().switchTo().defaultContent();
    }
}

From source file:org.jitsi.meet.test.SharedVideoTest.java

License:Apache License

/**
 * Start shared video./*from   w w  w .j a v  a 2s . co  m*/
 * @param url
 * @param title
 * @param checkSecondParticipantState whether second participant state
 *                                    needs to be checked
 */
private void startSharingVideoByUrlAndTitle(String url, String title, boolean checkSecondParticipantState) {
    WebDriver owner = ConferenceFixture.getOwner();
    MeetUIUtils.clickOnToolbarButton(owner, "toolbar_button_sharedvideo");

    TestUtils.waitForElementByXPath(owner, "//input[@name='sharedVideoUrl']", 5);

    //owner.findElement(
    //    By.xpath("//input[@name='sharedVideoUrl']")).sendKeys(url);
    // sendKeys is not working for FF, seems the input has size of 20
    // and only 21 chars goes in, the size is not visible in
    // web-development console
    MeetUIUtils.setAttribute(owner, owner.findElement(By.xpath("//input[@name='sharedVideoUrl']")), "value",
            url);

    currentVideoTitle = title;

    owner.findElement(By.name("jqi_state0_buttonspandatai18ndialogShareSharespan")).click();

    WebDriverWait wait = new WebDriverWait(owner, 30);
    wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("sharedVideoIFrame")));
    // make sure we are in meet, not in the frame
    owner.switchTo().defaultContent();

    assertEquals("Video not displayed:", true, owner.findElement(By.id("sharedVideoIFrame")).isDisplayed());

    if (checkSecondParticipantState) {
        // Now let's check the second participant state
        WebDriver secondParticipant = ConferenceFixture.getSecondParticipant();
        // make sure we are in meet, not in the frame
        secondParticipant.switchTo().defaultContent();

        assertEquals("Video not displayed:", true,
                secondParticipant.findElement(By.id("sharedVideoIFrame")).isDisplayed());
    }
}

From source file:org.jitsi.meet.test.web.WebParticipant.java

License:Apache License

/**
 * {@inheritDoc}/*from w  w w .  j  a v  a  2s  . c o  m*/
 */
@Override
public void doJoinConference(JitsiMeetUrl conferenceUrl) {
    // with chrome v52 we start getting error:
    // "Timed out receiving message from renderer" and
    // "Navigate timeout: cannot determine loading status"
    // seems its a bug or rare problem, maybe concerns async loading
    // of resources ...
    // https://bugs.chromium.org/p/chromedriver/issues/detail?id=402
    // even there is a TimeoutException the page is loaded correctly
    // and driver is operating, we just lower the page load timeout
    // default is 3 minutes and we log and skip this exception
    driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
    try {
        driver.get(conferenceUrl.toString());
    } catch (org.openqa.selenium.TimeoutException ex) {
        ex.printStackTrace();
        TestUtils.print(
                "TimeoutException while loading page, " + "will skip it and continue:" + ex.getMessage());
    }

    if (conferenceUrl.getIframeToNavigateTo() != null) {
        // let's wait for loading and switch to that iframe so we can continue
        // with regular tests
        WebDriverWait wait = new WebDriverWait(driver, 10);
        wait.until(ExpectedConditions
                .frameToBeAvailableAndSwitchToIt(By.id(conferenceUrl.getIframeToNavigateTo())));
    } else {
        MeetUtils.waitForPageToLoad(driver);
    }

    // disables animations
    executeScript("try { jQuery.fx.off = true; } catch(e) {}");

    executeScript("APP.UI.dockToolbar(true);");

    // disable keyframe animations (.fadeIn and .fadeOut classes)
    executeScript("$('<style>.notransition * { " + "animation-duration: 0s !important; "
            + "-webkit-animation-duration: 0s !important; transition:none; }"
            + " </style>').appendTo(document.head);");
    executeScript("$('body').toggleClass('notransition');");

    // disable the blur effect in firefox as it has some performance issues
    if (this.type.isFirefox()) {
        executeScript("try { var blur " + "= document.querySelector('.video_blurred_container'); "
                + "if (blur) { " + "document.querySelector('.video_blurred_container')"
                + ".style.display = 'none' " + "} } catch(e) {}");
    }

    if ("false".equals(conferenceUrl.getFragmentParam("config.callStatsID"))) {
        // Hack-in disabling of callstats (old versions of jitsi-meet don't
        // handle URL parameters)
        executeScript("config.callStatsID=false;");
    }

    String version = TestUtils.executeScriptAndReturnString(driver, "return JitsiMeetJS.version;");
    TestUtils.print(name + " lib-jitsi-meet version: " + version
            + (driver instanceof RemoteWebDriver ? " sessionID: " + ((RemoteWebDriver) driver).getSessionId()
                    : ""));

    executeScript("document.title='" + name + "'");
}