Agilitest allows to call javascript code on a component that has been captured.
This differs from a java call that is more like a subscript call.
In both cases, you must be informed that it will be possible to modify the elements of the software that you test, and thus to break appart from the operation that you are supposed to control.
In some cases, it is very practical, even necessary: We will see the case of the slider.
The next image shows two sliders that originally have a value of 50.

When manipulating a slider, it is quite complex to set a precise value only by using mouse movement actions, as shown in the example below, the two sliders display different values for the same swipe of 100 pixels to the right.


What is the issue ? If you perform a test based on move of 100 pixels and subsequently the value of the slider is critical to the success of your test, you become dependent on the implementation of the slider.
In this case, javascript is particularly suitable, since it will allow you to set a value directly on the slider element by modifying its internal variable value:
value=75;

Then, the two sliders that have different sizes allow the setting of the same value, no matter the movement of the sliders, which are different.

Visual checks
You can modify the style and therefore the color of the elements you test, for that you just have to modify the style object:
style.backgroundColor="green"

This will allow you to display visual controls in ATSV files or XML reports produced by Agilitest. It might be useful...

A complex check built into the page
In some cases where you have to perform a complex check on your page, it is quite possible to code this check in javascript code loaded in the page, and then call the javascript function in your test by retrieving the value returned to do a simple check.
This is not an optimal situation because you may have to manage development code including this function and production code with the hazards that it may cause, but it can lead to complex situations to deal with.
For that you just have to declare a global function in a SCRIPT tag of your page:
<SCRIPT>
function checkpage() {
....operations...
if (condition) {
return true;
} else {
return false;
}
}
</SCRIPT>
Then just call it from your Agilitest editor, referencing a return variable, on which you will only have to perform a value check.
