Example usage for org.openqa.selenium By className

List of usage examples for org.openqa.selenium By className

Introduction

In this page you can find the example usage for org.openqa.selenium By className.

Prototype

public static By className(String className) 

Source Link

Document

Find elements based on the value of the "class" attribute.

Usage

From source file:com.github.wasiqb.coteafs.appium.ios.vodqa.activities.BaseActivity.java

License:Apache License

@Override
protected DeviceElement prepare() {
    final DeviceElement main = DeviceElement.create("Form").forIos(By.className("XCUIElementTypeWindow"));

    DeviceElement.create("Back").parent(main).forIos(MobileBy.iOSNsPredicateString("name == 'Back'"));

    return main;//w  ww. j  av  a  2 s.  com
}

From source file:com.google.caja.plugin.BrowserTestCase.java

License:Apache License

/**
 * Do what should be done with the browser.
 */// ww w.ja  v  a2 s.  c om
protected String driveBrowser(final WebDriver driver) {
    // long timeout: something we're doing is leading to huge unpredictable
    // slowdowns in random test startup; perhaps we're holding onto a lot of ram
    // and  we're losing on swapping/gc time.  unclear.
    countdown(10000, 200, new Countdown() {
        @Override
        public String toString() {
            return "startup";
        }

        public int run() {
            List<WebElement> readyElements = driver.findElements(By.className("readytotest"));
            return readyElements.size() == 0 ? 1 : 0;
        }
    });

    // 4s because test-domado-dom-events has non-click tests that can block
    // for a nontrivial amount of time, so our clicks aren't necessarily
    // processed right away.
    countdown(4000, 200, new Countdown() {
        private List<WebElement> clickingList = null;

        @Override
        public String toString() {
            return "clicking done (Remaining elements = " + renderElements(clickingList) + ")";
        }

        public int run() {
            clickingList = driver.findElements(By.xpath("//*[contains(@class,'clickme')]/*"));
            for (WebElement e : clickingList) {
                // TODO(felix8a): webdriver fails if e has been removed
                e.click();
            }
            return clickingList.size();
        }
    });

    // override point
    waitForCompletion(driver);

    // check the title of the document
    String title = driver.getTitle();
    assertTrue("The title shows " + title, title.contains("all tests passed"));
    return title;
}

From source file:com.googlesites.Sites.java

public void verifySideBarOptionIsSelected(String option) {

    String actualText = driver.findElement(By.className(SELECTED_CLASS)).getText();
    assertTrue(actualText.equals(option), "The selected option is : " + actualText);
}

From source file:com.guidewire.pstesting.policycenter.submission.gbpa.GBDriverRolesPanel.java

protected void setAccidentViolationLevel(String rowText, int columnIndex, String listItem) {
    if (listItem != null) {
        WebElement rowElement = getController().findRow(accidentsViolationsSummaryTableLocator, rowText);
        WebElement cellElement = rowElement.findElements(By.tagName("td")).get(columnIndex);
        By listLocator = By.className("x-list-plain");
        getController().clickAndWait(cellElement, listLocator).type(listItem).sleep(250).pressEnter()
                .sleep(250);/*from   w ww  .  jav  a  2s.  com*/
    }
}

From source file:com.guidewire.pstesting.policycenter.submission.pa.DriverRolesPanel.java

protected void setAccidentViolationLevel(String rowText, int columnIndex, String listItem) {
    if (listItem != null) {
        WebElement rowElement = getController().findRow(accidentsViolationsSummaryTableLocator, rowText);
        WebElement cellElement = rowElement.findElements(By.tagName("td")).get(columnIndex);
        //Cell changes to input once list is invoked - use name attribute for each
        By cellInputLocator = By.name("c" + columnIndex);
        By listLocator = By.className("x-list-plain");
        try {//w  w w  .  j  av  a2s .co  m
            getController().clickRightEdgeAndWait(cellElement, listLocator);
        } catch (Exception e) {
            getController().clickAndWaitFluently(cellElement, listLocator);
        }
        getController().setTextAndTab(cellInputLocator, listItem);
    }
}

From source file:com.gumtreescraper.scraper.GumtreeScraper.java

public boolean login() {
    openSite(LOGIN_URL);//from ww  w  . j a v a 2s .c o  m
    webDriver.findElement(By.id("login-email")).sendKeys(username);
    webDriver.findElement(By.id("login-password")).sendKeys(password);
    webDriver.findElement(By.className("login-form-submit")).findElement(By.tagName("button")).click();

    //        waitForSeconds(10);

    try {
        // if found then return true, otherwise return false
        (new WebDriverWait(this.webDriver, SPECIAL_TIMEOUT))
                .until(ExpectedConditions.presenceOfElementLocated(By.className("item-sign-out")));
        //            webDriver.findElement(By.className("item-sign-out")); 
    } catch (Exception ex) {
        System.out.println(ex);
        return false;
    }

    return true;
}

From source file:com.gwtplatform.carstore.cucumber.application.cars.EditCarsPage.java

License:Apache License

public String getCurrentCarTabName() {
    WebElement selectedTab = carsTabs.findElement(By.className("gwt-TabBarItem-selected"));
    WebElement tabNameContainer = selectedTab.findElement(By.cssSelector("span"));
    return tabNameContainer.getText();
}

From source file:com.gwtplatform.carstore.cucumber.application.stats.StatsPage.java

License:Apache License

public void selectDate(int year, int month, int day) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(year, month - 1, day);//from   w  ww.j  av a 2 s .c o m

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy MMM");
    WebElement datePickerMonth = datePicker.findElement(By.className("datePickerMonth"));
    Date datePickerDate = getCurrentDatePickerDate(dateFormat, datePickerMonth);
    WebElement navigateCalendarButton = getNavigateCalendarButton(calendar, datePickerDate);

    navigateToMonth(calendar.getTime(), dateFormat, datePickerMonth, navigateCalendarButton);
    clickCalendarDay(day);
}

From source file:com.gwtplatform.carstore.cucumber.application.stats.StatsPage.java

License:Apache License

private WebElement getNavigateCalendarButton(Calendar calendar, Date datePickerDate) {
    WebElement navigateCalendarButton;/*from  w  w  w  .  ja v a 2  s .  c o  m*/
    if (calendar.before(datePickerDate)) {
        navigateCalendarButton = datePicker.findElement(By.className("datePickerNextButton"));
    } else {
        navigateCalendarButton = datePicker.findElement(By.className("datePickerPreviousButton"));
    }
    return navigateCalendarButton;
}

From source file:com.hack23.cia.systemintegrationtest.AbstractRoleSystemTest.java

License:Apache License

/**
 * Click first row in grid.// w ww .  j a  v a 2  s.co  m
 *
 * @param userPageVisit
 *            the user page visit
 * @return the string
 * @throws InterruptedException
 *             the interrupted exception
 */
protected final void clickFirstRowInGrid(final UserPageVisit userPageVisit) throws InterruptedException {
    final List<WebElement> gridRows = userPageVisit.getGridRows();
    assertFalse(gridRows.isEmpty());

    final WebElement choosenRow = gridRows.iterator().next();

    final List<WebElement> cells = choosenRow.findElements(By.className("v-grid-cell"));

    final WebElement choosenCell = cells.iterator().next();

    userPageVisit.performClickAction(choosenCell);

}