diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2014-03-31 10:44:44 +0300 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-04-01 09:55:31 +0000 |
commit | 1571143b96271b6c41a4f54dab7421cf3e7e085c (patch) | |
tree | b780300fb427d1a5aee47b905e8ca8a0e4d24bea /uitest/src/com/vaadin/tests/layouts | |
parent | d0bc54ba4b487fe461cc950de02ec57187c654ad (diff) | |
download | vaadin-framework-1571143b96271b6c41a4f54dab7421cf3e7e085c.tar.gz vaadin-framework-1571143b96271b6c41a4f54dab7421cf3e7e085c.zip |
Added a button hitting method to AbstractTB3Test.
Refactored LayoutTesterApplicationTest.
Refactored SliderDisableTest.
Change-Id: I038fedb9d234656b85359ce7fb778b001e6f4402
Diffstat (limited to 'uitest/src/com/vaadin/tests/layouts')
-rw-r--r-- | uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java | 32 |
1 files changed, 9 insertions, 23 deletions
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); - } } |