]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add a dummy GridElement and use it in GridBasicFeaturesTest (#13334)
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Tue, 20 May 2014 14:25:39 +0000 (17:25 +0300)
committerVaadin Code Review <review@vaadin.com>
Fri, 23 May 2014 05:48:02 +0000 (05:48 +0000)
Change-Id: I729d906a14da66f5a4827ccbaa48762d69ebbe11

uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java
uitest/src/com/vaadin/tests/components/grid/GridElement.java [new file with mode: 0644]

index 0f4a899750af8b01a8c8d886db8337935ee5e2ee..ac1951242c2a092ae23bc50fbacce2408bd069a9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
@@ -25,7 +25,6 @@ import java.util.List;
 import org.junit.Test;
 import org.openqa.selenium.By;
 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;
@@ -269,13 +268,13 @@ public class GridBasicFeaturesTest extends MultiBrowserTest {
 
         final By newRow = By.xpath("//td[text()='newcell: 0']");
 
-        assertTrue("Unexpected initial state", !elementIsFound(newRow));
+        assertTrue("Unexpected initial state", !isElementPresent(newRow));
 
         selectMenuPath("Component", "Body rows", "Add first row");
-        assertTrue("Add row failed", elementIsFound(newRow));
+        assertTrue("Add row failed", isElementPresent(newRow));
 
         selectMenuPath("Component", "Body rows", "Remove first row");
-        assertTrue("Remove row failed", !elementIsFound(newRow));
+        assertTrue("Remove row failed", !isElementPresent(newRow));
     }
 
     /**
@@ -300,14 +299,6 @@ public class GridBasicFeaturesTest extends MultiBrowserTest {
                 "modified: Column0", getBodyCellByRowAndColumn(1, 1).getText());
     }
 
-    private boolean elementIsFound(By locator) {
-        try {
-            return driver.findElement(locator) != null;
-        } catch (NoSuchElementException e) {
-            return false;
-        }
-    }
-
     private void assertPrimaryStylename(String stylename) {
         assertTrue(getGridElement().getAttribute("class").contains(stylename));
 
@@ -348,32 +339,27 @@ public class GridBasicFeaturesTest extends MultiBrowserTest {
     }
 
     private WebElement getVerticalScroller() {
-        return getDriver().findElement(
-                By.xpath("//div[@id='testComponent']/div[1]"));
+        return getGridElement().findElement(By.xpath("./div[1]"));
     }
 
     private WebElement getHorizontalScroller() {
-        return getDriver().findElement(
-                By.xpath("//div[@id='testComponent']/div[2]"));
+        return getGridElement().findElement(By.xpath("./div[2]"));
     }
 
     private WebElement getTableWrapper() {
-        return getDriver().findElement(
-                By.xpath("//div[@id='testComponent']/div[3]"));
+        return getGridElement().findElement(By.xpath("./div[3]"));
     }
 
-    private WebElement getGridElement() {
-        return getDriver().findElement(By.id("testComponent"));
+    private GridElement getGridElement() {
+        return $(GridElement.class).id("testComponent");
     }
 
     private List<WebElement> getGridHeaderRowCells() {
-        return getDriver().findElements(
-                By.xpath("//div[@id='testComponent']//thead//th"));
+        return getGridElement().findElements(By.xpath(".//thead//th"));
     }
 
     private List<WebElement> getGridFooterRowCells() {
-        return getDriver().findElements(
-                By.xpath("//div[@id='testComponent']//tfoot//td"));
+        return getGridElement().findElements(By.xpath(".//tfoot//td"));
     }
 
     private void scrollGridVerticallyTo(double px) {
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridElement.java b/uitest/src/com/vaadin/tests/components/grid/GridElement.java
new file mode 100644 (file)
index 0000000..51e07f6
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid;
+
+import com.vaadin.testbench.elements.AbstractComponentElement;
+import com.vaadin.testbench.elements.ServerClass;
+
+/**
+ * TestBench Element API for Grid
+ * 
+ * @since 7.4
+ * @author Vaadin Ltd
+ */
+@ServerClass("com.vaadin.ui.components.grid.Grid")
+public class GridElement extends AbstractComponentElement {
+
+}