HTMLUnit : super slow execution?

前端 未结 3 734
情深已故
情深已故 2020-12-30 09:34

I have been using HTMLUnit . It suits my requirements well. But it seems to be extremely slow. for example : I have automated the following scenario using HTMLUnit



        
3条回答
  •  孤城傲影
    2020-12-30 10:00

    For the current htmlUnit 2.13, setting options is slightly different from what maxmax has provided:

    final WebClient webClient = new WebClient(BrowserVersion.CHROME);
    webClient.getOptions().setCssEnabled(false);//if you don't need css
    webClient.getOptions().setJavaScriptEnabled(false);//if you don't need js
    HtmlPage page = webClient.getPage("http://XXX.xxx.xx");
    ...
    

    In my own test, this is 8 times faster than the default options.(Note that this could be webpage-dependent)

提交回复
热议问题