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

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

Introduction

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

Prototype

public static ExpectedCondition<WebElement> visibilityOf(final WebElement element) 

Source Link

Document

An expectation for checking that an element, known to be present on the DOM of a page, is visible.

Usage

From source file:com.ionidea.RegressionNGA.Tests.ArtistInformation.java

@Test
public void elementsExistWorksOfArt() throws InterruptedException {

    //Initiate new page (+widget)
    ArtistInformationPage artistInformationPage = new ArtistInformationPage(driver);
    WidgetWorksOfArtPage widget = new WidgetWorksOfArtPage(driver);

    //move to the URL of test page
    artistInformationPage.openPageWidget(artistInformationPage, m_baseUrl,
            artistInformationPage.worksOfArtLink);
    m_wait.until(ExpectedConditions.visibilityOf(widget.leftAccordionsClosed.get(1)));

    //Verify number  of folter accordions        
    Assert.assertEquals(widget.leftAccordionsClosed.size(), 7,
            "The quantity of left accordions is less than expected");
    System.out.println("the number of accordions is correct");

    //Expand all accordions
    widget.clickAllElements(widget.leftAccordionsClosed, (FluentWait) m_wait);
    System.out.println("all closed accordions are displayed");

    //verify all left accordions
    widget.verifyAllElementsAreDisplayed(widget.leftAccordionsOpen, (FluentWait) m_wait);
    System.out.println("all open accordions are displayed");

    //verify all check-boxes and respective labels
    Assert.assertEquals(widget.allCheckBoxes.size(), widget.allLabels.size(),
            "the check-boxes quantity is less than labels'");
    Assert.assertEquals(widget.allCheckBoxes.size(), 11, "the labels quantity is not equal to 11");
    widget.verifyAllElementsAreDisplayed(widget.allCheckBoxes, (FluentWait) m_wait);
    widget.verifyAllElementsAreDisplayed(widget.allLabels, (FluentWait) m_wait);

    //verify all check-boxes are unselected
    widget.verifyAllCheckBoxesAreUnselected(widget.allCheckBoxes, (FluentWait) m_wait);
    System.out.println("all checkboxes are verified, the number is:" + widget.allCheckBoxes.size());

    //Verify the number of the works of art
    int worksNumber;
    worksNumber = widget.addToListallWorkObjects(widget, widget.artistNameLabels, 4, (FluentWait) m_wait);
    Assert.assertEquals(worksNumber, 50, "works number is not equal to 50");
    System.out.println("The number of author labels is - 50");

}

From source file:com.ionidea.RegressionNGA.Tests.ProvenanceInformation.java

@Test

public void provenanceStaticElementsExist() {
    ProvenanceInformationPage provenanceInformationPage = new ProvenanceInformationPage(driver);
    driver.get(m_baseUrl + "/content/ngaweb/Collection/provenance-info.6747.html#works");
    driver.manage().window().maximize();
    m_wait.until(ExpectedConditions.visibilityOf(provenanceInformationPage.artistDescription));

    //Verify all static page elements
    provenanceInformationPage.assertElementIsPresent(driver, provenanceInformationPage.relatedContentLink);
    provenanceInformationPage.assertElementIsPresent(driver, provenanceInformationPage.worksOfArtLink);
    provenanceInformationPage.assertTextIsPresent(driver, provenanceInformationPage.artistNameTitle,
            "Frank, Robert");
    provenanceInformationPage.assertTextIsPresent(driver, provenanceInformationPage.artistDescription,
            "Robert Frank c/o Pace/MacGill Gallery");
    provenanceInformationPage.assertTextIsPresent(driver, provenanceInformationPage.artistLifeSpan,
            "American, born Switzerland, 1924");

    //Open another page example
    driver.get(m_baseUrl + "/content/ngaweb/Collection/provenance-info.29368.html");
    driver.manage().window().maximize();
    m_wait.until(ExpectedConditions.visibilityOf(provenanceInformationPage.artistDescription));
    provenanceInformationPage.assertElementIsPresent(driver, provenanceInformationPage.biographyLink);
    provenanceInformationPage.assertElementIsPresent(driver, provenanceInformationPage.artistBibliographyLink);

}

From source file:com.ionidea.RegressionNGA.Tests.ProvenanceInformation.java

@Test

