aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-09-04 15:05:27 +0300
committerArtur Signell <artur@vaadin.com>2015-09-04 15:05:27 +0300
commitf46be1b2792755cb7d9b111068dd6cf202398c4a (patch)
tree74f7098faee688cc1f1ca1b6ffe9e912338bbcaf /uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
parente603ea3cf91e5dd0893b766f27d400947527fba9 (diff)
parentebceef4d44bcd61605fa92fcf7be8d3678537599 (diff)
downloadvaadin-framework-f46be1b2792755cb7d9b111068dd6cf202398c4a.tar.gz
vaadin-framework-f46be1b2792755cb7d9b111068dd6cf202398c4a.zip
Merge remote-tracking branch 'origin/master' into reconnect-dialog
Change-Id: Ie622160a83116c83b255a26bec297f73f3223ac7
Diffstat (limited to 'uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java')
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java92
1 files changed, 91 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index 665f1668b2..a58575890e 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -51,6 +51,7 @@ import org.openqa.selenium.interactions.Keyboard;
import org.openqa.selenium.interactions.Mouse;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.Locatable;
+import org.openqa.selenium.internal.WrapsElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.HttpCommandExecutor;
import org.openqa.selenium.remote.RemoteWebDriver;
@@ -384,7 +385,7 @@ public abstract class AbstractTB3Test extends ParallelTest {
* @return
*/
public WebElement vaadinElementById(String id) {
- return driver.findElement(vaadinLocatorById(id));
+ return driver.findElement(By.id(id));
}
/**
@@ -1118,4 +1119,93 @@ public abstract class AbstractTB3Test extends ParallelTest {
return isElementPresent(By.className("v-debugwindow"));
}
+ protected void assertNoHorizontalScrollbar(WebElement element,
+ String errorMessage) {
+ // IE rounds clientWidth/clientHeight down and scrollHeight/scrollWidth
+ // up, so using clientWidth/clientHeight will fail if the element height
+ // is not an integer
+ int clientWidth = getClientWidth(element);
+ int scrollWidth = getScrollWidth(element);
+ boolean hasScrollbar = scrollWidth > clientWidth;
+
+ Assert.assertFalse(
+ "The element should not have a horizontal scrollbar (scrollWidth: "
+ + scrollWidth + ", clientWidth: " + clientWidth + "): "
+ + errorMessage, hasScrollbar);
+ }
+
+ protected void assertNoVerticalScrollbar(WebElement element,
+ String errorMessage) {
+ // IE rounds clientWidth/clientHeight down and scrollHeight/scrollWidth
+ // up, so using clientWidth/clientHeight will fail if the element height
+ // is not an integer
+ int clientHeight = getClientHeight(element);
+ int scrollHeight = getScrollHeight(element);
+ boolean hasScrollbar = scrollHeight > clientHeight;
+
+ Assert.assertFalse(
+ "The element should not have a vertical scrollbar (scrollHeight: "
+ + scrollHeight + ", clientHeight: " + clientHeight
+ + "): " + errorMessage, hasScrollbar);
+ }
+
+ protected int getScrollHeight(WebElement element) {
+ return ((Number) executeScript("return arguments[0].scrollHeight;",
+ element)).intValue();
+ }
+
+ protected int getScrollWidth(WebElement element) {
+ return ((Number) executeScript("return arguments[0].scrollWidth;",
+ element)).intValue();
+ }
+
+ /**
+ * Returns client height rounded up instead of as double because of IE9
+ * issues: https://dev.vaadin.com/ticket/18469
+ */
+ protected int getClientHeight(WebElement e) {
+ String script;
+ if (BrowserUtil.isIE8(getDesiredCapabilities())) {
+ script = "return arguments[0].clientHeight;"; //
+ } else {
+ script = "var cs = window.getComputedStyle(arguments[0]);"
+ + "return Math.ceil(parseFloat(cs.height)+parseFloat(cs.paddingTop)+parseFloat(cs.paddingBottom));";
+ }
+ return ((Number) executeScript(script, e)).intValue();
+ }
+
+ /**
+ * Returns client width rounded up instead of as double because of IE9
+ * issues: https://dev.vaadin.com/ticket/18469
+ */
+ protected int getClientWidth(WebElement e) {
+ String script;
+ if (BrowserUtil.isIE8(getDesiredCapabilities())) {
+ script = "return arguments[0].clientWidth;";
+ } else {
+ script = "var cs = window.getComputedStyle(arguments[0]);"
+ + "var h = parseFloat(cs.width)+parseFloat(cs.paddingLeft)+parseFloat(cs.paddingRight);"
+ + "return Math.ceil(h);";
+ }
+
+ return ((Number) executeScript(script, e)).intValue();
+ }
+
+ protected void assertElementsEquals(WebElement expectedElement,
+ WebElement actualElement) {
+ while (expectedElement instanceof WrapsElement) {
+ expectedElement = ((WrapsElement) expectedElement)
+ .getWrappedElement();
+ }
+ while (actualElement instanceof WrapsElement) {
+ actualElement = ((WrapsElement) actualElement).getWrappedElement();
+ }
+
+ Assert.assertEquals(expectedElement, actualElement);
+ }
+
+ protected WebElement getActiveElement() {
+ return (WebElement) executeScript("return document.activeElement;");
+
+ }
}