summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-06-01 15:46:19 +0300
committerTeemu Suo-Anttila <teemusa@vaadin.com>2015-06-02 16:14:34 +0300
commit0349e002b8904e6d91e7d7938cbe085b3501ce0f (patch)
treefb6e46876cf9688529982498bec9ed309d33e294
parent90e75a20bda563f90297840f4feb5668cd524633 (diff)
downloadvaadin-framework-0349e002b8904e6d91e7d7938cbe085b3501ce0f.tar.gz
vaadin-framework-0349e002b8904e6d91e7d7938cbe085b3501ce0f.zip
Refactor MenuBar handling methods to AbstractTB3Test
This patch uses the new menubar handling in AccordionClipsContentTest Change-Id: Ib54b8b7c51b04fb98785af214aebdd33126aa61d
-rw-r--r--uitest/src/com/vaadin/tests/components/accordion/AccordionClipsContentTest.java24
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java29
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java29
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridClientDataSourcesTest.java27
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableDragColumnTest.java17
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java64
6 files changed, 80 insertions, 110 deletions
diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionClipsContentTest.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionClipsContentTest.java
index 25e40e5ed3..b6fa82aa41 100644
--- a/uitest/src/com/vaadin/tests/components/accordion/AccordionClipsContentTest.java
+++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionClipsContentTest.java
@@ -15,9 +15,10 @@
*/
package com.vaadin.tests.components.accordion;
+import org.junit.Test;
+
import com.vaadin.testbench.elements.NativeButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
-import org.junit.Test;
public class AccordionClipsContentTest extends MultiBrowserTest {
@Override
@@ -29,21 +30,8 @@ public class AccordionClipsContentTest extends MultiBrowserTest {
public void testAccordionClipsContent() throws Exception {
openTestURL();
- /*
- * MenuBarElement doesn't have any API, so this part is ugly until
- * #13364 is fixed
- */
-
- // Component
- vaadinElement("PID_Smenu#item0").click();
- // Component container features
- clickAt("Root/VOverlay[0]/VMenuBar[0]#item3", 136, 8);
- // Add component
- clickAt("Root/VOverlay[1]/VMenuBar[0]#item0", 65, 4);
- // NativeButton
- clickAt("Root/VOverlay[2]/VMenuBar[0]#item1", 86, 2);
- // autoxauto
- vaadinElement("Root/VOverlay[3]/VMenuBar[0]#item0").click();
+ selectMenuPath("Component", "Component container features",
+ "Add component", "NativeButton", "auto x auto");
$(NativeButtonElement.class).first().click();
@@ -54,8 +42,4 @@ public class AccordionClipsContentTest extends MultiBrowserTest {
compareScreen("button-clicked");
}
-
- private void clickAt(String vaadinLocator, int x, int y) {
- testBenchElement(vaadinElement(vaadinLocator)).click(x, y);
- }
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java
index c1b8028cbf..517f657c62 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java
@@ -22,10 +22,8 @@ import static org.junit.Assert.fail;
import java.util.List;
import org.openqa.selenium.By;
-import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.parallel.TestCategory;
@@ -204,29 +202,16 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
return null;
}
+ @Override
protected void selectMenu(String menuCaption) {
- TestBenchElement menuElement = getMenuElement(menuCaption);
- Dimension size = menuElement.getSize();
- new Actions(getDriver()).moveToElement(menuElement, size.width - 10,
- size.height / 2).perform();
- }
-
- private TestBenchElement getMenuElement(String menuCaption) {
- return (TestBenchElement) findElement(By.xpath("//td[text() = '"
- + menuCaption + "']"));
+ // GWT menu does not need to be clicked.
+ selectMenu(menuCaption, false);
}
- 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 WebElement getMenuElement(String menuCaption) {
+ return getDriver().findElement(
+ By.xpath("//td[text() = '" + menuCaption + "']"));
}
protected void assertLogContains(String substring) {
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java
index aea2892e3e..a0eb8dfefe 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java
@@ -22,7 +22,6 @@ 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;
@@ -51,34 +50,6 @@ public abstract class GridBasicFeaturesTest extends MultiBrowserTest {
return GridBasicFeatures.class;
}
- protected void selectMenu(String menuCaption) {
- selectMenu(menuCaption, true);
- }
-
- 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], 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 CustomGridElement getGridElement() {
return ((TestBenchElement) findElement(By.id("testComponent")))
.wrap(CustomGridElement.class);
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridClientDataSourcesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridClientDataSourcesTest.java
index fb12178c9b..c406f85c0c 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridClientDataSourcesTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridClientDataSourcesTest.java
@@ -21,11 +21,9 @@ import static org.junit.Assert.assertNull;
import org.junit.Before;
import org.junit.Test;
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;
-import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@@ -152,29 +150,16 @@ public class GridClientDataSourcesTest extends MultiBrowserTest {
+ "\"v-grid-scroller-vertical\")]"));
}
- private void selectMenu(String menuCaption) {
- WebElement menuElement = getMenuElement(menuCaption);
- Dimension size = menuElement.getSize();
- new Actions(getDriver()).moveToElement(menuElement, size.width - 10,
- size.height / 2).perform();
+ @Override
+ protected void selectMenu(String menuCaption) {
+ // 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 + "']"));
}
- private 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();
- }
-
}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableDragColumnTest.java b/uitest/src/com/vaadin/tests/components/table/TableDragColumnTest.java
index cb7c6a070e..bd2d2ad28b 100644
--- a/uitest/src/com/vaadin/tests/components/table/TableDragColumnTest.java
+++ b/uitest/src/com/vaadin/tests/components/table/TableDragColumnTest.java
@@ -102,21 +102,4 @@ public class TableDragColumnTest extends MultiBrowserTest {
new Actions(getDriver()).release().perform();
}
-
- protected void selectSubMenu(String menuCaption) {
- selectMenu(menuCaption);
- new Actions(getDriver()).moveByOffset(100, 0).build().perform();
- }
-
- protected void selectMenu(String menuCaption) {
- getDriver().findElement(
- By.xpath("//span[text() = '" + menuCaption + "']")).click();
- }
-
- protected void selectMenuPath(String... menuCaptions) {
- selectMenu(menuCaptions[0]);
- for (int i = 1; i < menuCaptions.length; i++) {
- selectSubMenu(menuCaptions[i]);
- }
- }
}
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index ddf90b080b..7b77aaf817 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -26,7 +26,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
-import java.util.NoSuchElementException;
import java.util.Set;
import java.util.logging.Level;
@@ -40,9 +39,12 @@ import org.junit.Assert;
import org.junit.Rule;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
+import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.HasInputDevices;
import org.openqa.selenium.interactions.Keyboard;
import org.openqa.selenium.interactions.Mouse;
@@ -976,4 +978,64 @@ public abstract class AbstractTB3Test extends ParallelTest {
}
});
}
+
+ /**
+ * Selects a menu item. By default, this will click on the menu item.
+ *
+ * @param menuCaption
+ * caption of the menu item
+ */
+ protected void selectMenu(String menuCaption) {
+ selectMenu(menuCaption, true);
+ }
+
+ /**
+ * Selects a menu item.
+ *
+ * @param menuCaption
+ * caption of the menu item
+ * @param click
+ * <code>true</code> if should click the menu item;
+ * <code>false</code> if not
+ */
+ 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();
+ }
+ }
+
+ /**
+ * Finds the menu item from the DOM based on menu item caption.
+ *
+ * @param menuCaption
+ * caption of the menu item
+ * @return the found menu item
+ * @throws NoSuchElementException
+ * if menu item is not found
+ */
+ protected WebElement getMenuElement(String menuCaption)
+ throws NoSuchElementException {
+ return getDriver().findElement(
+ By.xpath("//span[text() = '" + menuCaption + "']"));
+ }
+
+ /**
+ * Selects a submenu described by a path of menus from the first MenuBar in
+ * the UI.
+ *
+ * @param menuCaptions
+ * array of menu captions
+ */
+ protected void selectMenuPath(String... menuCaptions) {
+ 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);
+ }
}