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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×