Skip to content

textbox

TextBox(browser, container, encrypted=False)

Bases: BaseControl

Entity-Component: TextBox

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/textbox.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def __init__(self, browser, container, encrypted=False):
    """
    :param browser: The selenium webdriver
    :param container: The locator of the container where the control is located in.
    """
    super().__init__(browser, container)
    self.encrypted = encrypted
    self.container = container
    self.browser = browser
    if container.by == "xpath":
        self.elements.update(
            {"input": Selector(by=By.XPATH, select=container.select + "//input")}
        )
    else:
        self.elements.update(
            {"input": Selector(select=container.select + " input")}
        )

clear_text()

Clears the textbox value

Source code in pytest_splunk_addon_ui_smartx/components/controls/textbox.py
82
83
84
85
86
def clear_text(self):
    """
    Clears the textbox value
    """
    self.input.clear()

get_type()

Get type of value entered in textbox :return: Type of input within the textbox

Source code in pytest_splunk_addon_ui_smartx/components/controls/textbox.py
88
89
90
91
92
93
def get_type(self):
    """
    Get type of value entered in textbox
        :return: Type of input within the textbox
    """
    return self.input.get_attribute("type").strip()

get_value()

get value from the textbox :return: Str The current value of the textbox

Source code in pytest_splunk_addon_ui_smartx/components/controls/textbox.py
66
67
68
69
70
71
def get_value(self):
    """
    get value from the textbox
        :return: Str The current value of the textbox
    """
    return self.input.get_attribute("value").strip()

is_editable()

Returns True if the Textbox is editable, False otherwise :return: Bool whether or not the textbox is editable

Source code in pytest_splunk_addon_ui_smartx/components/controls/textbox.py
73
74
75
76
77
78
79
80
def is_editable(self):
    """
    Returns True if the Textbox is editable, False otherwise
        :return: Bool whether or not the textbox is editable
    """
    return not bool(
        self.input.get_attribute("readonly") or self.input.get_attribute("disabled")
    )

set_value(value)

set value of the textbox

Source code in pytest_splunk_addon_ui_smartx/components/controls/textbox.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def set_value(self, value):
    """
    set value of the textbox
    """
    # first condition added for safari browser
    self.wait_to_be_clickable("input")
    if self.browser.capabilities["browserName"] == "Safari":
        self.input.send_keys(Keys.COMMAND)
        self.input.send_keys("a")
    elif os_base == "Darwin":
        self.input.send_keys(Keys.COMMAND, "a")
    else:
        self.input.send_keys(Keys.CONTROL, "a")
    self.input.send_keys(Keys.DELETE)
    self.input.send_keys(value)

wait_to_be_editable()

Wait for the textbox field to be editable

Source code in pytest_splunk_addon_ui_smartx/components/controls/textbox.py
 95
 96
 97
 98
 99
100
101
102
103
def wait_to_be_editable(self):
    """
    Wait for the textbox field to be editable
    """

    def _wait_for_field_to_be_editable(driver):
        return self.is_editable()

    self.wait_for(_wait_for_field_to_be_editable, msg="Field is uneditable")