简体   繁体   English

com.gargoylesoftware.htmlunit.ScriptException:调用open的异常

[英]com.gargoylesoftware.htmlunit.ScriptException: Exception invoking open

I'm working with an intranet site. 我正在使用Intranet网站。 When I login to the " https://itam.flextron.com.au/arsys/shared/login.jsp " website via chrome or IE browser it's work fine. 当我通过chrome或IE浏览器登录https://itam.flextron.com.au/arsys/shared/login.jsp网站时,它工作正常。 However while I login to the website via browser a window pop up and closes automatically and then the login page displays. 但是,当我通过浏览器登录网站时,会弹出一个窗口并自动关闭,然后显示登录页面。

But when I access the intranet page via HTMLUNIT it' throws exceptions with some html codes. 但是,当我通过HTMLUNIT访问Intranet页面时,会引发一些html代码的异常。

public class TestClass { 公共类TestClass {

public static void homePage() throws Exception {
    WebClient webClient = new WebClient(BrowserVersion.CHROME);
    HtmlPage page = webClient.getPage("https://itam.flextron.com.au/arsys/shared/login.jsp");
    System.out.print("Accessing the webpage...");
    System.out.print(page.asText());
    webClient.closeAllWindows();
}
public static void main(String arg[]) 
{
    try {
        homePage();
    }
    catch(Exception e)
    {
        System.out.print("Exception : "+ e);
    }
}

} }

** **

EXCEPTIONS: 例外:

** **

 Sep 27, 2014 11:47:17 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'application/x-javascript'. Sep 27, 2014 11:47:17 PM com.gargoylesoftware.htmlunit.WebClient printContentIfNecessary INFO: statusCode=[404] contentType=[text/html] Sep 27, 2014 11:47:17 PM com.gargoylesoftware.htmlunit.WebClient printContentIfNecessary INFO: <HTML> <HEAD> <title>BMC&nbsp;Remedy&nbsp;Mid&nbsp;Tier&nbsp;7.1 - Error page</title><!--;--> <style type="text/css"> <!-- BODY {font-family:Tahoma,arial,helvetica,verdana;} .ErrorTitle {font-size:12pt; font-weight:bold; text-align:left;} .ErrorMsg {font-size:12pt; text-align:left;} .ReturnHome {font-size:10pt;} #product {position: absolute; top:20px; left: 0px; font: 16px "Arial", "Lucida Grande", "Verdana", "Helvetica", sans-serif; font-weight: bold; color: #ffffff; padding-left:18px; text-align:left;} #logo {position: absolute; top:15px; right:0px} --> </style> <script> function setOverride(yesno) { document.overrideForm.ipoverride.value = yesno; document.overrideForm.submit(); } </script> </HEAD> <BODY style="background-repeat: no-repeat" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <table border=0 cellpadding="0" cellspacing="0" width="100%"> <!-- header table --> <tr> <td width="100%"> <table border=0 cellpadding="0" cellspacing="0" width="100%" height=60> <tr> <td height=60 background="/arsys/shared/images/bkgd_image.gif"> <span id="product">&nbsp;</span> <div id="logo" align="right"> <img src="/arsys/shared/images/bmc_logo.gif" width="118" height="26" hspace="20" alt="BMC logo"> </div> </td> </tr> </table> </td> </tr> </table> <br> <br> <br> <br> <table> <tr> <td width=150 nowrap> &nbsp; </td> <td> <div class="ErrorTitle"> The following error(s) occurred while trying to process your request:<!--;--> </div> <br> <br> <div class="ErrorMsg"> ARERR&nbsp;[9217] <br> File not found. Either the file requested is not present or the URL supplied is bad.&nbsp; </div> <br><br> </td> </tr> <tr> <td width=150 nowrap> &nbsp; </td> <td class="ReturnHome"> <a href=/arsys/home>Return to home page</a> </td> </tr> </table> <script> var Msg="File not found. Either the file requested is not present or the URL supplied is bad.\\n" </script> </BODY> </HTML> Exception: com.gargoylesoftware.htmlunit.ScriptException: Exception invoking open 

The issue might be that the code is running into some Javascript, which HtmlUnitDriver doesn't support by default. 问题可能是代码正在运行到某些Javascript中,而HtmlUnitDriver默认情况下不支持。 try something like this: 尝试这样的事情:

    HtmlUnitDriver driver = new HtmlUnitDriver;
    driver.SetJavaScriptEnabled(true);

If that doesn't work, you can basically run another browser that does support JS through the HtmlUnitDriver like this: 如果那不起作用,则基本上可以通过HtmlUnitDriver运行另一个支持JS的浏览器,如下所示:

    HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
    driver.setJavascriptEnabled(true);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.gargoylesoftware.htmlunit.ScriptException:错误:Bootstrap 的 JavaScript 需要 jQuery 1.9.1 或更高版本 - com.gargoylesoftware.htmlunit.ScriptException: Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher com.gargoylesoftware.htmlunit.ScriptException:TypeError:无法调用null的方法“ appendChild” - com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method “appendChild” of null llegalStateException:无法通过com.gargoylesoftware.htmlunit.TextPage的xpath定位元素 - llegalStateException: Unable to locate element by xpath for com.gargoylesoftware.htmlunit.TextPage 如何克服 HTMLUnit ScriptException? - How to overcome an HTMLUnit ScriptException? Htmlunit ScriptException“console”未定义 - Htmlunit ScriptException “console” is not defined com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[form] attributeName=[name] attributeValue=[docSearch] - com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[form] attributeName=[name] attributeValue=[docSearch] HtmlUnit ScriptException错误 - HtmlUnit ScriptException errors 为什么 javac 找不到我正在尝试导入的 com.gargoylesoftware.htmlunit package - Why isn't javac finding the com.gargoylesoftware.htmlunit package I am trying to import Java HTMLUnit WebClient ScriptException错误 - Java HTMLUnit WebClient ScriptException errors com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 404 Not Found for https://tax.ocgov.com/includes/jquery-2.2.3.min.js - com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 404 Not Found for https://tax.ocgov.com/includes/jquery-2.2.3.min.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM