1

looked through the 'net, as well as other replies on here..

i've got something that looks like the following html:

var langId = '-1';
var demoKey = 'null';
var extraParams = 'null'; // only used for User Registration page
var multiSelect = false;

and

function onCampusSelect_USA() {
    if($('campusUSAIdSelect').value == ''){clearAJAXTimer();hideLayer("programUSADiv");   hideLayer("errorDiv");    hideLayer("buttonDivUS"); return; }
    // REMOVE THIS LATER
    clearAJAXTimer();
    getData(buildParms('PROGRAMSUS','US','campusId='+$('campusUSAIdSelect').value + "&institutionId=" +  $('institutionUSAIdSelect').value));
}

i've tried the following with no luck

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3);
webClient.setJavaScriptEnabled(true);
HtmlPage page = webClient.getPage("http://www.foo.com/");
ScriptResult scriptResult = page.executeJavaScript("${'multiSelect'}");
System.out.println(scriptResult.getJavaScriptResult());

so.. i'm trying to figure out just what should go in the execute line..

ScriptResult scriptResult = page.executeJavaScript( what goes here?? );

something like

document.mutliSelect.value() <<<< (which doesn;t work by the way..)

thanks

1
  • In the API of the HtmlUnit you can find the answer to your question about "what goes here???" htmlunit.sourceforge.net/apidocs/com/gargoylesoftware/htmlunit/…. Depending on your requirement, the sourceCode can vary. I assume you try to get the value of the multiSelect node. The question is, how your html looks like, and not JavaScript and in which way you can identify your multiSelect node (for example: by knowing it's id, knowing it's name or maybe css class). Tell more about requirements and place some html Commented Feb 1, 2010 at 16:30

1 Answer 1

2

type the following into your browser navigation bar:

javascript:alert("hello!")

Using this technique, you can execute JavaScript commands. For HtmlUnit, replace "what goes here??" by the stuff you would type into the navigation bar without the "javascript:" part.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.