Skip to content

base_control

BaseControl(browser, container)

Bases: BaseComponent

Purpose: The base class for the controls present in the entity. It is implemented to simplify accessing of controls.

Parameters:

Name Type Description Default
browser

The instance of the selenium webdriver

required
container

The container in which the component is located at.

required
Source code in pytest_splunk_addon_ui_smartx/components/controls/base_control.py
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
def __init__(self, browser, container):
    """
    :param browser: The instance of the selenium webdriver
    :param container: The container in which the component is located at.
    """
    super().__init__(browser, container)
    self.elements.update(
        {"help_text": Selector(select=container.select + ' [data-test="help"]')}
    )
    self.elements.update(
        {
            "label_text": Selector(
                select=container.select + ' [data-test="label"][id]'
            )
        }
    )
    self.elements.update(
        {
            "tooltip_icon": Selector(
                select=container.select + ' [data-test="tooltip"]'
            )
        }
    )
    self.elements.update(
        {"tooltip_text": Selector(select='[data-test="screen-reader-content"]')}
    )
    self.browser = browser

get_input_label()

get field label value

Source code in pytest_splunk_addon_ui_smartx/components/controls/base_control.py
64
65
66
67
68
69
70
71
72
73
74
def get_input_label(self):
    """
    get field label value
    """
    GET_PARENT_ELEMENT = (
        "if(arguments[0].hasChildNodes()){var r='';var C=arguments[0].childNodes;"
        "for(var n=0;n<C.length;n++){if(C[n].nodeType==Node.TEXT_NODE){r+=' '+C[n].nodeValue}}"
        "return r.trim()}else{return arguments[0].innerText}"
    )
    parent_text = self.browser.execute_script(GET_PARENT_ELEMENT, self.label_text)
    return parent_text