Mixins - Element functionality extensions¶
Mixins allow for elements to “share” common functions with other elements. Elements inherit from the Element base class and can be “extended” by any number of mixins. An example would be:
from sda.element import Element
from sda.mixins import ElementMixin
class FooMixin(ElementMixin):
def foo(self):
return 1
class BarMixin(ElementMixin):
def bar(self):
return 0
class Foo(Element, FooMixin, BarMixin):
pass
f = Foo()
f.bar()
# Returns
0
f.foo()
# Returns
1
sda.mixins
-
class
sda.mixins.
ClickMixin
Bases:
sda.mixins.ElementMixin
The ClickMixin Implementation
-
click
() Click element
Returns:
-
double_click
() Double-click element
Returns:
-
hover
() Simulate hovering over element
Returns:
-
-
class
sda.mixins.
InputMixin
Bases:
sda.mixins.ElementMixin
The InputMixin implementation
-
input
(*args, **kwargs) Parameters: - args – Text to send to the input field
- kwargs – clear - True if user wants to clear the field before assigning text
Returns: True, if text is assigned
Return type: bool
-
value
Return value of input
Returns: Input value Return type: str
-
-
class
sda.mixins.
SelectMixin
Bases:
sda.mixins.ElementMixin
The SelectMixin implementation
-
deselect_all
() Deselect all selected options
Returns: True, if all options are deselected Return type: bool
-
deselect_by_index
(option) Deselect option by index [i]
Parameters: option – Select option index Returns: True, if option is deselected Return type: bool
-
deselect_by_text
(option) Deselect option by display text
Parameters: option – Select option Returns: True, if option is deselected Return type: bool
-
deselect_by_value
(option) Deselect option by option value
Parameters: option – Select option value Returns: True, if option is deselected Return type: bool
-
options
() Returns all Select options
Returns: List of options Return type: list
-
select_by_index
(option) Select option at index [i]
Parameters: option (str) – Select index Returns: True, if the option is selected Return type: bool
-
select_by_text
(option) Select option by display text
Parameters: option (str) – Select option Returns: True, if the option is selected Return type: bool
-
select_by_value
(option) Select option by option value
Parameters: option (str) – Select option value Returns: True, if the option is selected Return type: bool
-
selected_first
() Select first option
Returns: First option element Return type: WebElement
-
selected_options
() Returns a list of selected options
Returns: List of options Return type: list
-
-
class
sda.mixins.
SelectiveMixin
Bases:
sda.mixins.ClickMixin
The SelectiveMixin implementation
-
deselect
() Deselect this element
Returns:
-
select
() Select this element
Returns:
-
selected
() Return True if element is selected
Returns: True, if the element is selected Return type: bool
-
-
class
sda.mixins.
TextMixin
Bases:
sda.mixins.ElementMixin
The TextMixin implementation
-
text
() Returns the text within an element
Returns: Element text Return type: str
-
visible_text
() Returns the visible text within an element
Returns: Element text Return type: str
-