我有一个使用远程 webdriver 的 selenium 脚本。我timer.scheduleAtFixedRate(new TimerTask()
用来输出我的数据,但是当我PrintWriter writer = response.getWriter();
用来输出writer.prntln("Testing Started");
时,它在定时器内时不会显示在网页上。但它在定时器之外工作。此外,如果我system.out.println
在计时器内这样做,它也可以工作。
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
int delay = 1000;
int period = 1000;
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask()
{
PrintWriter writer = response.getWriter();
int count = 0;
public void run()
{
//WebDriver actions in here.
}
}, delay, period);