Cannot Execute OnClick Method on a Table Cell in HttpUnit/JWebUnit

Hello,

I'm trying to execute an onclick JS Function on a table cell using HttpUnit (and JWebUnit).  I researched the web on how to do this and all the different sites I found all said basically the same thing.  However it doesn't work for some reason.  Here's the Java code:

ScriptableDelegate delegate = getDialog().getWebTableBySummaryOrId("toolbarTable").getTableCellWithID("new").getScriptableDelegate();
delegate.doEvent("onclick");

and here's the HTML snippet:

<script language="javascript">
      function createNew() {
            if (document.inbox) {
                  document.inbox.action="compose.do";
                  document.inbox.submit();
            }
      }
      function deleteMessages() {
            var hiddenPane=document.getElementById("tab_messages__tabholder").innerHTML;
            var isSentSelected = (hiddenPane && hiddenPane.indexOf("tab_messages_sentbox") < 1);
            if (isSentSelected) {
                  document.sentbox.submit()
            } else {
                  document.inbox.submit()
            }
      }

        function MO(e) {if (!e) var e=window.event; var S=e.srcElement; if (!S) {S=e.target;} while ("TD"!=S.tagName) {S=S.parentNode;} S.className="H"; }
        function MU(e) {if (!e) var e=window.event; var S=e.srcElement; if (!S) {S=e.target;} while ("TD"!=S.tagName) {S=S.parentNode;} S.className="T"; }
</script>
<table id="toolbarTable" class="toolbar">
<tr style="background-image: url(images/toolbar_bg.gif)">
   <td id="new" nowrap="true" style="width: 44px;" class="T" onmouseover="MO(event)" onmouseout="MU(event)" onclick="createNew();"><img src="images/toolbar_new.gif" border="0" style="vertical-align: text-top"><span class="TT">&nbsp;New</span></td>
   <td style="width: 5px;"> | </td>
   <td id="delete" nowrap="true" style="width: 44px;" class="T" onmouseover="MO(event)" onmouseout="MU(event)" onclick="if (confirm('Are you sure?')) deleteMessages();"><img src="images/toolbar_delete.gif" border="0" style="vertical-align: text-top"><span class="TT">&nbsp;Delete</span></td>
   <td></td>
</tr>
</table>

When I run this code:

WebTable table = getDialog().getWebTableBySummaryOrId("toolbarTable");
TableCell cell = table.getTableCellWithID("new");
System.out.println(cell.getText());

it prints out "New" to the console so it appears to be getting the right table cell.  I checked to see if there was another element with an id of "new" but there isn't.  Any help would be welcome.

Thanks!
ECWebAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ECWebAuthor Commented:
Looks like I figured out the answer to this one...same code as above with the following change.  Instead of:

ScriptableDelegate delegate = getDialog().getWebTableBySummaryOrId("toolbarTable").getTableCellWithID("new").getScriptableDelegate();
delegate.doEvent("onclick");

I do this:

Scriptable scriptable = getDialog().getResponse().getScriptableObject();
scriptable.doEvent("createNew()");

It works great.  I'm not sure why the other one didn't work, but oh well...
0
GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.