public void provenanceWorksOfArtExist() throws InterruptedException {

    ProvenanceInformationPage provenanceInformationPage = new ProvenanceInformationPage(driver);
    WidgetWorksOfArtPage widget = new WidgetWorksOfArtPage(driver);

    driver.get(m_baseUrl + "/content/ngaweb/Collection/provenance-info.6747.html#works");
    driver.manage().window().maximize();
    provenanceInformationPage.worksOfArtLink.click();
    m_wait.until(ExpectedConditions.visibilityOf(widget.leftAccordionsClosed.get(1)));

    //Verify number  of folter accordions        
    Assert.assertEquals(widget.leftAccordionsClosed.size(), 4);
    System.out.println("the number of accordions is correct");

    //Expand all accordions
    widget.clickAllElements(widget.leftAccordionsClosed, (FluentWait) m_wait);
    System.out.println("all closed accordions are displayed");

    //verify all left accordions
    widget.verifyAllElementsAreDisplayed(widget.leftAccordionsOpen, (FluentWait) m_wait);
    System.out.println("all open accordions are displayed");

    //verify all check-boxes and respective labels
    Assert.assertEquals(widget.allCheckBoxes.size(), widget.allLabels.size());
    Assert.assertEquals(widget.allCheckBoxes.size(), 8);
    widget.verifyAllElementsAreDisplayed(widget.allCheckBoxes, (FluentWait) m_wait);
    widget.verifyAllElementsAreDisplayed(widget.allLabels, (FluentWait) m_wait);

    //verify all check-boxes are unselected
    widget.verifyAllCheckBoxesAreUnselected(widget.allCheckBoxes, (FluentWait) m_wait);
    System.out.println("all checkboxes are verified, the number is:" + widget.allCheckBoxes.size());

    //Verify the number of the works of art
    int worksNumber;
    worksNumber = widget.addToListallWorkObjects(widget, widget.artistNameLabels, 2, (FluentWait) m_wait);
    Assert.assertEquals(worksNumber, 40);
    System.out.println("The number of author labels is " + worksNumber);

}

From source file:com.ionidea.RegressionNGA.Tests.ProvenanceInformation.java

@Test

public void provenanceBibliographyExist() throws InterruptedException {

    //Initiate page (+ widget Page)
    ProvenanceInformationPage provenanceInformationPage = new ProvenanceInformationPage(driver);
    WidgetBibliographyPage widget = new WidgetBibliographyPage(driver);

    //move to widget page
    driver.get(m_baseUrl + "/content/ngaweb/Collection/provenance-info.29368.html");
    driver.manage().window().maximize();
    m_wait.until(ExpectedConditions.visibilityOf(provenanceInformationPage.artistBibliographyLink));
    provenanceInformationPage.artistBibliographyLink.click();
    ;/*from w ww.  j av  a 2  s .  co m*/

    //Verify all static  elements of the page
    provenanceInformationPage.assertTextIsPresent(driver, widget.bibliographyLabel, "BIBLIOGRAPHY");
    System.out.println("the label is displayed");

    //Add all text elements to array
    String years[][] = new String[10][2];
    years[0][0] = "1993";
    years[0][1] = "Heijbroek, Jan Frederik. Kunst, kennis en commercie: de kunsthandelaar J.H. de Bois (1878-1946). Amsterdam, 1993.";

    //Verify all found static web elemnts contain respective text

    provenanceInformationPage.assertTextIsPresent(driver, widget.yearLabel.get(0), years[0][0]);
    System.out.println("The element verified: " + widget.yearLabel.get(0));
    MainPage.assertTextIsPresent(driver, widget.yearDescriptionLabel.get(0), years[0][1]);
    System.out.println("The element verified: " + widget.yearDescriptionLabel.get(0));

}

From source file:com.ionidea.RegressionNGA.Tests.ProvenanceInformation.java

@Test
public void provenanceBiographyExist() {

    //Initiate page (+ widget Page)
    ProvenanceInformationPage provenanceInformationPage = new ProvenanceInformationPage(driver);
    WidgetBiographyPage widget = new WidgetBiographyPage(driver);

    //move to widget page
    driver.get(m_baseUrl + "/content/ngaweb/Collection/provenance-info.29368.html");
    driver.manage().window().maximize();
    m_wait.until(ExpectedConditions.visibilityOf(provenanceInformationPage.biographyLink));
    provenanceInformationPage.biographyLink.click();

    //Test the objects of #Biography 
    provenanceInformationPage.assertTextIsPresent(driver, widget.biographyTitle, "BIOGRAPHY");
    provenanceInformationPage.assertElementIsPresent(driver, widget.biographyAll);

}

