SCRIPT
Specifies javascript code, which will be executed in the context of the current page.
The script can set or print javascript values. It can also call any javascript function or method,
including html objects such as the window and document.
The frame and window attributes allow the
script to be executed in the context of the named frame and-or window
The following sets a variable and then prints it using document.writeln()
and also by using the output element <output/>
<script>myvar=10;</script>
<script>document.writeln(myvar);</script>
<output value="#{myvar} #{document.title}"/>
Note that there are two ways of invoking javascript - through the script element, or through any
variable expansion e.g. in output. eval or set elements.
Variable expansions (using #{var} syntax ) first checks for global variables, and then javascipt
variables on the current HTML page.
JavaScript support is based on that provided by HttpUnit.
The following is copied from the HttpUnit documentation.
The near-term goal is full JavaScript 1.1 support. Currently, we do not plan
to support browser-specific JavaScript.
Inline and included scripts are supported, as are the following DOM elements:
Window
properties
- closed - true if the window has been closed
- document - the associated Document object
- frames - an array of subframes of this window
- location - r/w the associated Location object, which may be treated as a URL string
- name - r/w the name of the window
- navigator - the Navigator object
- opener - r/o the window which opened this one (top-level frames only)
- parent - the window which is a parent of this one.
- self - the Window itself
- top - the top frame in the frameset containing this window
- window - a synonym for self
- <name> - the subframe of this window with the specified name
events
- onLoad - invoked when the page is loaded
methods
- alert() - queues up an alert message, accessible via WebResponse.getNextAlert() or popNextAlert()
- close() - closes the window
- confirm() - invokes a callback supplied via WebClient.setDialogResponder to return the user's response. By default,
the callback returns true. Users may change this by supplying an implementation of DialogResponder.
- prompt() - invokes a callback supplied via WebClient.setDialogResponder to return the user's response
- open() - opens a new window. A callback will be generated to any WebWindowListener registered with the client.
Navigator
properties
- appCodeName - the code name set in ClientProperties.setApplicationCodeName()
- appName - the name of the browser, as set in ClientProperties.setApplicationName()
- appVersion - the browser version, set in ClientProperties.setApplicationVersion()
- plugins - an empty array of objects, since plugins are not universally supported
- platform - the platform for the browser, set in ClientProperties.setPlatform (1.2 feature)
- userAgent - the name of the user agent, set by ClientProperties.setUserAgent or derived from the code name and version
methods
- javaEnabled - always returns false to indicate that applets are not supported
Screen (1.2 feature)
properties
- availWidth - the available screen width, set in ClientProperties.setAvailableScreenWidth()
- availHeight - the available screen height, set in ClientProperties.setAvailableScreenHeight()
methods
- javaEnabled - always returns false to indicate that applets are not supported
Location
properties
- href - r/w the current window location. Setting this value initiates a new request to the server
- host - r/o the host and port portion of the current window location
- hostname - r/o the host portion of the current window location
- port - r/o the port portion of the current window location
- protocol - r/o the port portion of the current window location
- pathname - r/w the path portion of the current window location. Setting this value initiates a new request to the server
- search - r/w the query portion of the current window location. Setting this value initiates a new request to the server
methods
- replace - replaces the current window by doing a new request to the server
Document
properties
- forms - an array of Form objects
- images - an array of Image objects
- links - an array of Link objects
- title - readonly. The title of the page
- location - a synonym for window.location
- cookie - access to the document-specific cookies.
- <name> - the name of a form, image, or link
methods
- open - opens a document for writing, optionally specifying a MIME type
- close - closes the open document and replaces its contents with the written text
- write - writes a string to the contents of the current open document
- writeln - writes a line with carriage-return to the contents of the current open document
Form
properties
- action - r/w the action associated with the form
- document - r/o the enclosing document
- elements - r/o an array of controls in the form
- <name> - the name of a control in the form
events
- onReset - invoked when form.reset() is invoked or a reset button is clicked
- onSubmit - invoked when form.submit() is invoked or a submit button is clicked
methods
- submit - submits the form
- reset - resets the form controls to their default values
Image
properties
- src - read/write - the relative URL of the image
Link
properties
- href - read/write - the URL associated with the link
events
- onClick - invoked when link.click() is invoked
- onMouseOver - invoked when link.mouseOver() is invoked
-
Input (and subclasses)
properties
- form - read-only - the form containing the input
- name - read-only - the name of the control
methods
Button
events
- onClick - invoked when button.click() is called
Text
properties
- value - read/write - the current text value
events
- onChange - invoked when the value of the control is changed via form.setParameter
TextArea
properties
- value - read/write - the current text value
events
- onChange - invoked when the value of the control is changed via form.setParameter
Hidden
properties
- value - read/write - the current text value
Password
properties
- value - read/write - the current text value
events
- onChange - invoked when the value of the control is changed via form.setParameter
Checkbox
properties
- checked - read/write - the state of the checkbox
- defaultChecked - read-only - the default state of the checkbox
- value - read/write - the value transmitted if the control is checked
events
- onClick - invoked when the state of the control is changed via form.setParameter or form.removeParameter
Radio
properties
- checked - read/write - the state of the radio button
- defaultChecked - read-only - the default state of the radio button
- value - read/write - the value transmitted if the control is checked
events
- onClick - invoked when the state of the control is changed via form.setParameter
Select
properties
- length - read-only - the number of options associated with the control
- selectedIndex - read-write - the index of the selected option
- options - read-write - an array of the options associated with the control
- options.length - read-write - the number of options associated with the control
events
- onChange - invoked when the value of the control is changed via form.setParameter
Option
constructor
You may construct an Option object and assign it to an element in the Select.options array
properties
- text - read-write - the display text associated with the option (listed after the <'option> tag)
- value - read-write - the value associated with the option (from the 'value' attribute)
- selected - read-write - true if this option is currently selected
- defaultSelected - read-only - true if this option is selected by default
- index - read-only - the index of this option in its select
1. Allowed Content
#PCDATA
2. Attributes
3. Content Rule
( #PCDATA )
4. Parent Elements
steps -- This element contains all the test steps.
suite -- Define a set of steps which can be "called" from a run element.
with -- Group together a set of steps that use the same page definition.
Top Elements ||
All Elements
|| Tree