1
我們在我們的應用程序中使用Tapestry 5.3.8。集成測試使用Selenium 2.53.1實現。在JavaScript中等待掛毯效果
有時,硒測試需要等待一些行動,直到它完成。如果Tapestry例如調用AJAX請求,測試將執行以下代碼,直到AJAX請求完成。
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;
}
});
現在,讓我們考慮的Tapestry模板下面的代碼片段:
<t:formfragment t:id="repeatedDate" element="fieldset" show="show" hide="fade" visible="dateRepeated">
...
</t:formfragment>
...
<t:checkbox value="dateRepeated" t:mixins="triggerfragment" fragment="repeatedDate"/>
當適當的複選框被選中的片段出現與掛毯效應「秀」。
有沒有辦法在Selenium測試中等待效果的完成?換句話說,是否有一些JavaScript表達式在效果進行時評估爲false
,並在完成時評估爲true
?
謝謝。