为了编写具有所有适当“等待”的高质量 Selenium 测试,我目前正在强制 Web 应用程序运行得更慢:
public class SlowLoadingFilter implements Filter {
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
throw new ServletException("SlowLoadingFilter sleep failed", e);
}
filterChain.doFilter(servletRequest, servletResponse);
}
我想知道 Tomcat 或 Jetty 是否有合适的方法来做到这一点,或者这是唯一的方法?