Adding ability to hover

Added hover functionality for ui.

Change-Id: I41c9fb5465ef1c6b4189a2681650f2e00bcd88dc
Signed-off-by: jpike <jason.pike@windriver.com>
This commit is contained in:
jpike
2025-08-13 10:54:45 -04:00
parent 6250850b2e
commit bfd6bbc293
4 changed files with 46 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
from abc import abstractmethod
from typing import List
from selenium.webdriver import ActionChains
from framework.web.condition.web_condition import WebCondition
from framework.web.web_locator import WebLocator
@@ -22,6 +24,7 @@ class WebAction:
self.webdriver = webdriver
self.web_locator = web_locator
self.web_conditions = web_conditions
self.actions = ActionChains(self.webdriver)
self.timeout = 30
def get_webdriver(self):

View File

@@ -0,0 +1,27 @@
from framework.web.action.web_action import WebAction
class WebActionHover(WebAction):
"""
Class representing a Web Click action.
"""
def perform_action(self, web_element, *args):
"""
Override the parent's perform action with a hover
Args:
web_element: Element to hover on.
*args: Unused arguments to follow the override signature.
Returns: None
"""
self.actions.move_to_element(web_element).perform()
def __str__(self):
"""
String representation of this action.
Returns:
"""
return "Hover"

View File

@@ -136,7 +136,6 @@ class WebActionExecutor:
state = "NOT_FOUND"
except Exception as e:
get_logger().log_debug(e)
get_logger().log_debug("Exception occurred during action, moving to UNKNOWN state")
state = "UNKNOWN"

View File

@@ -8,6 +8,7 @@ from config.configuration_manager import ConfigurationManager
from framework.logging.automation_logger import get_logger
from framework.web.action.web_action_click import WebActionClick
from framework.web.action.web_action_get_text import WebActionGetText
from framework.web.action.web_action_hover import WebActionHover
from framework.web.action.web_action_send_keys import WebActionSendKeys
from framework.web.action.web_action_set_text import WebActionSetText
from framework.web.condition.web_condition import WebCondition
@@ -96,6 +97,21 @@ class WebDriverCore:
action_executor = WebActionExecutor(action)
action_executor.execute_action()
def hover(self, locator: WebLocator, conditions: List[WebCondition] = []) -> None:
"""
Hover on the target element
Args:
locator (WebLocator): The locator of the element that we want to hover on.
conditions (List[WebCondition]): Conditions that must be satisfied for the Action to be declared successful.
Returns: None
"""
action = WebActionHover(self.driver, locator, conditions)
action_executor = WebActionExecutor(action)
action_executor.execute_action()
def send_keys(self, locator: WebLocator, keys: str, conditions: List[WebCondition] = []) -> None:
"""
Sends Keys directly to a WebElement. SendText should be favored wherever it can be used.