Class SharedActionBase
Base class of the shared actions. All shared actions must be derived from this class and implement DoAction, DoCheckpoint method. In order to verify if all parameters are given when calling DoAction() and DoCheckpoint() methods, please specify RequiredParameters Property
Namespace: AxaFrance.WebEngine
Assembly: AxaFrance.WebEngine.dll
Syntax
public abstract class SharedActionBase
Constructors
| Improve this Doc View SourceSharedActionBase(Variable[])
Default constructor
Declaration
protected SharedActionBase(Variable[] _parameters)
Parameters
Type | Name | Description |
---|---|---|
Variable[] | _parameters | the parameters to use during the test |
Fields
| Improve this Doc View SourcetestCase
Declaration
protected TestCase testCase
Field Value
Type | Description |
---|---|
TestCase |
Properties
| Improve this Doc View SourceActionReport
Stores the test result for the current action. the information of execution will be updated.
Declaration
protected ActionReport ActionReport { get; set; }
Property Value
Type | Description |
---|---|
ActionReport |
ActionResult
The indicator if the current action is correctly executed. it's default value is Passed
Declaration
public Result ActionResult { get; protected set; }
Property Value
Type | Description |
---|---|
Result |
Remarks
If an actions is Failed the test case runner will continue run following test steps and actions. If critical error have happend and the test case must stop, please use the result CriticalError You can provide more detailed information to Information property.
ContextValues
Values can be stored and shared with other actions within the same test case.
Declaration
public List<Variable> ContextValues { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Variable> |
Global
The Global level context test values.
Variables in this list will be conserved between different test cases. if necessary you need to clear the list at the beginning of the test
Declaration
public static List<Variable> Global { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Variable> |
Information
All the information you want to pass to upper level. the information will be reported in TestStep object and be written in the XML report. Use AppendLine() operator to append information text if necessary.
Declaration
public StringBuilder Information { get; }
Property Value
Type | Description |
---|---|
System.Text.StringBuilder |
Parameters
Given parameters (Test Data) used to run the current test action
Declaration
public Variable[] Parameters { get; set; }
Property Value
Type | Description |
---|---|
Variable[] |
RequiredParameters
Provide required parameters for this Action. when provide a Value of a Parameter, it will be considered as its default value. Missing such parameter will lead the usage of default value for the test. when provide a null Value of a Parameter, Missing such parameter will lead NullArgumentException
Declaration
public abstract Variable[] RequiredParameters { get; }
Property Value
Type | Description |
---|---|
Variable[] |
Screenshots
The binary of the screenshots taken within this action
Declaration
public List<ScreenshotReport> Screenshots { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<ScreenshotReport> |
UpdateTime
The DateTime where the last shared action has been executed. This DateTime is considered the time of last operation of test framework. if an test case blocks somewhere and last for more than x minutes, the test framework will terminates a test case.
Declaration
public static DateTime UpdateTime { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime |
Methods
| Improve this Doc View SourceDoAction(Object)
Implement DoAction() method to interact with your application (Click the links, Fill forms, Click buttons, ...) Of course, you can do any actions needed.
Declaration
public abstract void DoAction(object Context)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Context | Application Context used for the action, for LeanFT actions, it will be an object of type AppModelBase |
DoAction(Type, TestCase, Object, List<Variable>, ActionReport, Variable[])
Declaration
public static SharedActionBase DoAction(Type sharedActionType, TestCase relatedTestCase, object Context, List<Variable> ContextValues, ActionReport actionReport, params Variable[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | sharedActionType | |
TestCase | relatedTestCase | |
System.Object | Context | |
System.Collections.Generic.List<Variable> | ContextValues | |
ActionReport | actionReport | |
Variable[] | parameters |
Returns
Type | Description |
---|---|
SharedActionBase |
DoAction(Type, Object, List<Variable>, ActionReport, Variable[])
Static function to run this shared action. the action:
- Check if all the required parameters are given, or by default using it's default value.
- for all those who the parameter has no default value (Parameter.Value == null), throw exception
- Create an instance of the action and run it.
Declaration
public static SharedActionBase DoAction(Type sharedActionType, object Context, List<Variable> ContextValues, ActionReport actionReport, params Variable[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | sharedActionType | the object type of sharedAction |
System.Object | Context | The browser object |
System.Collections.Generic.List<Variable> | ContextValues | The stored context content to be shared and be used with other actions. |
ActionReport | actionReport | The testaction report to use for generating |
Variable[] | parameters | Test parameters |
Returns
Type | Description |
---|---|
SharedActionBase | A SharedActionBase object which is created during the execution. this object can be used later to call DoCheckpoint() |
DoAction(Type, Object, List<Variable>, Variable[])
Funaction to run an sub action from the current one. This action reuses the DoAction(Type, Object, List<Variable>, ActionReport, Variable[]) and generates a ActionReport attached to SubActionReports
Declaration
protected SharedActionBase DoAction(Type sharedActionType, object Context, List<Variable> ContextValues, params Variable[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | sharedActionType | the object type of sharedAction |
System.Object | Context | The browser object |
System.Collections.Generic.List<Variable> | ContextValues | The stored context content to be shared and be used with other actions. |
Variable[] | parameters | Test parameters |
Returns
Type | Description |
---|---|
SharedActionBase | A SharedActionBase object which is created during the execution. this object can be used later to call DoCheckpoint() |
DoActionWithCheckpoint(Type, Object, List<Variable>, ActionReport, Variable[])
Static function to execute and check the Shared Action
This action calls internally DoAction() and DoCheckpoint() together. it is recommended to call this function within an action.
Declaration
public static bool DoActionWithCheckpoint(Type sharedActionType, object Context, List<Variable> ContextValues, ActionReport actionReport, params Variable[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | sharedActionType | the Type of the SharedAction to run |
System.Object | Context | The Browser object |
System.Collections.Generic.List<Variable> | ContextValues | The stored context content to be shared and be used with other actions |
ActionReport | actionReport | The report object of the target action to be used. |
Variable[] | parameters | Given parameters (test data dedicated to the current test case) |
Returns
Type | Description |
---|---|
System.Boolean | Boolean value indicates if the Action runs well and the checkpoint passes. |
Remarks
When calling DoAction, DoCheckpoint or DoActionWithCheckpoint in another action, please consider promote the result to above level.
DoActionWithCheckpoint(Type, Object, List<Variable>, SharedActionBase, Variable[])
Static function to execute and check the Shared Action
This action calls internally DoAction() and DoCheckpoint() together. it is recommended to call this function within an action.
Declaration
public static bool DoActionWithCheckpoint(Type sharedActionType, object Context, List<Variable> ContextValues, SharedActionBase CallingAction, params Variable[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | sharedActionType | the Type of the SharedAction to run |
System.Object | Context | The Browser object |
System.Collections.Generic.List<Variable> | ContextValues | The stored context content to be shared and be used with other actions |
SharedActionBase | CallingAction | The SharedAction object which calls the sub-action to be executed. |
Variable[] | parameters | Given parameters (test data dedicated to the current test case) |
Returns
Type | Description |
---|---|
System.Boolean | Boolean value indicates if the Action runs well and the checkpoint passes. |
Remarks
When calling DoAction, DoCheckpoint or DoActionWithCheckpoint in another action, please consider promote the result to above level.
DoCheckpoint(Object)
This method should be called after calling DoAction() Method in order to check whether the action is correctly running.
Declaration
public abstract bool DoCheckpoint(object Context)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Context | Application Context used for the checkpoint, for LeanFT actions, it will be an object of type AppModelBase |
Returns
Type | Description |
---|---|
System.Boolean | True if the checkpoint is passed, or False if the checkpoint fails. if the return value is false, the test will be marked as failed. |
Remarks
If the return value is True and the ActionResult = Failed or Warning, Test will continue and the Test case will be marked as Failed.
If the checkpoint returns False, test will be stop and will be considered as Failed.
When calling another action from an action, please considering promote errors and result to above level.
GetParameter(IEnumerable<Variable>, String)
Get the value of the parameter from giving list. The value can be empty, but will never be null (unless it's value is intendedly changed by yourself) If the parameter does not exists, an exception will be thrown, to avoid this make sure the parameter is listed in RequiredParameters.
Declaration
public static string GetParameter(IEnumerable<Variable> source, string name)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Variable> | source | the list of parameter where the parameter is in. |
System.String | name | the name of the parameter to find |
Returns
Type | Description |
---|---|
System.String | the value of the giving parameter |
GetParameter(String)
Get the value of the parameter from giving list. The value can be empty, but will never be null (unless it's value is intendedly changed by yourself) If the parameter does not exists, an exception will be thrown, to avoid this make sure the parameter is listed in RequiredParameters.
Declaration
public string GetParameter(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | the name of the parameter to find |
Returns
Type | Description |
---|---|
System.String | the value of the giving parameter |
GetType(String)
Get the Type of an SharedActionBase by its name.
Declaration
public Type GetType(string action)
Parameters
Type | Name | Description |
---|---|---|
System.String | action | the name of the shared action |
Returns
Type | Description |
---|---|
System.Type | Type object of the action. |
Screenshot(String)
Provide screen-shot in the report
Declaration
protected abstract void Screenshot(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name |