Example usage for org.openqa.selenium WebElement getSize

List of usage examples for org.openqa.selenium WebElement getSize

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement getSize.

Prototype

Dimension getSize();

Source Link

Document

What is the width and height of the rendered element?

Usage

From source file:com.vaadin.tests.components.calendar.SetFirstVisibleHourOfDayTest.java

License:Apache License

@Test
public void testWeekView() {
    openTestURL();/* w w  w. ja  v  a  2s .  com*/
    waitForElementPresent(By.className("v-calendar"));

    // open week view
    clickElement("v-calendar-week-number", "36");

    // first of all check if event is present in calendar view
    waitForElementPresent(By.className("v-calendar-event-content"));

    WebElement event = getDriver().findElement(By.className("v-calendar-event-content"));
    WebElement dateSlot = getDriver().findElement(By.className("v-datecellslot"));

    Assert.assertEquals("The height of shown part of calendar event should be equal to 12 datecell slots",
            dateSlot.getSize().getHeight() * 12, event.getSize().getHeight());
}

From source file:com.vaadin.tests.components.combobox.ComboBoxSuggestionPopupWidthModesTest.java

License:Apache License

@Test
public void suggestionPopupPersentageWidthTest() throws Exception {
    openTestURL();/*from   w ww . j a v  a2  s  .  c  o m*/

    waitForElementVisible(By.className("percentage"));

    WebElement selectTextbox = $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox"));
    selectTextbox.click();

    CustomComboBoxElement cb = $(CustomComboBoxElement.class).first();
    cb.openPopup();
    WebElement popup = cb.getSuggestionPopup();

    int width = popup.getSize().getWidth();
    assertTrue(width == 400);

}

From source file:com.vaadin.tests.components.combobox.ComboBoxSuggestionPopupWidthModesTest.java

License:Apache License

@Test
public void suggestionPopupFixedWidthTest() throws Exception {
    openTestURL();/*from w w w .ja va2  s .  c o m*/

    waitForElementVisible(By.className("pixels"));

    WebElement selectTextbox = $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox"));
    selectTextbox.click();

    CustomComboBoxElement cb = $(CustomComboBoxElement.class).first();
    cb.openPopup();
    WebElement popup = cb.getSuggestionPopup();

    int width = popup.getSize().getWidth();
    assertTrue(width == 300);

}

From source file:com.vaadin.tests.components.combobox.ComboBoxSuggestionPopupWidthModesTest.java

License:Apache License

@Test
public void suggestionPopupLegacyWidthTest() throws Exception {
    openTestURL();//from  ww  w  .jav a  2 s. c  om

    waitForElementVisible(By.className("legacy"));

    WebElement selectTextbox = $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox"));
    selectTextbox.click();

    CustomComboBoxElement cb = $(CustomComboBoxElement.class).first();
    cb.openPopup();
    WebElement popup = cb.getSuggestionPopup();

    int width = popup.getSize().getWidth();
    assertGreater("Legacy mode popup should be quite wide", width, 600);
    assertLessThan("Even legacy mode popup should not be over 1000px wide with the set item captions ", width,
            600);

}

From source file:com.vaadin.tests.components.grid.basicfeatures.client.GridClientStructureTest.java

License:Apache License

@Test
public void haederDecoSizeShouldBeRecalculated() {
    // it's easier to notice with valo
    openTestURL("theme=valo");

    WebElement topDeco = getGridElement().findElement(By.className("v-grid-header-deco"));
    assertGreater("The header deco in Valo hasn't been recalculated after initial rendering",
            topDeco.getSize().getHeight(), 20);
}

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridColumnReorderTest.java

License:Apache License

