aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin
diff options
context:
space:
mode:
authorBuild Agent <build@vaadin.com>2014-04-01 13:12:22 +0300
committerBuild Agent <build@vaadin.com>2014-04-01 13:12:23 +0300
commitdd7f045b89b14e786b2d370044df67fc29ddfc60 (patch)
treecad547396bcd0b6546385898950a78e18395ca78 /uitest/src/com/vaadin
parent7bfb2347ad32187444c194e7ebadae6a6d3597ca (diff)
parent1571143b96271b6c41a4f54dab7421cf3e7e085c (diff)
downloadvaadin-framework-dd7f045b89b14e786b2d370044df67fc29ddfc60.tar.gz
vaadin-framework-dd7f045b89b14e786b2d370044df67fc29ddfc60.zip
Merge changes from origin/7.1
1571143 Added a button hitting method to AbstractTB3Test. Change-Id: Ia294bd09ae143f81a6331b6bec5736b72acfea89
Diffstat (limited to 'uitest/src/com/vaadin')
-rw-r--r--uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java15
-rw-r--r--uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java32
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java8
-rw-r--r--uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java33
4 files changed, 43 insertions, 45 deletions
diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java b/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java
index f8fed28fac..923d0f46ab 100644
--- a/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java
+++ b/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java
@@ -17,6 +17,7 @@ package com.vaadin.tests.components.slider;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import java.io.IOException;
@@ -33,16 +34,16 @@ public class SliderDisableTest extends MultiBrowserTest {
public void disableSlider() throws IOException {
openTestURL();
- assertSliderHandlePositionIs(38);
+ String originalPosition = getSliderHandlePosition();
- // Move slider handle from 38px to 150px
moveSlider(112);
+ String expectedPosition = getSliderHandlePosition();
+ assertThat(expectedPosition, is(not(originalPosition)));
- assertSliderHandlePositionIs(150);
- driver.findElement(By.id("disableButton")).click();
+ hitButton("disableButton");
assertSliderIsDisabled();
- assertSliderHandlePositionIs(150);
+ assertThat(getSliderHandlePosition(), is(expectedPosition));
}
private void assertSliderIsDisabled() {
@@ -56,9 +57,9 @@ public class SliderDisableTest extends MultiBrowserTest {
testBench().waitForVaadin();
}
- private void assertSliderHandlePositionIs(int position) {
+ private String getSliderHandlePosition() {
WebElement handle = driver.findElement(By.className("v-slider-handle"));
- assertThat(handle.getCssValue("margin-left"), is(position + "px"));
+ return handle.getCssValue("margin-left");
}
} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java
index 8996e62503..6ba5109ce7 100644
--- a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java
+++ b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java
@@ -22,11 +22,10 @@ import java.util.Set;
import org.junit.Test;
import org.openqa.selenium.By;
-import org.openqa.selenium.JavascriptExecutor;
-import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.Select;
+import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;
import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
@@ -39,6 +38,7 @@ public class LayoutTesterApplicationTest extends MultiBrowserTest {
DesiredCapabilities cap = new DesiredCapabilities(
super.getDesiredCapabilities());
cap.setCapability("nativeEvents", false);
+
return cap;
}
@@ -86,7 +86,6 @@ public class LayoutTesterApplicationTest extends MultiBrowserTest {
new Select(vaadinElementById("layoutSelect").findElement(
By.xpath("select")))
.selectByVisibleText(layoutClass.toString());
- focusElementWithId("nextButton");
for (String subTest : LayoutTesterApplication.layoutGetters) {
compareScreen(subTest);
@@ -96,23 +95,13 @@ public class LayoutTesterApplicationTest extends MultiBrowserTest {
clickAndCompareScreen(subTest, "testButton" + i);
}
}
- getNextButton().click();
+
+ hitButton("nextButton");
}
}
/**
- * @param elementId
- * the id of the element to focus
- */
- private void focusElementWithId(String elementId) {
- // This should really be in TestBench
- ((JavascriptExecutor) getDriver())
- .executeScript("document.getElementById('" + elementId
- + "').focus()");
- }
-
- /**
* Clicks the button with the given id and compares the result to a
* screenshot named 'screenshotPrefix'-buttonCaption.
*
@@ -122,15 +111,16 @@ public class LayoutTesterApplicationTest extends MultiBrowserTest {
*/
private void clickAndCompareScreen(String screenshotPrefix, String buttonId)
throws Exception {
- WebElement button = vaadinElementById(buttonId);
- button.click();
+ hitButton(buttonId);
+
if (needsDelayToStabilize(screenshotPrefix)) {
// Table does some extra layout phase and TestBench does not always
// take this into account, grabbing screenshots before the layout
// phase is done (see #12866).
- sleep(200);
+ sleep(350);
}
- compareScreen(screenshotPrefix + "-" + sanitize(button.getText()));
+ compareScreen(screenshotPrefix + "-"
+ + sanitize(driver.findElement(By.id(buttonId)).getText()));
}
private boolean needsDelayToStabilize(String screenshotPrefix) {
@@ -140,8 +130,4 @@ public class LayoutTesterApplicationTest extends MultiBrowserTest {
private String sanitize(String text) {
return text.replace("%", "pct").replaceAll("[^a-zA-Z0-9]", "-");
}
-
- private WebElement getNextButton() {
- return vaadinElementById(LayoutTesterApplication.NEXT_BUTTON_ID);
- }
}
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index 55a2b80918..ba5c81e846 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -42,6 +42,7 @@ import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
+import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;
import com.vaadin.server.LegacyApplication;
import com.vaadin.server.UIProvider;
import com.vaadin.testbench.TestBench;
@@ -928,4 +929,11 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
return ((HasInputDevices) getDriver()).getKeyboard();
}
+ public void hitButton(String id) {
+ WebDriverBackedSelenium selenium = new WebDriverBackedSelenium(driver,
+ driver.getCurrentUrl());
+
+ selenium.keyPress("id=" + id, "\\13");
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
index 4ea50cbe29..9e2aa4cb78 100644
--- a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
@@ -101,22 +101,21 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test {
File mainReference = getScreenshotReferenceFile(identifier);
- List<File> alternativeFiles = findReferenceAlternatives(mainReference);
- List<File> failedReferenceAlternatives = new ArrayList<File>();
+ List<File> referenceFiles = findReferenceAndAlternatives(mainReference);
+ List<File> failedReferenceFiles = new ArrayList<File>();
- for (File file : alternativeFiles) {
- if (testBench(driver).compareScreen(file)) {
+ for (File referenceFile : referenceFiles) {
+ if (testBench(driver).compareScreen(referenceFile)) {
+ // There might be failure files because of retries in TestBench.
+ deleteFailureFiles(referenceFile);
break;
} else {
- failedReferenceAlternatives.add(file);
+ failedReferenceFiles.add(referenceFile);
}
}
File referenceToKeep = null;
- if (failedReferenceAlternatives.size() != alternativeFiles.size()) {
- // Matched one comparison but not all, remove all error images +
- // HTML files
- } else {
+ if (failedReferenceFiles.size() == referenceFiles.size()) {
// Ensure we use the correct browser version (e.g. if running IE11
// and only an IE 10 reference was available, then mainReference
// will be for IE 10, not 11)
@@ -143,18 +142,22 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test {
// Remove all PNG/HTML files we no longer need (failed alternative
// references or all error files (PNG/HTML) if comparison succeeded)
- for (File failedAlternative : failedReferenceAlternatives) {
+ for (File failedAlternative : failedReferenceFiles) {
File failurePng = getErrorFileFromReference(failedAlternative);
if (failedAlternative != referenceToKeep) {
// Delete png + HTML
- File failureHtml = htmlFromPng(failurePng);
-
- failurePng.delete();
- failureHtml.delete();
+ deleteFailureFiles(failurePng);
}
}
}
+ private void deleteFailureFiles(File failurePng) {
+ File failureHtml = htmlFromPng(failurePng);
+
+ failurePng.delete();
+ failureHtml.delete();
+ }
+
/**
* Returns a new File which points to a .html file instead of the given .png
* file
@@ -189,7 +192,7 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test {
* @return all references which should be considered when comparing with the
* given files, including the given reference
*/
- private List<File> findReferenceAlternatives(File reference) {
+ private List<File> findReferenceAndAlternatives(File reference) {
List<File> files = new ArrayList<File>();
files.add(reference);