aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2014-12-02 15:31:46 +0200
committerVaadin Code Review <review@vaadin.com>2014-12-03 11:22:50 +0000
commit33c2cb153cc26ed664af93440b4260e9c9ad9dee (patch)
tree358af0b88f7983bbd4cea5eec7365287958edc79 /uitest/src
parentefae54d2159de0d609e2a314929405426017ca9e (diff)
downloadvaadin-framework-33c2cb153cc26ed664af93440b4260e9c9ad9dee.tar.gz
vaadin-framework-33c2cb153cc26ed664af93440b4260e9c9ad9dee.zip
Fix Escalator testing with assert enabled on PhantomJS (#13334)
Change-Id: I6a5eb39c44873932bdde3a229f7ed52bc7c4df8c
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java88
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorBasicsTest.java (renamed from uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicsTest.java)7
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorColspanTest.java (renamed from uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorColspanTest.java)4
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorColumnFreezingTest.java (renamed from uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorColumnFreezingTest.java)10
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRowColumnTest.java (renamed from uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorRowColumnTest.java)11
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorScrollTest.java (renamed from uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorScrollTest.java)4
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorUpdaterUiTest.java (renamed from uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorUpdaterUiTest.java)5
7 files changed, 71 insertions, 58 deletions
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 31a142d556..0b2a7a7358 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java
@@ -22,14 +22,14 @@ import static org.junit.Assert.fail;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
-import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
+import com.vaadin.testbench.TestBenchElement;
import com.vaadin.tests.annotations.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
-@TestCategory("grid")
+@TestCategory("escalator")
public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest {
protected static final String COLUMNS_AND_ROWS = "Columns and Rows";
@@ -69,12 +69,12 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
return EscalatorBasicClientFeatures.class;
}
- protected WebElement getEscalator() {
- try {
- return getDriver().findElement(By.className("v-escalator"));
- } catch (NoSuchElementException e) {
- return null;
+ protected TestBenchElement getEscalator() {
+ By className = By.className("v-escalator");
+ if (isElementPresent(className)) {
+ return (TestBenchElement) findElement(className);
}
+ return null;
}
/**
@@ -83,7 +83,7 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
* calculation starts from the end (-1 is the last, -2 is the
* second-to-last etc)
*/
- protected WebElement getHeaderRow(int row) {
+ protected TestBenchElement getHeaderRow(int row) {
return getRow("thead", row);
}
@@ -93,7 +93,7 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
* calculation starts from the end (-1 is the last, -2 is the
* second-to-last etc)
*/
- protected WebElement getBodyRow(int row) {
+ protected TestBenchElement getBodyRow(int row) {
return getRow("tbody", row);
}
@@ -103,7 +103,7 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
* calculation starts from the end (-1 is the last, -2 is the
* second-to-last etc)
*/
- protected WebElement getFooterRow(int row) {
+ protected TestBenchElement getFooterRow(int row) {
return getRow("tfoot", row);
}
@@ -113,7 +113,7 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
* calculation starts from the end (-1 is the last, -2 is the
* second-to-last etc)
*/
- protected WebElement getHeaderCell(int row, int col) {
+ protected TestBenchElement getHeaderCell(int row, int col) {
return getCell("thead", row, col);
}
@@ -123,7 +123,7 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
* calculation starts from the end (-1 is the last, -2 is the
* second-to-last etc)
*/
- protected WebElement getBodyCell(int row, int col) {
+ protected TestBenchElement getBodyCell(int row, int col) {
return getCell("tbody", row, col);
}
@@ -133,7 +133,7 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
* calculation starts from the end (-1 is the last, -2 is the
* second-to-last etc)
*/
- protected WebElement getFooterCell(int row, int col) {
+ protected TestBenchElement getFooterCell(int row, int col) {
return getCell("tfoot", row, col);
}
@@ -143,17 +143,13 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
* calculation starts from the end (-1 is the last, -2 is the
* second-to-last etc)
*/
- private WebElement getCell(String sectionTag, int row, int col) {
- WebElement rowElement = getRow(sectionTag, row);
- if (rowElement != null) {
- try {
- return rowElement.findElement(By.xpath("*[" + (col + 1) + "]"));
- } catch (NoSuchElementException e) {
- return null;
- }
- } else {
- return null;
+ private TestBenchElement getCell(String sectionTag, int row, int col) {
+ TestBenchElement rowElement = getRow(sectionTag, row);
+ By xpath = By.xpath("*[" + (col + 1) + "]");
+ if (rowElement != null && rowElement.isElementPresent(xpath)) {
+ return (TestBenchElement) rowElement.findElement(xpath);
}
+ return null;
}
/**
@@ -162,35 +158,35 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
* calculation starts from the end (-1 is the last, -2 is the
* second-to-last etc)
*/
- private WebElement getRow(String sectionTag, int row) {
- WebElement escalator = getEscalator();
+ private TestBenchElement getRow(String sectionTag, int row) {
+ TestBenchElement escalator = getEscalator();
WebElement tableSection = escalator.findElement(By.tagName(sectionTag));
+ By xpath;
- try {
- if (row >= 0) {
- int fromFirst = row + 1;
- return tableSection.findElement(By.xpath("tr[" + fromFirst
- + "]"));
- } else {
- int fromLast = Math.abs(row + 1);
- return tableSection.findElement(By.xpath("tr[last() - "
- + fromLast + "]"));
- }
- } catch (NoSuchElementException e) {
- return null;
+ if (row >= 0) {
+ int fromFirst = row + 1;
+ xpath = By.xpath("tr[" + fromFirst + "]");
+ } else {
+ int fromLast = Math.abs(row + 1);
+ xpath = By.xpath("tr[last() - " + fromLast + "]");
+ }
+ if (tableSection != null
+ && ((TestBenchElement) tableSection).isElementPresent(xpath)) {
+ return (TestBenchElement) tableSection.findElement(xpath);
}
+ return null;
}
protected void selectMenu(String menuCaption) {
- WebElement menuElement = getMenuElement(menuCaption);
+ TestBenchElement menuElement = getMenuElement(menuCaption);
Dimension size = menuElement.getSize();
new Actions(getDriver()).moveToElement(menuElement, size.width - 10,
size.height / 2).perform();
}
- private WebElement getMenuElement(String menuCaption) {
- return getDriver().findElement(
- By.xpath("//td[text() = '" + menuCaption + "']"));
+ private TestBenchElement getMenuElement(String menuCaption) {
+ return (TestBenchElement) findElement(By.xpath("//td[text() = '"
+ + menuCaption + "']"));
}
protected void selectMenuPath(String... menuCaptions) {
@@ -217,7 +213,7 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
}
private String getLogText() {
- WebElement log = getDriver().findElement(By.cssSelector("#log"));
+ WebElement log = findElement(By.cssSelector("#log"));
return log.getText();
}
@@ -240,8 +236,8 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
executeScript("arguments[0].scrollTop = " + px, getVeticalScrollbar());
}
- private WebElement getVeticalScrollbar() {
- return getEscalator().findElement(
+ private TestBenchElement getVeticalScrollbar() {
+ return (TestBenchElement) getEscalator().findElement(
By.className("v-escalator-scroller-vertical"));
}
@@ -250,8 +246,8 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
getHorizontalScrollbar());
}
- private WebElement getHorizontalScrollbar() {
- return getEscalator().findElement(
+ private TestBenchElement getHorizontalScrollbar() {
+ return (TestBenchElement) getEscalator().findElement(
By.className("v-escalator-scroller-horizontal"));
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicsTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorBasicsTest.java
index bac5c24fbe..95ed6ab3ff 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicsTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorBasicsTest.java
@@ -13,14 +13,17 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.tests.components.grid.basicfeatures;
+package com.vaadin.tests.components.grid.basicfeatures.escalator;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import java.io.IOException;
+
import org.junit.Test;
import com.vaadin.testbench.elements.NotificationElement;
+import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
public class EscalatorBasicsTest extends EscalatorBasicClientFeaturesTest {
@@ -34,7 +37,7 @@ public class EscalatorBasicsTest extends EscalatorBasicClientFeaturesTest {
}
@Test
- public void testDetachingASemiPopulatedEscalator() {
+ public void testDetachingASemiPopulatedEscalator() throws IOException {
setDebug(true);
openTestURL();
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorColspanTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorColspanTest.java
index 3c3e16e65a..01247e31f7 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorColspanTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorColspanTest.java
@@ -13,13 +13,15 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.tests.components.grid.basicfeatures;
+package com.vaadin.tests.components.grid.basicfeatures.escalator;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.openqa.selenium.WebElement;
+import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
+
public class EscalatorColspanTest extends EscalatorBasicClientFeaturesTest {
private static final int NO_COLSPAN = 1;
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorColumnFreezingTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorColumnFreezingTest.java
index 2ea0d8638b..6b9e36b235 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorColumnFreezingTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorColumnFreezingTest.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.tests.components.grid.basicfeatures;
+package com.vaadin.tests.components.grid.basicfeatures.escalator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -25,6 +25,8 @@ import java.util.regex.Pattern;
import org.junit.Test;
import org.openqa.selenium.WebElement;
+import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
+
public class EscalatorColumnFreezingTest extends
EscalatorBasicClientFeaturesTest {
@@ -42,12 +44,12 @@ public class EscalatorColumnFreezingTest extends
+ "\\((\\d+)px,"
// any end of the string
- + ".*");
+ + ".*", Pattern.CASE_INSENSITIVE);
// @formatter:on
- private final static Pattern LEFT_PATTERN = Pattern
- .compile(".*left: (\\d+)px.*");
+ private final static Pattern LEFT_PATTERN = Pattern.compile(
+ ".*left: (\\d+)px.*", Pattern.CASE_INSENSITIVE);
private static final int NO_FREEZE = -1;
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorRowColumnTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRowColumnTest.java
index 831524b4fb..392a901463 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorRowColumnTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRowColumnTest.java
@@ -13,16 +13,19 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.tests.components.grid.basicfeatures;
+package com.vaadin.tests.components.grid.basicfeatures.escalator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.By;
+import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
+
public class EscalatorRowColumnTest extends EscalatorBasicClientFeaturesTest {
/**
@@ -175,7 +178,8 @@ public class EscalatorRowColumnTest extends EscalatorBasicClientFeaturesTest {
scrollVerticallyTo(2000); // more like 1857, but this should be enough.
// if not found, an exception is thrown here
- findElement(By.xpath("//td[text()='Cell: 9,99']"));
+ assertTrue("Wanted cell was not visible",
+ isElementPresent(By.xpath("//td[text()='Cell: 9,99']")));
}
@Test
@@ -186,7 +190,8 @@ public class EscalatorRowColumnTest extends EscalatorBasicClientFeaturesTest {
scrollVerticallyTo(2000); // more like 1857, but this should be enough.
// if not found, an exception is thrown here
- findElement(By.xpath("//td[text()='Cell: 9,99']"));
+ assertTrue("Wanted cell was not visible",
+ isElementPresent(By.xpath("//td[text()='Cell: 9,99']")));
}
@Test
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorScrollTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorScrollTest.java
index d2be88b557..91527504a5 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorScrollTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorScrollTest.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.tests.components.grid.basicfeatures;
+package com.vaadin.tests.components.grid.basicfeatures.escalator;
import static org.junit.Assert.assertEquals;
@@ -21,6 +21,8 @@ import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
+import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
+
public class EscalatorScrollTest extends EscalatorBasicClientFeaturesTest {
/**
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorUpdaterUiTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorUpdaterUiTest.java
index c1c3a31b77..85d3fc0bac 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorUpdaterUiTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorUpdaterUiTest.java
@@ -13,10 +13,13 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.tests.components.grid.basicfeatures;
+package com.vaadin.tests.components.grid.basicfeatures.escalator;
import org.junit.Test;
+import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
+import com.vaadin.tests.components.grid.basicfeatures.EscalatorUpdaterUi;
+
public class EscalatorUpdaterUiTest extends EscalatorBasicClientFeaturesTest {
@Override
protected Class<?> getUIClass() {