Skip to content

input_table

InputTable(browser, container, mapping={})

Bases: Table

Component: Input Table Input table has enable/disable, more-info views additionally to configuration table.

Parameters:

Name Type Description Default
browser

The selenium webdriver

required
container

Container in which the table is located. Of type dictionary: {“by”:…, “select”:…}

required
mapping

If the table headers are different from it’s html-label, provide the mapping as dictionary. For ex, {“Status”: “disabled”}

{}
Source code in pytest_splunk_addon_ui_smartx/components/input_table.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def __init__(self, browser, container, mapping={}):
    """
    :param browser: The selenium webdriver
    :param container: Container in which the table is located. Of type dictionary: {"by":..., "select":...}
    :param mapping: If the table headers are different from it's html-label, provide the mapping as dictionary. For ex, {"Status": "disabled"}
    """
    super().__init__(browser, container, mapping)

    self.elements.update(
        {
            "switch_button_status": Selector(select='[data-disabled="true"]'),
            "status_toggle": Selector(
                select='button[data-test="button"][role="switch"]'
            ),
            "switch_to_page": Selector(
                select=container.select + " [data-test-page]"
            ),
            "input_status": Selector(
                select=container.select
                + ' [data-test="cell"][data-column="disabled"]'
            ),
        }
    )
    self.container = container

input_status_toggle(name, enable)

This function sets the table row status as either enabled or disabled. If it is already enabled then it reuturns an exception :param name: Str The row that we want to enable st the status to as enabled or disabled :param enable: Bool Whether or not we want the table field to be set to enable or disable :return: Bool whether or not enabling or disabling the field was successful, If the field was already in the state we wanted it in, then it will return an exception

Source code in pytest_splunk_addon_ui_smartx/components/input_table.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
def input_status_toggle(self, name, enable):
    """
    This function sets the table row status as either enabled or disabled. If it is already enabled then it reuturns an exception
        :param name: Str The row that we want to enable st the status to as enabled or disabled
        :param enable: Bool Whether or not we want the table field to be set to enable or disable
        :return: Bool whether or not enabling or disabling the field was successful, If the field was already in the state we wanted it in, then it will return an exception
    """
    _row = self._get_row(name)
    status_button = _row.find_element(
        *list(self.elements["status_toggle"]._asdict().values())
    )
    input_enabled = (
        True
        if status_button.get_attribute("data-selected").lower().strip() == "true"
        else False
    )
    if enable:
        if input_enabled:
            raise Exception("The input is already enabled")
        else:
            status_button.click()
            self.wait_until("switch_button_status")
            return True
    else:
        if not input_enabled:
            raise Exception("The input is already disabled")
        else:
            status_button.click()
            self.wait_until("switch_button_status")
            return True