Jump to content
WAPT Forum
Sign in to follow this  
Guest vince

Accessing HTML DOM through javascript

Recommended Posts

Guest vince

Hi

 

I have tried a couple to javascript commands, which are mentioned in the WAPT Help, in my script.

Below mentioned is the Javascript:

var doc = context.document;

var body = context.responseBody;

var header = context.responseHeader;

var userID = context.userID;

var sessionNumber = context.sessionNumber;

context.variable("test") = "testvar";

log.message(doc.forms[0].getElementById("id").value);

 

After Test Run, in the log it is saying "JavaScript failed. Object doesn't support this property or method".

 

Instead of forms[0] I have also tried with the formname in the response code. I tried these inside a function. Then javascript didn't fail but nothing was executed. Everything was blank.

 

How can I access HTML DOM through javascripts. Is there some settings to be changed? I have attached a screenshot of javascript and the result log.

post-19870-0-42815900-1332408153.png

post-19870-0-12135700-1332408174.png

Share this post


Link to post
Share on other sites
Guest vince

Thanks Sergei. My syntax was wrong. Thats why I didn't get it. I was using "doc.forms[0].getElementById("id").value" instead of "doc.forms[0].elements["name"].value". Got it now :)

 

Do you know the keyword for getting the value based on element id. I tried "getElementById" but no use.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...