[HtmlUnit] [htmlunit:bugs] #2016 JavaScript taking way too long time

RBRi via HtmlUnit-develop <[email protected]> Wed, 29 May 2019 18:59:31 -0000
Newsgroups gmane.comp.java.htmlunit.devel
Message-ID </p/htmlunit/bugs/2016/52c6a6587f642038813dcb05c28c23278eb948a5.bugs@htmlunit.p.sourceforge.net>
This is a multi-part message in MIME format.
--===============3680270029677733219==
Content-Type: multipart/related;
 boundary="===============2711612986645239760=="

This is a multi-part message in MIME format.
--===============2711612986645239760==
Content-Type: multipart/alternative;
 boundary="===============0465997146540911419=="
MIME-Version: 1.0

--===============0465997146540911419==
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

Without a concret URL it is  a bit tricky to analyze the problem.

But two points

1. waitForBackgroundJavaScript / waitForBackgroundJavaScriptStartingBefore are not options. You have to call these methods after every action that might trigger js (e.g. openUrl). 
2. do not set the AjaxController if there is no real need.

If you can provide a real complet sample i will have a look.


---

** [bugs:#2016] JavaScript taking way too long time**

**Status:** open
**Group:** 2.35.0
**Labels:** javascript performance long time 
**Created:** Wed May 29, 2019 10:15 AM UTC by Abhishek Thakur
**Last Updated:** Wed May 29, 2019 10:25 AM UTC
**Owner:** nobody


Hi There,

I am new to HtmlUnit and I am using this library to login/geo login with postcodes to different websites. I am able to login to websites but it is taking way too long(up to 5 mins). I need to have Javascript enabled to download the forms asyncronously.

I am using below webclient configuration

    WebClient webClient = new WebClient(BrowserVersion.CHROME);

    WebClientOptions webClientOption = webClient.getOptions();
    webClientOption.setCssEnabled(false);
    webClientOption.setJavaScriptEnabled(true);
    webClientOption.setUseInsecureSSL(true);
    webClientOption.setTimeout(30000);
    webClientOption.setThrowExceptionOnScriptError(false);
    webClientOption.setThrowExceptionOnFailingStatusCode(false);
    webClientOption.setUseInsecureSSL(true);
    webClientOption.setActiveXNative(true);
    webClientOption.setAppletEnabled(true);
    webClientOption.setPopupBlockerEnabled(false);
    webClientOption.setRedirectEnabled(true);

    webClient.waitForBackgroundJavaScript(30000);
    webClient.waitForBackgroundJavaScriptStartingBefore(10000);
    webClient.setJavaScriptTimeout(30000);
    webClient.getCookieManager().setCookiesEnabled(true);
    webClient.setAjaxController(new NicelyResynchronizingAjaxController());

      JavaScriptEngine scriptEngine = (JavaScriptEngine) webClient.getJavaScriptEngine();
    HtmlUnitContextFactory factory = scriptEngine.getContextFactory();
    Context context = factory.enterContext();
    context.setOptimizationLevel(9);

   This is happening with almost all the website I am trying to login. Any help in improving the time to run javascript will be greatly appreciated.

   Regards,
   Abhishek Thakur


---

Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/htmlunit/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
--===============0465997146540911419==
MIME-Version: 1.0
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: 7bit

<div class="markdown_content"><p>Without a concret URL it is  a bit tricky to analyze the problem.</p>
<p>But two points</p>
<ol>
<li>waitForBackgroundJavaScript / waitForBackgroundJavaScriptStartingBefore are not options. You have to call these methods after every action that might trigger js (e.g. openUrl). </li>
<li>do not set the AjaxController if there is no real need.</li>
</ol>
<p>If you can provide a real complet sample i will have a look.</p>
<hr/>
<p><strong> <a class="alink" href="https://sourceforge.net/p/htmlunit/bugs/2016/">[bugs:#2016]</a> JavaScript taking way too long time</strong></p>
<p><strong>Status:</strong> open<br/>
<strong>Group:</strong> 2.35.0<br/>
<strong>Labels:</strong> javascript performance long time <br/>
<strong>Created:</strong> Wed May 29, 2019 10:15 AM UTC by Abhishek Thakur<br/>
<strong>Last Updated:</strong> Wed May 29, 2019 10:25 AM UTC<br/>
<strong>Owner:</strong> nobody</p>
<p>Hi There,</p>
<p>I am new to HtmlUnit and I am using this library to login/geo login with postcodes to different websites. I am able to login to websites but it is taking way too long(up to 5 mins). I need to have Javascript enabled to download the forms asyncronously.</p>
<p>I am using below webclient configuration</p>
<div class="codehilite"><pre><span></span>WebClient webClient = new WebClient(BrowserVersion.CHROME);

WebClientOptions webClientOption = webClient.getOptions();
webClientOption.setCssEnabled(false);
webClientOption.setJavaScriptEnabled(true);
webClientOption.setUseInsecureSSL(true);
webClientOption.setTimeout(30000);
webClientOption.setThrowExceptionOnScriptError(false);
webClientOption.setThrowExceptionOnFailingStatusCode(false);
webClientOption.setUseInsecureSSL(true);
webClientOption.setActiveXNative(true);
webClientOption.setAppletEnabled(true);
webClientOption.setPopupBlockerEnabled(false);
webClientOption.setRedirectEnabled(true);

webClient.waitForBackgroundJavaScript(30000);
webClient.waitForBackgroundJavaScriptStartingBefore(10000);
webClient.setJavaScriptTimeout(30000);
webClient.getCookieManager().setCookiesEnabled(true);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());

  JavaScriptEngine scriptEngine = (JavaScriptEngine) webClient.getJavaScriptEngine();
HtmlUnitContextFactory factory = scriptEngine.getContextFactory();
Context context = factory.enterContext();
context.setOptimizationLevel(9);
</pre></div>


<p>This is happening with almost all the website I am trying to login. Any help in improving the time to run javascript will be greatly appreciated.</p>
<p>Regards,<br/>
   Abhishek Thakur</p>
<hr/>
<p>Sent from sourceforge.net because htmlunit-develop<a class="user-mention" href="https://sourceforge.net/u/lists/">@lists</a>.sourceforge.net is subscribed to <a href="https://sourceforge.net/p/htmlunit/bugs/">https://sourceforge.net/p/htmlunit/bugs/</a></p>
<p>To unsubscribe from further messages, a project admin can change settings at <a href="https://sourceforge.net/p/htmlunit/admin/bugs/options.">https://sourceforge.net/p/htmlunit/admin/bugs/options.</a>  Or, if this is a mailing list, you can unsubscribe from the mailing list.</p></div>
--===============0465997146540911419==--
--===============2711612986645239760==--


--===============3680270029677733219==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============3680270029677733219==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop

--===============3680270029677733219==--