Change-Id: I586c6b624f16969868be1affeac4707db18f5136tags/7.4.8
@@ -15,9 +15,9 @@ | |||
*/ | |||
package com.vaadin.tests.components.grid.basicfeatures; | |||
import org.openqa.selenium.Dimension; | |||
import java.util.List; | |||
import org.openqa.selenium.WebElement; | |||
import org.openqa.selenium.interactions.Actions; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.TestBenchElement; | |||
@@ -53,31 +53,16 @@ public abstract class GridBasicClientFeaturesTest extends GridBasicFeaturesTest | |||
@Override | |||
protected void selectMenu(String menuCaption) { | |||
WebElement menuElement = getMenuElement(menuCaption); | |||
Dimension size = menuElement.getSize(); | |||
new Actions(getDriver()).moveToElement(menuElement, size.width - 10, | |||
size.height / 2).perform(); | |||
// GWT menu does not need to be clicked. | |||
selectMenu(menuCaption, false); | |||
} | |||
private WebElement getMenuElement(String menuCaption) { | |||
@Override | |||
protected WebElement getMenuElement(String menuCaption) { | |||
return getDriver().findElement( | |||
By.xpath("//td[text() = '" + menuCaption + "']")); | |||
} | |||
@Override | |||
protected void selectMenuPath(String... menuCaptions) { | |||
new Actions(getDriver()).moveToElement(getMenuElement(menuCaptions[0])) | |||
.click().perform(); | |||
for (int i = 1; i < menuCaptions.length - 1; ++i) { | |||
selectMenu(menuCaptions[i]); | |||
new Actions(getDriver()).moveByOffset(20, 0).perform(); | |||
} | |||
new Actions(getDriver()) | |||
.moveToElement( | |||
getMenuElement(menuCaptions[menuCaptions.length - 1])) | |||
.click().perform(); | |||
} | |||
@Override | |||
protected GridElement getGridElement() { | |||
if (composite) { |
@@ -19,6 +19,7 @@ import java.util.ArrayList; | |||
import java.util.List; | |||
import org.openqa.selenium.By; | |||
import org.openqa.selenium.Dimension; | |||
import org.openqa.selenium.JavascriptExecutor; | |||
import org.openqa.selenium.WebDriver; | |||
import org.openqa.selenium.WebElement; | |||
@@ -42,21 +43,32 @@ public abstract class GridBasicFeaturesTest extends MultiBrowserTest { | |||
return GridBasicFeatures.class; | |||
} | |||
protected void selectSubMenu(String menuCaption) { | |||
selectMenu(menuCaption); | |||
new Actions(getDriver()).moveByOffset(100, 0).build().perform(); | |||
protected void selectMenu(String menuCaption) { | |||
selectMenu(menuCaption, true); | |||
} | |||
protected void selectMenu(String menuCaption) { | |||
getDriver().findElement( | |||
By.xpath("//span[text() = '" + menuCaption + "']")).click(); | |||
protected void selectMenu(String menuCaption, boolean click) { | |||
WebElement menuElement = getMenuElement(menuCaption); | |||
Dimension size = menuElement.getSize(); | |||
new Actions(getDriver()).moveToElement(menuElement, size.width - 10, | |||
size.height / 2).perform(); | |||
if (click) { | |||
new Actions(getDriver()).click().perform(); | |||
} | |||
} | |||
protected WebElement getMenuElement(String menuCaption) { | |||
return getDriver().findElement( | |||
By.xpath("//span[text() = '" + menuCaption + "']")); | |||
} | |||
protected void selectMenuPath(String... menuCaptions) { | |||
selectMenu(menuCaptions[0]); | |||
for (int i = 1; i < menuCaptions.length; i++) { | |||
selectSubMenu(menuCaptions[i]); | |||
selectMenu(menuCaptions[0], true); | |||
for (int i = 1; i < menuCaptions.length - 1; i++) { | |||
selectMenu(menuCaptions[i]); | |||
new Actions(getDriver()).moveByOffset(40, 0).build().perform(); | |||
} | |||
selectMenu(menuCaptions[menuCaptions.length - 1], true); | |||
} | |||
protected GridElement getGridElement() { |
@@ -230,7 +230,7 @@ public class GridEditorTest extends GridBasicFeaturesTest { | |||
assertFalse("Exception should not exist", | |||
isElementPresent(NotificationElement.class)); | |||
assertEquals("There should be no editor error message", null, | |||
editor.getErrorMessage()); | |||
getGridElement().getEditor().getErrorMessage()); | |||
} | |||
@Test |
@@ -141,12 +141,12 @@ public class GridSortingTest extends GridBasicFeaturesTest { | |||
// String. | |||
// Click header twice to sort descending | |||
GridCellElement header = grid.getHeaderCell(0, 9); | |||
header.click(); | |||
clickHeader(grid.getHeaderCell(0, 9)); | |||
assertLastSortIsUserOriginated(true); | |||
assertColumnsAreSortedAs(_(9, 1, SortDirection.ASCENDING)); | |||
grid.getHeaderCell(0, 9).click(); | |||
clickHeader(grid.getHeaderCell(0, 9)); | |||
assertColumnsAreSortedAs(_(9, 1, SortDirection.DESCENDING)); | |||
// First cells for first 3 rows are (9, 0), (99, 0) and (999, 0) | |||
@@ -163,7 +163,7 @@ public class GridSortingTest extends GridBasicFeaturesTest { | |||
"Auto"); | |||
// Column 10 is random numbers from Random with seed 13334 | |||
// Click header to sort ascending | |||
grid.getHeaderCell(0, 10).click(); | |||
clickHeader(grid.getHeaderCell(0, 10)); | |||
assertColumnsAreSortedAs(_(10, 1, SortDirection.ASCENDING)); | |||
for (int i = 0; i < 5; ++i) { | |||
@@ -181,9 +181,9 @@ public class GridSortingTest extends GridBasicFeaturesTest { | |||
// Column 7 is row index as a number. Last three row are original rows | |||
// 2, 1 and 0. | |||
// Click header twice to sort descending | |||
grid.getHeaderCell(0, 7).click(); | |||
clickHeader(grid.getHeaderCell(0, 7)); | |||
assertColumnsAreSortedAs(_(7, 1, SortDirection.ASCENDING)); | |||
grid.getHeaderCell(0, 7).click(); | |||
clickHeader(grid.getHeaderCell(0, 7)); | |||
assertColumnsAreSortedAs(_(7, 1, SortDirection.DESCENDING)); | |||
for (int i = 0; i < 3; ++i) { | |||
@@ -195,6 +195,11 @@ public class GridSortingTest extends GridBasicFeaturesTest { | |||
} | |||
private void clickHeader(GridCellElement headerCell) { | |||
new Actions(getDriver()).moveToElement(headerCell, 5, 5).click() | |||
.perform(); | |||
} | |||
private void sendKey(Keys seq) { | |||
new Actions(getDriver()).sendKeys(seq).perform(); | |||
} |