Our app uses Tapestry 5.3.8, and Selenium 2.53.1 for integration tests.
There are times when a Selenium test needs to wait for an action to complete, such as when Tapestry initiates an AJAX request. In such cases, the following code is used to wait for the completion of the AJAX request:
new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>()
{
@Override
public Boolean apply(final WebDriver webDriver)
{
String js = "return window.Ajax.activeRequestCount";
Long count = (Long) ((JavascriptExecutor) webDriver).executeScript(js);
return count.longValue() == 0;
}
});
Now, let's examine this snippet from a Tapestry template:
<t:formfragment t:id="repeatedDate" element="fieldset" show="show" hide="fade" visible="dateRepeated">
...
</t:formfragment>
...
<t:checkbox value="dateRepeated" t:mixins="triggerfragment" fragment="repeatedDate"/>
When the specified checkbox is selected, the fragment is displayed using the Tapestry effect "show".
Is there a way to wait for this effect to finish in a Selenium test? Essentially, is there a JavaScript expression that returns false
while the effect is still in progress, and true
once it is done?
Thank you.