Behaviors
Change the way how particular actions are executed.
General
There are different action behavior types that can be replaced with Atata predefined attributes or custom ones. Shortly, you can customize how to execute actions like click, hover, focus, set value, get value, etc. The default behaviors are fine for majority of cases, but sometimes we can face specific components on web sites, and need to apply different approaches (behaviors) to perform certain actions.
Usage
In order to apply a needed behavior to a certain control, just apply an appropriate attribute as any other Atata multi-cast attribute.
[ClicksUsingScript]
public Button<_> Save { get; private set; }
Custom Behavior
In order to create a custom implementation of a specific behavior,
create a new class inherited for behavior’s base class and write a behavior implementation inside an overriden Execute
method.
public class ClicksUsingCustomWayAttribute : ClickBehaviorAttribute
{
public override void Execute<TOwner>(IUIComponent<TOwner> component)
{
// TODO: Write an implementation.
}
}
Click
ClickBehaviorAttribute
- the base behavior class for control click implementation.
Responsible for the Control<TOwner>.Click()
method action.
Implementations
- default
ClicksUsingClickMethodAttribute
- the behavior for control clicking byIWebElement.Click()
method. ClicksUsingActionsAttribute
- the behavior for control clicking by using a set of actions:Actions.MoveToElement(IWebElement)
orActions.MoveToElement(IWebElement, int, int)
andActions.Click()
.ClicksUsingScriptAttribute
- the behavior for control clicking by executingHTMLElement.click()
JavaScript method.ClicksOnCellByIndexAttribute
- the behavior for control clicking by actually clicking the nth<td>
cell. There is a sense to apply this behavior to classes inherited fromTableRow<TOwner>
.
Double Click
DoubleClickBehaviorAttribute
- the base behavior class for control double-click implementation.
Responsible for the Control<TOwner>.DoubleClick()
method action.
Implementations
- default
DoubleClicksUsingActionsAttribute
- the behavior for control double-clicking by using a set of actions:Actions.MoveToElement(IWebElement)
orActions.MoveToElement(IWebElement, int, int)
andActions.DoubleClick()
. DoubleClicksUsingScriptAttribute
- the behavior for control double-clicking by executingHTMLElement.dispatchEvent(new Event('dblclick'))
JavaScript.
Right Click
RightClickBehaviorAttribute
- the base behavior class for control right-click implementation.
Responsible for the Control<TOwner>.RightClick()
method action.
Implementations
- default
RightClicksUsingActionsAttribute
- the behavior for control right-clicking by using a set of actions:Actions.MoveToElement(IWebElement)
orActions.MoveToElement(IWebElement, int, int)
and thenActions.ContextClick()
. RightClicksUsingScriptAttribute
- the behavior for control right-clicking by executingHTMLElement.dispatchEvent(new Event('contextmenu'))
JavaScript.
Hover
HoverBehaviorAttribute
- the base behavior class for control hover implementation.
Responsible for the
Implementations
- default
HoversUsingActionsAttribute
- the behavior for control hovering by using one of actions:Actions.MoveToElement(IWebElement)
orActions.MoveToElement(IWebElement, int, int)
.
Focus
FocusBehaviorAttribute
- the base behavior class for control focus implementation.
Responsible for the Control<TOwner>.Focus
method action.
Implementations
- default
FocusesUsingScriptAttribute
- the behavior for control focusing by executingHTMLElement.focus()
JavaScript.
Blur
BlurBehaviorAttribute
- the base behavior class for control blur (removing focus) implementation.
Responsible for the Control<TOwner>.Hover()
method action.
Implementations
- default
BlursUsingScriptAttribute
- the behavior for control blurring by executingHTMLElement.blur()
JavaScript.
Scroll
ScrollBehaviorAttribute
- the base behavior class for scrolling to control.
Responsible for the Control<TOwner>.ScrollTo()
method action.
Implementations
- default
ScrollsUsingScrollToElementActionAttribute
- the behavior for scrolling to control using WebDriver’sActions.ScrollToElement(IWebElement)
action. ScrollsUsingMoveToElementActionAttribute
- the behavior for scrolling to control using WebDriver’sActions.MoveToElement(IWebElement)
action.ScrollsUsingScriptAttribute
- the behavior for scrolling to control using JavaScript. Performselement.scrollIntoView()
function.
Drag and Drop
DragAndDropBehaviorAttribute
- Represents the base behavior class for control drag and drop implementation
Responsible for the Control<TOwner>.DragAndDropTo(Control<TOwner>)
and
Control<TOwner>.DragAndDropTo(Func<TOwner, Control<TOwner>>)
methods action.
Implementations
- default
DragsAndDropsUsingActionsAttribute
- the behavior for drag and drop using WebDriver’sActions
. PerformsActions.DragAndDrop(IWebElement, IWebElement)
action. DragsAndDropsUsingDomEventsAttribute
- the behavior for drag and drop using JavaScript. The script simulates drag and drop by dispatching DOM events: ‘dragstart’, ‘dragenter’, ‘dragover’, ‘drop’ and ‘dragend’.
Drag and Drop to Offset
DragAndDropToOffsetBehaviorAttribute
- the base behavior class for control drag and drop to offset implementation.
Responsible for the Control<TOwner>.DragAndDropToOffset(int, int)
method action.
Implementations
- default
DragsAndDropsToOffsetUsingActionsAttribute
- the behavior for control dragging and dropping to offset using WebDriver’sActions
. PerformsActions.DragAndDropToOffset(IWebElement, int, int)
action.
Get Content
ContentGetBehaviorAttribute
- the base behavior class for getting the component’s content.
Responsible for the UIComponent<TOwner>.Content
property value getting.
Implementations
- default
GetsContentFromSourceAttribute
- the behavior for component content getting from the specified source ofContentSource
enumeration type. By default,ContentSource.Text
is used. GetsContentFromAttributeAttribute
- the behavior for component content getting from HTML attribute by attribute name.
Get Value
ValueGetBehaviorAttribute
- the base behavior class for an implementation of the
EditableTextField<TValue, TOwner>
value getting.
Implementations
- default
GetsValueFromValueAttribute
- the behavior for control value getting fromvalue
attribute. GetsValueFromContentAttribute
- the behavior for control value getting fromIUIComponent<TOwner>.Content
property.
Set Value
ValueSetBehaviorAttribute
- the base behavior class for an implementation of the EditableTextField<TValue, TOwner>
value set.
Implementations
- default
SetsValueUsingClearAndTypeBehaviorsAttribute
- the behavior for control value set by executingValueClearBehaviorAttribute
behavior first; then, if value to set is notnull
or empty, executesTextTypeBehaviorAttribute
behavior. SetsValueUsingScriptAttribute
- the behavior for control value set by executingHTMLElement.value = '{value}'; HTMLElement.dispatchEvent(new Event('change'));
JavaScript.SetsValueUsingSendKeysAttribute
- the behavior for control value set byIWebElement.SendKeys(string)
method.IWebElement.SendKeys(string)
method is invoked only when the value is not null or empty.SetsValueUsingClearAndSendKeysAttribute
- the behavior for control value set by invokingIWebElement.Clear()
andIWebElement.SendKeys(string)
methods.IWebElement.SendKeys(string)
method is invoked only when the value is not null or empty.SetsValueUsingCharByCharTypingAttribute
- the behavior for control value set by clicking on the control element and then typing the text character by character with interval defined inTypingIntervalInSeconds
property.
Clear Value
ValueClearBehaviorAttribute
- the base behavior class for an implementation of control value clearing.
Responsible for the EditableTextField<TValue, TOwner>.Clear()
method action.
Implementations
- default
ClearsValueUsingClearMethodAttribute
- the behavior for control value clearing byIWebElement.Clear()
method. ClearsValueUsingClearMethodOrScriptAttribute
- the behavior for control value clearing by trying to executeIWebElement.Clear()
method. IfInvalidElementStateException
occurs, then clears the value by executingHTMLElement.value = ''; HTMLElement.dispatchEvent(new Event('change'));
JavaScript.ClearsValueUsingScriptAttribute
- the behavior for control value clearing by executingHTMLElement.value = ''; HTMLElement.dispatchEvent(new Event('change'));
JavaScript.ClearsValueUsingCtrlADeleteKeysAttribute
- the behavior for control value clearing by performing “Ctrl+A, Delete” keyboard shortcut.ClearsValueUsingHomeShiftEndDeleteKeysAttribute
- the behavior for control value clearing by performing “Home, Shift+End, Delete” keyboard shortcut.ClearsValueUsingShiftHomeDeleteKeysAttribute
- the behavior for control value clearing by performing “Shift+Home, Delete” keyboard shortcut. Note that “End” key is not pressed in the beginning of the shortcut, as the caret on element by default goes to the end.
Type Text
TextTypeBehaviorAttribute
- the base behavior class for an implementation of control text typing.
Responsible for the EditableTextField<TValue, TOwner>.Type(string)
method action.
Implementations
- default
TypesTextUsingSendKeysAttribute
- the behavior for control text typing byIWebElement.SendKeys(string)
method.IWebElement.SendKeys(string)
method is invoked only when the value is not null or empty. TypesTextUsingSendKeysCharByCharAttribute
- the behavior for control text typing by invokingIWebElement.SendKeys(string)
method for character by character with interval defined inTypingIntervalInSeconds
property.TypesTextUsingFocusBehaviorAndSendKeysAttribute
- the behavior for control text typing by executingFocusBehaviorAttribute
behavior and then invokingIWebElement.SendKeys(string)
method.TypesTextUsingFocusBehaviorAndSendKeysCharByCharAttribute
- the behavior for control text typing by executingFocusBehaviorAttribute
behavior and then invokingIWebElement.SendKeys(string)
method for character by character with interval defined inTypingIntervalInSeconds
property.TypesTextUsingScriptAttribute
- the behavior for control text typing by executingHTMLElement.value += '{value}'; HTMLElement.dispatchEvent(new Event('change'));
JavaScript.
Select Option
SelectOptionBehaviorAttribute
- the base behavior class for option selection of Select<TValue, TOwner>
control.
Implementations
- default
SelectsOptionByTextAttribute
- the behavior for option selection ofSelect<TValue, TOwner>
control using option text. SelectsOptionByValueAttribute
- the behavior for option selection ofSelect<TValue, TOwner>
control using optionvalue
attribute.SelectsOptionByLabelAttributeAttribute
- the behavior for option selection ofSelect<TValue, TOwner>
control using optionlabel
attribute.SelectsOptionByAttributeAttribute
- the behavior for option selection ofSelect<TValue, TOwner>
control using specified option attribute.