@@ -44,6 +44,8 @@ class Action(Enum):
4444 ELEMENT_SHOULD_NOT_EXIST = "ELEMENT_SHOULD_NOT_EXIST"
4545 ELEMENT_SHOULD_BE_ENABLED = "ELEMENT_SHOULD_BE_ENABLED"
4646 ELEMENT_SHOULD_BE_DISABLED = "ELEMENT_SHOULD_BE_DISABLED"
47+ ELEMENT_SHOULD_BE_OFFSCREEN = "ELEMENT_SHOULD_BE_OFFSCREEN"
48+ ELEMENT_SHOULD_NOT_BE_OFFSCREEN = "ELEMENT_SHOULD_NOT_BE_OFFSCREEN"
4749 WAIT_UNTIL_ELEMENT_IS_OFFSCREEN = "WAIT_UNTIL_ELEMENT_IS_OFFSCREEN"
4850 WAIT_UNTIL_ELEMENT_IS_ENABLED = "WAIT_UNTIL_ELEMENT_IS_ENABLED"
4951 WAIT_UNTIL_ELEMENT_EXIST = "WAIT_UNTIL_ELEMENT_EXIST"
@@ -110,6 +112,10 @@ def execute_action(self, action: Action, values: Container):
110112 lambda : self ._element_should_be_enabled (values ["xpath" ]),
111113 self .Action .ELEMENT_SHOULD_BE_DISABLED :
112114 lambda : self ._element_should_be_disabled (values ["xpath" ]),
115+ self .Action .ELEMENT_SHOULD_BE_OFFSCREEN :
116+ lambda : self ._element_should_be_offscreen (values ["xpath" ]),
117+ self .Action .ELEMENT_SHOULD_NOT_BE_OFFSCREEN :
118+ lambda : self ._element_should_not_be_offscreen (values ["xpath" ]),
113119 self .Action .ELEMENT_SHOULD_EXIST :
114120 lambda : self ._element_should_exist (values ["xpath" ], values ["use_exception" ]),
115121 self .Action .ELEMENT_SHOULD_NOT_EXIST :
@@ -337,6 +343,38 @@ def _element_should_be_disabled(self, xpath: str):
337343 if enabled :
338344 raise FlaUiError (FlaUiError .ElementNotDisabled .format (xpath ))
339345
346+ def _element_should_be_offscreen (self , xpath : str ):
347+ """
348+ Checks if the element with the given xpath is offscreen
349+
350+ Args:
351+ xpath (string): XPath identifier from element.
352+
353+ Raises:
354+ FlaUiError: If node could not be found from xpath.
355+ FlaUiError: If node by xpath is not offscreen.
356+ """
357+ offscreen = self ._element_is_offscreen (xpath )
358+
359+ if not offscreen :
360+ raise FlaUiError (FlaUiError .ElementNotOffscreen .format (xpath ))
361+
362+ def _element_should_not_be_offscreen (self , xpath : str ):
363+ """
364+ Checks if the element with the given xpath not offscreen
365+
366+ Args:
367+ xpath (string): XPath identifier from element.
368+
369+ Raises:
370+ FlaUiError: If node could not be found from xpath.
371+ FlaUiError: If node by xpath is offscreen.
372+ """
373+ offscreen = self ._element_is_offscreen (xpath )
374+
375+ if offscreen :
376+ raise FlaUiError (FlaUiError .ElementIsOffscreen .format (xpath ))
377+
340378 def _wait_until_element_is_offscreen (self , xpath : str , retries : int ):
341379 """Waits until element is offscreen or timeout occurred.
342380
0 commit comments