Anonymous - 2004-08-09

Hi,

I have problems getting a link to which a parameter is added via javascript. I cannot change the webapp so I somehow have to click the "right" link using HttpUnit.

The http:

A table with entries and some links. One of the links is the one I want to click:

<div id='createCommand'><a href="/FV/anlegen.do" style="" class="" id="create" onclick="return createClicked(this)">Neu</a>

The javascript:

<script language="JavaScript1.2">
        function createClicked(linkElement) {
            var newLink = linkElement.href;
            var valueCombo = null;
            var countCells = -1;
            var combo = null;
   
            combo = getElemById("selectSaison");
            valueCombo = getSelectedComboOID(combo);
   
            if (!valueCombo) {
                alert('Bitte waehlen Sie aus!');
                return false;
            }
           
            linkElement.href = newLink + "&" + "saison_id=" + valueCombo;
            window.event.returnValue = true;
            return true;
        }
</script>

The script adds a value from a combobox (one is selected by default) as parameter. In the browser everything works fine, in httpunit, the old page remains after clicking:

WebLink wl;
wl = wr.getLinkWith("neu");
//also tried wl = wr.getLinkWithID("create");
WebResponse wr;
wr=wl.click();

even
wr = this.getWebconversation().getCurrentPage(); returns the original page, not the one with "/FV/anlegen.do".

It would be already helpful for me, if I could change the link-url in the weblink objekt manually, but no appropriate methods are served.

Thanks for your help.