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:applicationdriverlayer.pageobjects.squash.booking.CourtAndTimeSlotChooserPage.java

License:Apache License

@Override
protected void waitForLoadToComplete() {
    new WebDriverWait(driver, explicitWaitTimeoutSeconds)
            .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className("booking-table")));
    new WebDriverWait(driver, explicitWaitTimeoutSeconds).until(ExpectedConditions.visibilityOf(dateDropdown));
}

From source file:applicationdriverlayer.pageobjects.squash.booking.CourtAndTimeSlotChooserPage.java

License:Apache License

@Override
protected void assertIsLoaded() {
    Assert.assertTrue("The CourtAndTimeSlotBooking page is not loaded (booking table not visible)",
            driver.findElement(By.className("booking-table")).isDisplayed());
    Assert.assertTrue("The CourtAndTimeSlotBooking page is not loaded (date selector dropdown not visible)",
            dateDropdown.isDisplayed());
}

From source file:applicationdriverlayer.pageobjects.squash.booking.CourtCancellationPage.java

License:Apache License

@Override
protected void waitForLoadToComplete() {
    new WebDriverWait(driver, explicitWaitTimeoutSeconds)
            .until(ExpectedConditions.visibilityOfElementLocated(By.className("cancellation-form")));
    new WebDriverWait(driver, explicitWaitTimeoutSeconds)
            .until(ExpectedConditions.visibilityOf(submitCancellationButton));
}

From source file:applicationdriverlayer.pageobjects.squash.booking.CourtCancellationPage.java

License:Apache License

@Override
protected void assertIsLoaded() throws Error {
    super.assertIsLoaded();

    Assert.assertTrue("The cancellation form is not visible",
            driver.findElement(By.className("cancellation-form")).isDisplayed());
}

From source file:applicationdriverlayer.pageobjects.squash.booking.CourtReservationPage.java

License:Apache License

@Override
protected void waitForLoadToComplete() {
    new WebDriverWait(driver, explicitWaitTimeoutSeconds)
            .until(ExpectedConditions.visibilityOfElementLocated(By.className("reservation-form")));
    new WebDriverWait(driver, explicitWaitTimeoutSeconds)
            .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[name = 'name']")));
}

From source file:applicationdriverlayer.pageobjects.squash.booking.CourtReservationPage.java

License:Apache License

@Override
protected void assertIsLoaded() throws Error {
    super.assertIsLoaded();

    Assert.assertTrue("The reservation form is not visible",
            driver.findElement(By.className("reservation-form")).isDisplayed());
}

From source file:at.tugraz.ist.catroweb.admin.SendEmailNotificationTests.java

License:Open Source License

@Test(groups = { "functionality", "sendEmail" }, description = "send e-mail notification")
public void sendButton() throws Throwable {
    try {/*from  ww w. j ava2  s. c  o m*/
        openAdminLocation();
        ajaxWait();
        driver().findElement(By.id("aAdministrationTools")).click();
        ajaxWait();
        driver().findElement(By.id("aAdminToolsSendEmailNotification")).click();
        ajaxWait();

        List<WebElement> checkboxes = driver().findElements(By.className("chkBoxEmail"));

        clickOkOnNextConfirmationBox();
        driver().findElement(By.id("sendEmailSubmit")).click();
        assertFalse(isTextPresent("Answer:"));
        assertFalse(isTextPresent("Number of emails selected:"));

        driver().findElement(By.id("chkboxSelectAll")).click();

        clickCancelOnNextConfirmationBox();
        driver().findElement(By.id("sendEmailSubmit")).click();
        assertFalse(isTextPresent("Answer:"));
        assertFalse(isTextPresent("Number of emails selected:"));

        clickOkOnNextConfirmationBox();
        driver().findElement(By.id("sendEmailSubmit")).click();

        assertTrue(isTextPresent("Answer:"));
        assertTrue(isTextPresent("Number of emails selected: " + checkboxes.size()));
        assertFalse(isTextPresent("Sending message to user \"anonymous\""));
        assertTrue(isTextPresent("Sending message to user \"catroweb\""));
        assertTrue(isTextPresent(
                "Status: " + checkboxes.size() + " of " + +checkboxes.size() + " e-mails sent. (0 failed)"));
    } catch (AssertionError e) {
        captureScreen("SendEmailNotificationTests.sendButton");
        throw e;
    } catch (Exception e) {
        captureScreen("SendEmailNotificationTests.sendButton");
        throw e;
    }
}

