...
- (Optional) Modify the input label name in the Form Test Name field.
- (Optional) Modify the form action in the Form Action field.
- If you want to use the default form action (as specified in the code), select the Default option. Note that if the default value changes, SOAtest will update the form action automatically; you will not need to manually update the form test.
- If you want to specify a fixed value, select the Fixed option, then specify the desired form action in the text field.
- Use the Form Inputs controls to add or modify inputs for each form input elemenelement.
- If you want to use the default input (as specified in the code), select the Default option. Note that if the default value changes, SOAtest will update the form test value automatically; you will not need to manually update the form test.
- If you want to specify a fixed value, select the Fixed option, then specify the desired value using the available controls.
- Check boxes, radio buttons, and select inputs have a User-Defined option, which allows you to specify a simple string that will be sent as the value for this input.
- Radio buttons and select inputs also have an Index option which allows you to specify the index of a radio button or of select option(s). If an index is selected, then the value of that radio button or option will be sent, regardless of how the option changes. This index is 0-based. For instance, if you want to always select the 2nd option, then you can choose the Index option and choose the index “1”. For radio buttons, the current value of the radio button at that index is shown for each index. For select inputs, the current display value of the option is shown along with each index.
- Select inputs store the display values for the select rather than the values that would be sent to the server. Consequently, when the submit values change, you do not need to modify the test.
- If you want SOAtest to extract the form input value from the page on which the form appears—for instance, if the correct form value is set dynamically by JavaScript—select Extracted, fill the Left-hand text field with the text string that always appears to the left of the value you want extracted, then fill the Right-hand text field with the text string that always appears to the right of the value you want extracted. For example, to extract the value
123
from the textpre123post
, you would enter pre in the Left-hand text field andpost
in the Right-hand text field. - If you want to disable an enabled input, select the Disable option. If you want to enable a disabled input, select the Enable option.
- If you want to use the return value of a custom method, select the Script option. Click the Edit button to create or edit the method(s) and choose the desired method for use from the Method drop-down menu in the popup dialog. If there are two or more methods, you can also select a different method for use from the drop-down menu in the form panel.
- (If a form has an OnSubmit handler) Enable or disable the Process OnSubmit Handler When Submitting Form option depending on whether you want that handler used during the test.
- If the form has an OnSubmit handler, this option by default is set to true by default—unless the form test was created while recording paths with the browser. In this case, it is set to false because when SOAtest records a path from the browser, SOAtest sets up the form test in such a way that the OnSubmit does not need to be processed (and, in fact, processing this handler in this case could cause problems during path execution).
- (Optional) Change the default form submission method.
- If you want to mimic a simple JavaScript submission or a situation where the user submits the form by pressing the Enter key, select the Implied Submit option.
- If you want to mimic the user submitting the form by clicking a submit button, either choose the option representing that submit button (for example, Image: "Anonymous") or click a specific area of the submit image (if available in the Form Input panel).
...
You can create, apply, and invoke scripts that define hooks in the same way that you create, apply, and invoke any other script in SOAtest: upon startup (only for JavaScript and Jython scripts), by creating and applying an Extension tool, and by adding scripts to a specific path node. You can invoke hooks at different times to elicit the desired functionality. For example, if you want to use a script’s hook functionality for all SOAtest projects and sites, you could add the JavaScript or Jython script that defines and uses that hook to the <soatest_install_dir><INSTALL>/plugins/com.parasoft.xtestptest.libs.web_<soatest_version><VERSION>/root/startup directory; then, any . Any time the program calls the hook, the associated user-defined methods will be executed. The methods will be executed until you call clear () on the hook.
...
This hook is commonly used to print the results of alert messages to a special SOAtest Message window. For example, if you wanted SOAtest to report all alert messages in a SOAtest Message window named "Alert Messages," you could create the following Jython script and add it to your <soatest_install_dir>your <INSTALL>/plugins/com.parasoft.xtestptest.libs.web_<soatest_version><VERSION>/root/startup directory:
Code Block |
---|
from com.parasoft.api import Application def myAlertHook(msg): # Print the alert message to SOAtest Messages Application.showMessage(" JavaScript Alert: %s" % str(msg)) # Add the contents of the alert message to a Result Window named # "Alert Messages". This ResultWindow can later be used # as part of a test suite in a regression test, to make sure the # contents of the window, which contains the alert message, # are what you expect them to be. Application.report("Alert Messages", str(msg)) # Add your method to the Alert Hook Application.getHook("Alert").set(myAlertHook) |
...
Next, add this file to the <soatest_install_dir><INSTALL>/plugins/com.parasoft.xtestptest.libs.web_<soatest_version><VERSION>/root/startup directorystartup directory. The next time you start SOAtest, it will execute the above script whenever it encounters a confirm() method.
...
For example, if you wanted SOAtest to print each URL visited to the Console view, you could create the following Jython script and add it to your <soatest_install_dir><INSTALL>/plugins/com.parasoft.xtestptest.libs.web_<soatest_version><VERSION>/root/startup directory:
Code Block |
---|
from com.parasoft.api import * from webtool.site import SiteUtil count = 1 def setHook(): SiteUtil.enableLogging = 1 hook = Application.getHook("UrlLogging") hook.set(loggingHook) def loggingHook(url, post, props): global count if post: Application.showMessage(str(count) + ". " + url + " [POST=" + post + "]") else: Application.showMessage(str(count) + ". " + url) count = count + 1 setHook() |