import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
-import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.PopupViewElement;
// Open PopupView
$(PopupViewElement.class).first().click();
- // Shadow element
- WebElement shadow = findElement(By.className("v-shadow"));
- WebElement vl = $(VerticalLayoutElement.class).id("content-vl");
-
// Sanity check
- assertShadowSize(vl, shadow);
+ assertShadowSize();
// Resize
$(ButtonElement.class).first().click();
- assertShadowSize(vl, shadow);
+ assertShadowSize();
}
- private void assertShadowSize(WebElement layout, WebElement shadow) {
- Dimension shadowSize = shadow.getSize();
- Dimension layoutSize = layout.getSize();
+ private void assertShadowSize() {
+ Dimension shadowSize = findElement(By.className("v-shadow")).getSize();
+ Dimension layoutSize = $(VerticalLayoutElement.class).id("content-vl")
+ .getSize();
assertThat(shadowSize.height, is(greaterThan(layoutSize.height)));
assertThat(shadowSize.height, is(lessThan(layoutSize.height + 10)));
import org.junit.Assert;
import org.junit.Test;
-import org.openqa.selenium.WebElement;
-import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TableElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
public void testTableSortingIndicatorIsVisibleAfterServersideSort() {
openTestURL();
+ ButtonElement button = $(ButtonElement.class).caption("Sort").first();
+ TableElement table = $(TableElement.class).first();
+
Assert.assertFalse("Descending indicator was prematurely visible",
- isElementPresent(By.className(TABLE_HEADER_DESC_INDICATOR)));
+ getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR));
Assert.assertFalse("Ascending indicator was prematurely visible",
- isElementPresent(By.className(TABLE_HEADER_ASC_INDICATOR)));
- WebElement button = driver.findElement(By
- .vaadin("//Button[caption=\"Sort\"]"));
+ getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR));
+
button.click();
Assert.assertTrue("Indicator did not become visible",
- isElementPresent(By.className(TABLE_HEADER_DESC_INDICATOR)));
-
+ getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR));
Assert.assertFalse("Ascending sort indicator was wrongly visible",
- isElementPresent(By.className(TABLE_HEADER_ASC_INDICATOR)));
- WebElement manualSort = driver.findElement(By
- .className(TABLE_HEADER_DESC_INDICATOR));
- manualSort.click();
+ getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR));
+
+ table.getHeaderCell(0).click();
Assert.assertFalse("Table sort indicator didn't change",
- isElementPresent(By.className(TABLE_HEADER_DESC_INDICATOR)));
+ getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR));
Assert.assertTrue("Ascending sort indicator didn't become visible",
- isElementPresent(By.className(TABLE_HEADER_ASC_INDICATOR)));
+ getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR));
+
button.click();
Assert.assertTrue(
"Descending sort indicator didn't appear on the second serverside sort.",
- isElementPresent(By.className(TABLE_HEADER_DESC_INDICATOR)));
+ getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR));
Assert.assertFalse("Ascending sort indicator didn't disappear",
- isElementPresent(By.className(TABLE_HEADER_ASC_INDICATOR)));
+ getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR));
+ }
+
+ private String getHeaderClasses(TableElement table) {
+ return table.getHeaderCell(0).getAttribute("class");
}
}