Jump to content

Accessing HTML DOM through javascript

  • Please log in to reply
2 replies to this topic

#1 Guest_vince_*

  • Guests

Posted 22 March 2012 - 09:23 AM


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";

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.

Attached Files

#2 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 665 posts

Posted 22 March 2012 - 10:28 AM

You can access to the DOM of the last response only if it contains HTML code.
Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com

#3 Guest_vince_*

  • Guests

Posted 26 March 2012 - 05:12 AM

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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users