Class NamedScriptWithResult<T1, T2, T3, T4, TResult>
- Namespace
- CSF.Screenplay.Selenium
- Assembly
- CSF.Screenplay.Selenium.dll
A model representing a pre-written piece of executable JavaScript, which accepts 4 parameters, but which is expected to return a result.
public class NamedScriptWithResult<T1, T2, T3, T4, TResult> : NamedScriptBasis, IHasName
Type Parameters
T1The type of the first parameter
T2The type of the second parameter
T3The type of the third parameter
T4The type of the fourth parameter
TResultThe expected result/return type from the script
- Inheritance
-
NamedScriptWithResult<T1, T2, T3, T4, TResult>
- Implements
- Inherited Members
Remarks
Whilst the generic type parameters of this type have no direct bearing upon its members (such as properties), they are very useful when combined with the builder methods ExecuteAScript(NamedScript) and its many overloads. Developers are encouraged to represent JavaScripts that they wish to execute in the web browser using this type (and related types, see "See Also"). Where the script accepts parameters and/or returns a result, choose a type which specifies appropriate generic type arguments for those parameters and returned type.
For scripts which are created in this manner, getting an IPerformable or IPerformableWithResult<TResult> for those
scripts is very easy and type safe. Use the ExecuteAScript method from the PerformableBuilder and the compiler will
use the generic type arguments of this type to select an appropriate overload which provides type-safety for specifying the parameter
values and the return type, as appropriate.
Another benefit is that scripts defined and stored in instances of this type are reusable and easily catalogued. See the Scripts helper class for an example of a catalogue of script objects which may be executed. Once again, developers are encouraged to follow this pattern in their own applications/tests which use Screenplay & Selenium.
Constructors
NamedScriptWithResult(string, string)
Initialises a new instance of NamedScriptWithResult<TResult>.
public NamedScriptWithResult(string scriptBody, string name)
Parameters
Exceptions
- ArgumentException
If either parameter is null or whitespace-only.