@Test
public void testColumnReordering_bigWidth_dragElementPositionCorrect() {
    openTestURL();//from  w ww . ja va  2  s  .c om
    toggleColumnReordering();
    selectMenuPath("Component", "Size", "Width", "900px");
    assertColumnHeaderOrder(0, 1, 2, 3);

    GridCellElement draggedHeaderCell = getGridElement().getHeaderCell(0, 1);
    final int xOffset = 500;
    new Actions(getDriver()).moveToElement(draggedHeaderCell, 20, 10).clickAndHold().moveByOffset(xOffset, 0)
            .build().perform();

    WebElement floatingDragElement = findElement(By.className("dragged-column-header"));

    int expectedLeft = draggedHeaderCell.getLocation().getX() + xOffset + 20
            - (floatingDragElement.getSize().getWidth() / 2);
    int realLeft = floatingDragElement.getLocation().getX();

    assertTrue("Dragged element location wrong, expected " + expectedLeft + " was " + realLeft,
            Math.abs(expectedLeft - realLeft) < 10);
}

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridStructureTest.java

License:Apache License

@Test
public void testInitialColumnWidths() throws Exception {
    openTestURL();/*from  www .  ja  va  2  s. c o  m*/

    WebElement cell = getGridElement().getCell(0, 0);
    assertEquals(100, cell.getSize().getWidth());

    cell = getGridElement().getCell(0, 1);
    assertEquals(150, cell.getSize().getWidth());

    cell = getGridElement().getCell(0, 2);
    assertEquals(200, cell.getSize().getWidth());
}

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridStructureTest.java

License:Apache License

@Test
public void testColumnWidths() throws Exception {
    openTestURL();//from ww  w  .  j a v  a  2  s  .c o m

    // Default column width is 100px
    WebElement cell = getGridElement().getCell(0, 0);
    assertEquals(100, cell.getSize().getWidth());

    // Set first column to be 200px wide
    selectMenuPath("Component", "Columns", "Column 0", "Column 0 Width", "200px");

    cell = getGridElement().getCell(0, 0);
    assertEquals(200, cell.getSize().getWidth());

    // Set second column to be 150px wide
    selectMenuPath("Component", "Columns", "Column 1", "Column 1 Width", "150px");
    cell = getGridElement().getCell(0, 1);
    assertEquals(150, cell.getSize().getWidth());

    selectMenuPath("Component", "Columns", "Column 0", "Column 0 Width", "Auto");

    // since the column 0 was previously 200, it should've shrunk when
    // autoresizing.
    cell = getGridElement().getCell(0, 0);
    assertLessThan("", cell.getSize().getWidth(), 200);
}

From source file:com.vaadin.tests.components.tree.TreeContextMenuAndIconsTest.java

License:Apache License

@Test
public void testContextLargeIcon() throws Exception {
    openTestURL();/*from   w  w w .j  ava  2s  . c o  m*/

    selectMenuPath("Settings", "Show event log");
    selectMenuPath("Component", "Features", "Context menu", "Only one large icon");

    WebElement menu = openContextMenu(getTreeNodeByCaption("Item 1"));

    // reindeer doesn't support menu with larger row height, so the
    // background image contains parts of other sprites =>
    // just check that the menu is of correct size
    Dimension size = menu.getSize();
    Assert.assertEquals("Menu height with large icons", 74, size.height);

    closeContextMenu();
}

From source file:com.vaadin.v7.tests.components.grid.basicfeatures.escalator.EscalatorColspanTest.java

License:Apache License

@Test
public void testColspan() {
    openTestURL();//from  w  w w  .j a va2  s  .c o m
    populate();

    int firstCellWidth = getBodyCell(0, 0).getSize().getWidth();
    int secondCellWidth = getBodyCell(0, 1).getSize().getWidth();
    int doubleCellWidth = firstCellWidth + secondCellWidth;

    selectMenuPath(FEATURES, COLUMN_SPANNING, COLSPAN_NORMAL);

    WebElement bodyCell = getBodyCell(0, 0);
    assertEquals("Cell was not spanned correctly", 2, getColSpan(bodyCell));
    assertEquals("Spanned cell's width was not the sum of the previous cells (" + firstCellWidth + " + "
            + secondCellWidth + ")", doubleCellWidth, bodyCell.getSize().getWidth(), 1);
}