Skip to content

oauth_select

OAuthSelect(browser, container, searchable=True)

Bases: BaseControl

Entity-Component: Select

OAuthSelect Javascript framework: OAuthSelect

A dropdown which can select only one value

Parameters:

Name Type Description Default
browser

The selenium webdriver

required
container

The locator of the container where the control is located in.

required
Source code in pytest_splunk_addon_ui_smartx/components/controls/oauth_select.py
30
31
32
33
34
35
36
37
38
39
40
41
42
def __init__(self, browser, container, searchable=True):
    """
    :param browser: The selenium webdriver
    :param container: The locator of the container where the control is located in.
    """

    super().__init__(browser, container)
    self.elements.update(
        {
            "root": Selector(select=container.select + ' [data-test="select"]'),
            "values": Selector(select=container.select + ' [data-test="option"]'),
        }
    )

get_value()

Gets the selected value :return: Str The elected value within the dropdown, else returns blank

Source code in pytest_splunk_addon_ui_smartx/components/controls/oauth_select.py
68
69
70
71
72
73
74
75
76
def get_value(self):
    """
    Gets the selected value
        :return: Str The elected value within the dropdown, else returns blank
    """
    try:
        return self.root.get_attribute("data-test-value")
    except:
        return ""

list_of_values()

Gets the list of value from the Single Select :returns: List of options from the single select

Source code in pytest_splunk_addon_ui_smartx/components/controls/oauth_select.py
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def list_of_values(self):
    """
    Gets the list of value from the Single Select
        :returns: List of options from the single select
    """
    selected_val = self.get_value()
    self.root.click()
    first_element = None
    list_of_values = []
    popover_id = "#" + self.root.get_attribute("data-test-popover-id")
    self.elements.update(
        {"values": Selector(select=popover_id + ' [data-test="option"]')}
    )
    for each in self.get_elements("values"):
        list_of_values.append(each.text.strip())
    return list_of_values

select(value)

Selects the value within hte select dropdown :param value: the value to select :return: Bool if successful in selection, else raises an error

Source code in pytest_splunk_addon_ui_smartx/components/controls/oauth_select.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
def select(self, value):
    """
    Selects the value within hte select dropdown
        :param value: the value to select
        :return: Bool if successful in selection, else raises an error
    """

    self.root.click()
    popover_id = "#" + self.root.get_attribute("data-test-popover-id")
    self.elements.update(
        {
            "values": Selector(
                select=popover_id
                + ' [data-test="option"]:not([data-test-selected="true"]) [data-test="label"]'
            )
        }
    )
    for each in self.get_elements("values"):
        if each.text.strip().lower() == value.lower():
            each.click()
            return True
    else:
        raise ValueError("{} not found in select list".format(value))