This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Testing and the fly likes cannot get https page details Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "cannot get https page details" Watch "cannot get https page details" New topic

cannot get https page details

Prasath Premkumar
Ranch Hand

Joined: Nov 13, 2008
Posts: 43

I'm trying to extract data from a wesite. After i give the login details the new page opens through javascript window. So, when i provide the login details to the program it should process javasript , get the url & go to the new page. then i can get a table from the new page & extract data. This is the senario. How can i do that using HtmlUnit?

I wrote a sample application; i have posted the code below;

public class Main{

public static void main(String args[]){
try {
Main main = new Main();
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);

public void submittingForm() throws Exception {
final WebClient webClient = new WebClient();
ProxyConfig proxy = new ProxyConfig();
// Get the first page
final HtmlPage page1 = webClient.getPage("some url");

// Get the form that we are dealing with and within that form,
// find the submit button and the field that we want to change.
final HtmlForm form = page1.getFormByName("form1");

final HtmlSubmitInput button = form.getInputByName("Submit");
final HtmlTextInput textField1 = form.getInputByName("user_id");
final HtmlPasswordInput textField2 = form.getInputByName("password1");

// Change the value of the text field
textField1.setValueAttribute("my username");
textField2.setValueAttribute("my password");

// Now submit the form by clicking the button and get back the second page.
final Page page2 =;
final HtmlPage toTest = (HtmlPage)page2;
final List<?> divs = toTest.getByXPath("//table");
for(int i = 0; i<divs.size();i++){
final HtmlTable table = (HtmlTable)divs.get(i);
for (final HtmlTableRow row : table.getRows()) {
// System.out.println("Found row");
for (final HtmlTableCell cell : row.getCells()) {
System.out.println(" Found cell: " + cell.asText());


bt the program gives the following chained exception:

======= EXCEPTION START ========
Exception class=[org.mozilla.javascript.WrappedException]
com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: Inappropriate array length. ( (script in from (4, 38) to (32, 14)#27)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(
at com.gargoylesoftware.htmlunit.html.HtmlElement$
at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(
at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(
at com.gargoylesoftware.htmlunit.WebClient.getPage(
at com.gargoylesoftware.htmlunit.WebClient.getPage(
at com.gargoylesoftware.htmlunit.html.HtmlForm.submit(
at com.gargoylesoftware.htmlunit.html.HtmlSubmitInput.doClickAction(
at siteextractor.Main.submittingForm(
at siteextractor.SampathBank.main(
Caused by: org.mozilla.javascript.WrappedException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: Inappropriate array length. ( (script in from (4, 38) to (32, 14)#27)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(
at org.mozilla.javascript.MemberBox.invoke(
at org.mozilla.javascript.Interpreter.interpretLoop(
at org.mozilla.javascript.Interpreter.interpret(
at org.mozilla.javascript.ContextFactory.doTopCall(
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(
at org.mozilla.javascript.ScriptRuntime.doTopCall(
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$
... 23 more
and so on................

I'm really stuck with it. What can be the problem?

Please help me. Thanks in advance. >
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32635

Moving to our testing forum since it is about a testing tool.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: cannot get https page details
It's not a secret anymore!