From source file:com.ionidea.RegressionNGA.Tests.ProvenanceInformation.java

@Test

public void provenanceRelatedContentExist() {

    //Initiate page (+ widget Page)
    ProvenanceInformationPage provenanceInformationPage = new ProvenanceInformationPage(driver);
    WidgetRelatedContentPage widget = new WidgetRelatedContentPage(driver);

    //move to widget page
    driver.get(m_baseUrl + "/content/ngaweb/Collection/provenance-info.6747.html#works");
    driver.manage().window().maximize();
    m_wait.until(ExpectedConditions.visibilityOf(provenanceInformationPage.relatedContentLink));
    provenanceInformationPage.relatedContentLink.click();

    //Verify all elements
    Assert.assertTrue(widget.relatedContentDescription.size() == 3,
            "The quantity of related content elements is not correct");
    Assert.assertTrue(widget.relatedContentImage.size() == 3,
            "The quantity of related content elements is not correct");
    Assert.assertTrue(widget.relatedContentResultLink.size() == 4,
            "The quantity of related content elements is not correct");
    Assert.assertTrue(widget.relatedContentResultTitle.size() == 4,
            "The quantity of related content elements is not correct");
    Assert.assertTrue(widget.relatedContentTitle.isDisplayed(), "The titlw is not displayed");
    System.out.println("The array size check is completed");

    //Verify all Elelemnts are visible
    provenanceInformationPage.verifyAllElementsAreDisplayed(widget.relatedContentDescription,
            (FluentWait) m_wait);// w w w  .  j a va2s.  co  m
    provenanceInformationPage.verifyAllElementsAreDisplayed(widget.relatedContentImage, (FluentWait) m_wait);
    provenanceInformationPage.verifyAllElementsAreDisplayed(widget.relatedContentResultLink,
            (FluentWait) m_wait);
    provenanceInformationPage.verifyAllElementsAreDisplayed(widget.relatedContentResultTitle,
            (FluentWait) m_wait);
    System.out.println("The display size check is completed");
}

From source file:com.java.xero.EmployeeCreationPage.java

public boolean EmployeeCreationWithAllFields(String organizationName, String sTitle, String sFirstName,
        String sMiddleName, String sLastName, String sBirthDay, String sMonth, String sYear, String sJobTitle,
        String sGender, String sPhoneNumber, String sMobileNumber, String sEmail, String sAddress1,
        String sAddress2, String sSuburb, String sState, String sPostCode) {
    boolean flag = false;
    try {//  w  w  w. j  ava  2  s  .  com
        wait = new WebDriverWait(driver, 100);

        WebElement organisationNameElement = driver
                .findElement(By.xpath("//a[contains(text(),'" + organizationName + "') and @class='name']"));
        wait.until(ExpectedConditions.visibilityOf(organisationNameElement));
        organisationNameElement.click();

        Thread.sleep(10000);
        driver.findElement(By.xpath(payRollDropdown)).click();

        driver.findElement(By.xpath(employeesSelection)).click();

        Thread.sleep(10000);
        driver.findElement(By.xpath(addEmployeeButton)).click();
        Thread.sleep(5000);

        driver.findElement(By.xpath(titleTextBox)).clear();
        driver.findElement(By.xpath(titleTextBox)).sendKeys(sTitle);

        driver.findElement(By.xpath(firstNameTextBox)).clear();
        driver.findElement(By.xpath(firstNameTextBox)).sendKeys(sFirstName);

        driver.findElement(By.xpath(middleNameTextBox)).clear();
        driver.findElement(By.xpath(middleNameTextBox)).sendKeys(sMiddleName);

        driver.findElement(By.xpath(lastNameTextBox)).clear();
        driver.findElement(By.xpath(lastNameTextBox)).sendKeys(sLastName);

        driver.findElement(By.xpath(birthDayTextBox)).clear();
        driver.findElement(By.xpath(birthDayTextBox)).sendKeys(sBirthDay);

        driver.findElement(By.xpath(monthDropdown)).click();
        // Select mySelectMonth= new Select(monthDropdown);
        // mySelectMonth.selectByVisibleText(sMonth);

        WebElement monthSelection = driver.findElement(
                By.xpath("//span[@class='xg-menu-item-text' and contains(text(),'" + sMonth + "')]"));
        monthSelection.click();

        driver.findElement(By.xpath(yearTextBox)).clear();
        driver.findElement(By.xpath(yearTextBox)).sendKeys(sYear);

        driver.findElement(By.xpath(jobTitleTextBox)).clear();
        driver.findElement(By.xpath(jobTitleTextBox)).sendKeys(sJobTitle);

        WebElement genderRadioButton = driver
                .findElement(By.xpath("//input[@type='radio' and @value='" + sGender + "']"));
        genderRadioButton.click();

        driver.findElement(By.xpath(phoneNumberTextBox)).clear();
        driver.findElement(By.xpath(phoneNumberTextBox)).sendKeys(sPhoneNumber);

        driver.findElement(By.xpath(mobileNumberTextBox)).clear();
        driver.findElement(By.xpath(mobileNumberTextBox)).sendKeys(sMobileNumber);

        driver.findElement(By.xpath(emailTextBox)).clear();
        driver.findElement(By.xpath(emailTextBox)).sendKeys(sEmail);

        driver.findElement(By.xpath(addressLineTextBox)).clear();
        driver.findElement(By.xpath(addressLineTextBox)).sendKeys(sAddress1);

        driver.findElement(By.xpath(addressLine2)).clear();
        driver.findElement(By.xpath(addressLine2)).sendKeys(sAddress2);

        driver.findElement(By.xpath(suburbTextBox)).clear();
        driver.findElement(By.xpath(suburbTextBox)).sendKeys(sSuburb);

        driver.findElement(By.xpath(stateDropdown)).click();

        WebElement stateSelection = driver.findElement(
                By.xpath("//span[@class='xg-menu-item-text' and contains(text(),'" + sState + "')]"));
        stateSelection.click();

        driver.findElement(By.xpath(postCodeTextBox)).clear();
        driver.findElement(By.xpath(postCodeTextBox)).sendKeys(sPostCode);

        driver.findElement(By.xpath(saveButton)).click();
        Thread.sleep(5000);

        String employeeSaveValidationXpath = "//p[contains(text(),'" + sFirstName + " " + sLastName
                + " has been saved successfully.')]";
        if (driver.findElements(By.xpath(employeeSaveValidationXpath)).size() != 0) {
            flag = true;
            System.out.println("Employee created successfully");
        } else
            System.out.println("Failed to create an employee");
    } catch (Exception e) {
        e.printStackTrace();
    }

    return flag;
}

From source file:com.java.xero.EmployeeCreationPage.java

public boolean EmployeeCreationWithoutFillingAnyFields(String organizationName) {
    boolean flag = false;
    try {//from www  .  j  ava  2  s.c o m
        wait = new WebDriverWait(driver, 100);

        WebElement organisationNameElement = driver
                .findElement(By.xpath("//a[contains(text(),'" + organizationName + "') and @class='name']"));
        wait.until(ExpectedConditions.visibilityOf(organisationNameElement));
        organisationNameElement.click();

        Thread.sleep(10000);
        driver.findElement(By.xpath(payRollDropdown)).click();

        driver.findElement(By.xpath(employeesSelection)).click();

        Thread.sleep(10000);
        driver.findElement(By.xpath(addEmployeeButton)).click();
        Thread.sleep(5000);

        driver.findElement(By.xpath(saveButton)).click();
        Thread.sleep(5000);
        if (driver.findElements(By.xpath(errorMessageText)).size() != 0) {
            flag = true;
        } else
            System.out.println("Failed!");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return flag;
}

From source file:com.liferay.blade.sample.test.functional.utils.BladeSampleFunctionalActionUtil.java

License:Apache License

public static boolean isVisible(WebDriver webDriver, WebElement webelement) {

    WebDriverWait webDriverWait = new WebDriverWait(webDriver, 30);

    try {/* w ww  .j ava  2s.  c o  m*/
        webDriverWait.until(ExpectedConditions.visibilityOf(webelement));

        return true;
    } catch (org.openqa.selenium.TimeoutException te) {
        return false;
    }
}

From source file:com.liferay.blade.samples.servicebuilder.web.BladeServiceBuilderWebTest.java

License:Apache License

public void customClick(WebDriver webDriver, WebElement webElement) {
    Actions action = new Actions(webDriver);

    action.moveToElement(webElement).build().perform();

    WebDriverWait wait = new WebDriverWait(webDriver, 5);

    WebElement element = wait.until(ExpectedConditions.visibilityOf(webElement));

    element.click();//from  ww  w . j  a v a 2s. co m
}