lundi 27 juin 2016

htmlunit javascript don't loading

i'm trying to get the content of a page in my local network with htmlunit. The page is similiar to this page view-source:http://mstratman.github.io/jQuery-Smart-Wizard/ and the header looks like this:

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>Process Loop Diagnosis</title>
  <link rel="stylesheet" type="text/css" href="./styles/smart_wizard.css">
  <link rel="stylesheet" type="text/css" href="./styles/tanklevel.css">
  <script type="text/javascript" src="./scripts/gen_utils.js"></script>
  <script type="text/javascript" src="./scripts/jquery.min.js"></script>
  <script type="text/javascript" src="./scripts/jquery.smartWizard.min.js"></script>
  <script type="text/javascript" src="./scripts/ajax.js"></script>
  <script type="text/javascript" src="./scripts/processloopdiagnosis.js"></script>
</head> 

So i wrote the following code to get access on the conent

        WebClient webClient = new WebClient(BrowserVersion.CHROME);
        webClient.getOptions().setJavaScriptEnabled(true);
        webClient.getOptions().setCssEnabled(true);
        webClient.getOptions().setUseInsecureSSL(true);
        webClient.getCookieManager().setCookiesEnabled(true);
        webClient.setAjaxController(new NicelyResynchronizingAjaxController());

        HtmlPage page = webClient.getPage("http://192.168.0.106/processloopdiagnosiswizard.shtml");
        webClient.waitForBackgroundJavaScript(30 * 1000);

        System.out.println(page.asXml()); 

unfortunately the javascript dont get executed and i get the following warnings

Jun 26, 2016 10:13:21 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNUNG: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://192.168.0.106/scripts/gen_utils.js', but got 'text/plain'.
Jun 26, 2016 10:13:22 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNUNG: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://192.168.0.106/scripts/jquery.min.js', but got 'text/plain'.
Jun 26, 2016 10:13:22 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNUNG: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://192.168.0.106/scripts/jquery.smartWizard.min.js', but got 'text/plain'.
Jun 26, 2016 10:13:22 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNUNG: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://192.168.0.106/scripts/ajax.js', but got 'text/plain'.
Jun 26, 2016 10:13:22 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNUNG: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://192.168.0.106/scripts/processloopdiagnosis.js', but got 'text/plain'.

if i use the same code on this page http://mstratman.github.io/jQuery-Smart-Wizard/ everthing works fine, the javascript get executed and i there are no warnings. Have some one any idea where the problem can be?

Aucun commentaire:

Enregistrer un commentaire