From source file:at.tugraz.ist.catroweb.admin.SendEmailNotificationTests.java

License:Open Source License

@Test(groups = { "functionality",
        "sendEmail" }, description = "select checkboxes one by one and by using select all checkbox")
public void checkCheckboxes() throws Throwable {
    try {/* w w w .  j  ava2  s  . c  o m*/
        int checked = 0;
        openAdminLocation();
        ajaxWait();
        driver().findElement(By.id("aAdministrationTools")).click();
        ajaxWait();
        driver().findElement(By.id("aAdminToolsSendEmailNotification")).click();
        ajaxWait();

        assertTrue(isTextPresent(" (" + checked + " user(s) selected)"));

        List<WebElement> checkboxes = driver().findElements(By.className("chkBoxEmail"));
        for (WebElement checkbox : checkboxes) {
            assertFalse(checkbox.isSelected());
        }

        for (WebElement checkbox : checkboxes) {
            driver().findElement(By.id(checkbox.getAttribute("id"))).click();
            checked++;
            assertTrue(isTextPresent(" (" + checked + " user(s) selected)"));
            assertTrue(checkbox.isSelected());
        }

        assertTrue(isTextPresent("unselect all"));
        // unselect all checkboxes by clicking on unselect all checkbox
        checked = 0;
        driver().findElement(By.id("chkboxSelectAll")).click();
        ajaxWait();

        for (WebElement checkbox : checkboxes) {
            assertFalse(checkbox.isSelected());
        }
        assertTrue(isTextPresent("select all"));
        assertTrue(isTextPresent(" (" + checked + " user(s) selected)"));

        // select all checkboxes by clicking on select all checkbox
        driver().findElement(By.id("chkboxSelectAll")).click();
        for (WebElement checkbox : checkboxes) {
            checked++;
            assertTrue(checkbox.isSelected());
        }
        assertTrue(isTextPresent("unselect all"));
        assertTrue(isTextPresent(" (" + checked + " user(s) selected)"));

    } catch (AssertionError e) {
        captureScreen("SendEmailNotificationTests.checkCheckboxes");
        throw e;
    } catch (Exception e) {
        captureScreen("SendEmailNotificationTests.checkCheckboxes");
        throw e;
    }
}

From source file:at.tugraz.ist.catroweb.catroid.SearchTests.java

License:Open Source License

@Test(groups = { "functionality" }, description = "search project, highlight search query")
public void highlightSearchQuery() throws Throwable {
    try {/*from  ww  w  . ja va 2  s  .  com*/

        String projectTitle = CommonData.getRandomShortString(7);
        String response = projectUploader
                .upload(CommonData.getUploadPayload(projectTitle, "identical_search_project_2", "", "", "", "",
                        CommonData.getLoginUserDefault(), Config.DEFAULT_UPLOAD_TOKEN));
        assertEquals("200", CommonFunctions.getValueFromJSONobject(response, "statusCode"));

        openLocation("/search/?q=" + projectTitle + "&p=1", false);
        ajaxWait();
        assertEquals(projectTitle, driver().findElement(By.className("highlight")).getText());

        openLocation("/search/?q=" + projectTitle.toUpperCase() + "&p=1", false);
        ajaxWait();
        assertEquals(projectTitle, driver().findElement(By.className("highlight")).getText());
    } catch (AssertionError e) {
        captureScreen("SearchTests.highlightSearchQuery");
        throw e;
    } catch (Exception e) {
        captureScreen("SearchTests.highlightSearchQuery");
        throw e;
    }
}

From source file:au.edu.qtac.admission.webtest.DragAndDropTest.java

@Test
public void shouldBeAbleToDragAndDrop() {
    driver.navigate().to("http://pfdemo-peterdemo101.rhcloud.com/pfdemo/dragdrop.xhtml");
    Actions builder = new Actions(driver);

    //        Action dragAndDrop = builder.clickAndHold(driver.findElement(By.id("j_idt11_header")))
    //                .moveByOffset(100, 300).release().build();

    Action dragAndDrop = builder.dragAndDrop(driver.findElement(By.className("ui-draggable")),
            driver.findElement(By.className("ui-droppable"))).build();

    dragAndDrop.perform();//from  www.  j  ava2 s .  c o  m

    try {
        Thread.sleep(5000);
    } catch (InterruptedException ex) {
        Logger.getLogger(DragAndDropTest.class.getName()).log(Level.SEVERE, null, ex);
    }
}