Skip to content

base_web_client_actions

WebClientActions

Bases: WebDriverInteractions, ElementInteractions, UtilityMethods

A class used to represent WebClientActions.

Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\base_web_client_actions.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
class WebClientActions(WebDriverInteractions, ElementInteractions, UtilityMethods):
    """A class used to represent WebClientActions."""

    def __init__(
            self,
            web_driver: WebDriver = None,
            default_explicit_wait: int = None,
            default_implicit_wait: int = None,
    ):
        """Initializes WebClientActions with a driver and optional explicit
        wait.

        Args:
            web_driver: The selenium webdriver instance.
                            if not provided, it will be picked from Session Store
            default_explicit_wait: The default explicit wait time (in seconds).
                                   If not provided, it will be retrieved from ConfigUtils.
        """
        super().__init__(
            web_driver=web_driver,
            default_explicit_wait=default_explicit_wait,
            default_implicit_wait=default_implicit_wait,
        )
        self.navigate_methods = WebDriverInteractions(
            web_driver=self.driver,
            default_explicit_wait=self.default_explicit_wait,
            default_implicit_wait=self.default_implicit_wait,
        )
        self.element_interactions = ElementInteractions(
            web_driver=self.driver,
            default_explicit_wait=self.default_explicit_wait,
            default_implicit_wait=self.default_implicit_wait,
        )

    def set_implicit_wait(self, wait_time: int = None) -> None:
        """Set the implicit wait time for the driver. If no value is provided,
        the default implicit wait time from the configuration file will be
        used.

        Examples:
            >> from cafex_ui import CafeXWeb
            >> CafeXWeb().set_implicit_wait(30)

        Args:
            wait_time: The implicit wait time in seconds.

        Returns:
            None
        """
        try:
            wait_time = wait_time or self.default_implicit_wait
            self.driver.implicitly_wait(wait_time)
        except Exception as e:
            self.logger.exception("Exception in set_implicit_wait method. Exception Details: %s", e)
            raise e

__init__(web_driver=None, default_explicit_wait=None, default_implicit_wait=None)

Initializes WebClientActions with a driver and optional explicit wait.

Parameters:

Name Type Description Default
web_driver WebDriver

The selenium webdriver instance. if not provided, it will be picked from Session Store

None
default_explicit_wait int

The default explicit wait time (in seconds). If not provided, it will be retrieved from ConfigUtils.

None
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\base_web_client_actions.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def __init__(
        self,
        web_driver: WebDriver = None,
        default_explicit_wait: int = None,
        default_implicit_wait: int = None,
):
    """Initializes WebClientActions with a driver and optional explicit
    wait.

    Args:
        web_driver: The selenium webdriver instance.
                        if not provided, it will be picked from Session Store
        default_explicit_wait: The default explicit wait time (in seconds).
                               If not provided, it will be retrieved from ConfigUtils.
    """
    super().__init__(
        web_driver=web_driver,
        default_explicit_wait=default_explicit_wait,
        default_implicit_wait=default_implicit_wait,
    )
    self.navigate_methods = WebDriverInteractions(
        web_driver=self.driver,
        default_explicit_wait=self.default_explicit_wait,
        default_implicit_wait=self.default_implicit_wait,
    )
    self.element_interactions = ElementInteractions(
        web_driver=self.driver,
        default_explicit_wait=self.default_explicit_wait,
        default_implicit_wait=self.default_implicit_wait,
    )

set_implicit_wait(wait_time=None)

Set the implicit wait time for the driver. If no value is provided, the default implicit wait time from the configuration file will be used.

Examples:

from cafex_ui import CafeXWeb CafeXWeb().set_implicit_wait(30)

Parameters:

Name Type Description Default
wait_time int

The implicit wait time in seconds.

None

Returns:

Type Description
None

None

Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\base_web_client_actions.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def set_implicit_wait(self, wait_time: int = None) -> None:
    """Set the implicit wait time for the driver. If no value is provided,
    the default implicit wait time from the configuration file will be
    used.

    Examples:
        >> from cafex_ui import CafeXWeb
        >> CafeXWeb().set_implicit_wait(30)

    Args:
        wait_time: The implicit wait time in seconds.

    Returns:
        None
    """
    try:
        wait_time = wait_time or self.default_implicit_wait
        self.driver.implicitly_wait(wait_time)
    except Exception as e:
        self.logger.exception("Exception in set_implicit_wait method. Exception Details: %s", e)
        raise e