Understanding Javascript loading in Zombie

74 views
Skip to first unread message

Jagdeep Rao

unread,
Nov 30, 2015, 11:13:41 AM11/30/15
to zombie.js
Hi,
 I have a page that makes liberal use of javascript for various validations and other tasks. One of these is that the submit click leads to some computations and setting of some values in cookies and hidden fields followed by the script invoking the submit method on the form. Problem is the script references for example the submit for form -

<form action="/logon" method="POST" name="logonForm" enctype="application/x-www-form-urlencoded" autocomplete="off">
.
.
</form>

with Javascript - 
document.logonForm.submit();

This does not work in zombie - I get an error message that states - "TypeError: Cannot read property 'submit' of undefined". 

Any idea how this can be resolved? 

Assaf Arkin

unread,
Nov 30, 2015, 12:17:19 PM11/30/15
to zomb...@googlegroups.com
Try document.getElementById(id)

--
You received this message because you are subscribed to the Google Groups "zombie.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zombie-js+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jagdeep Rao

unread,
Nov 30, 2015, 1:26:08 PM11/30/15
to zombie.js
Can't. The javascript is not in my control. <form name=xyz.../> being accessed as document.formXyz is this enabled by JSDOM? Can I manipulate the dom and thereby be able to submit the form from the javascript as is?

Jagdeep Rao

unread,
Nov 30, 2015, 2:43:13 PM11/30/15
to zombie.js
Also another point to note is that the HTML shows the form (i.e. form is not being added dynamically), but browser.document.getElementsByClassName('logonForm')[0] is undefined, I am accessing other elements with getElementsByClassName(). The only issue seems to be <form> with a class name. Is this a known bug?

Assaf Arkin

unread,
Nov 30, 2015, 2:47:32 PM11/30/15
to zomb...@googlegroups.com
FYI your example from before, the form element doesn’t have a class name.

Jagdeep Rao

unread,
Nov 30, 2015, 2:55:37 PM11/30/15
to zombie.js
My apologies, getElementsByName() is working fine, as is getElementsByClassName(). Typo led to the undefined. The issue is the DOM tree being referred to by the javascript does not see the form element. So I am wondering if the source of the problem is related to one of the dependencies of zombie...

Assaf Arkin

unread,
Nov 30, 2015, 3:32:24 PM11/30/15
to zomb...@googlegroups.com
Yeah, it’s part of the DOM so first place to look for this would be JSDOM.

Jagdeep Rao

unread,
Dec 1, 2015, 3:00:53 PM12/1/15
to zombie.js
Confirmed JSDOM issue. It is there in the latest version of JSDOM too. Ofcourse cannot post using JSDOM alone but the element document.logonForm is undefined there as well. 

Reply all
Reply to author
Forward
0 new messages