Attempt to fix TapestryBeanValidationIntegrationTests.client_validation
authorThiago H. de Paula Figueiredo <thiago@arsmachina.com.br>
Fri, 23 Nov 2018 14:14:36 +0000 (12:14 -0200)
committerThiago H. de Paula Figueiredo <thiago@arsmachina.com.br>
Fri, 23 Nov 2018 14:14:36 +0000 (12:14 -0200)
in Jeknins

tapestry-beanvalidator/src/test/java/org/apache/tapestry5/beanvalidator/integration/TapestryBeanValidationIntegrationTests.java
tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java

index bfd9999..539b823 100644 (file)
@@ -117,6 +117,7 @@ public class TapestryBeanValidationIntegrationTests extends SeleniumTestCase
         //@NotNull
         click(SUBMIT);
 
+        waitForCssSelectorToAppear("p[data-error-block-for='notNullValue']");
         assertTextPresent("Not Null Value may not be null");
 
         type("notNullValue", "igor");
@@ -126,6 +127,7 @@ public class TapestryBeanValidationIntegrationTests extends SeleniumTestCase
 
         click(SUBMIT);
 
+        waitForCssSelectorToAppear("p[data-error-block-for='minValue']");
         assertTextPresent("Min Value must be greater than or equal to 6");
 
         //@Max
@@ -145,6 +147,7 @@ public class TapestryBeanValidationIntegrationTests extends SeleniumTestCase
 
         click(SUBMIT);
 
+        waitForCssSelectorToAppear("p[data-error-block-for='stringSizeValue']");
         assertTextPresent("String Size Value size must be between 3 and 6");
         
         //@Size(min) TAP5-2158
@@ -154,12 +157,14 @@ public class TapestryBeanValidationIntegrationTests extends SeleniumTestCase
 
         final String stringMinLengthErrorMessage = "String Min Length size must be between 3 and " + Integer.MAX_VALUE;
         
+        waitForCssSelectorToAppear("p[data-error-block-for='stringMinLength']");
                assertTextPresent(stringMinLengthErrorMessage);
         
         type("stringMinLength", "aaaaaa");
 
         click(SUBMIT);
-        
+
+        waitForInvisible("p[data-error-block-for='stringMinLength']");
         assertFalse(isTextPresent(stringMinLengthErrorMessage));
         
         //@Size(max) TAP5-2158
@@ -169,12 +174,14 @@ public class TapestryBeanValidationIntegrationTests extends SeleniumTestCase
 
         final String stringMaxLengthErrorMessage = "String Max Length size must be between 0 and 6";
         
+        waitForCssSelectorToAppear("p[data-error-block-for='stringMaxLength']");
                assertTextPresent(stringMaxLengthErrorMessage);
 
         type("stringMaxLength", "aaaaa");
 
         click(SUBMIT);
 
+        waitForInvisible("p[data-error-block-for='stringMaxLength']");
         assertFalse(isTextPresent(stringMaxLengthErrorMessage));
 
         click(SUBMIT);
@@ -190,8 +197,10 @@ public class TapestryBeanValidationIntegrationTests extends SeleniumTestCase
 
         click(SUBMIT);
 
+        waitForCssSelectorToAppear("p[data-error-block-for='languages']");
         assertTextPresent("Languages size must be between 2 and 3");
 
+        waitForCssSelectorToAppear("p[data-error-block-for='nullValue']");
         assertTextPresent("Null Value must be null");
     }
 
index 34806f8..ab3c0b3 100644 (file)
@@ -1687,6 +1687,21 @@ public abstract class SeleniumTestCase extends Assert implements Selenium
 
         waitForCondition(condition, PAGE_LOAD_TIMEOUT);
     }
+    
+    /**
+     * Waits for an element with a given CSS selector to appear.
+     *
+     * @param selector
+     *         the CSS selector to wait.
+     * @since 5.5
+     */
+    protected final void waitForCssSelectorToAppear(String selector)
+    {
+
+        String condition = String.format("selenium.browserbot.getCurrentWindow().document.querySelector(\"%s\")", selector);
+
+        waitForCondition(condition, PAGE_LOAD_TIMEOUT);
+    }
 
     /**
      * Waits for the element to be removed from the DOM.