The following test case for the multipleSelect field will not work as it should and will result in failure.
In the below test case, the multi_select
field is of type multipleSelect with the list of values ["Device1", "Device2", "Device3", "Alert1", "Alert2"]
. It will first list values starting with "Device", then try to search the list of values with "DeviceAlert". Ideally, it should first list the values starting with "Device", then list values starting with "Alert".
def test_inputs_multiple_select_field(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""
Check the list of options for the 'multi_select' field
"""
input_page = InputPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
input_page.inputs_dropdown.select(const.INPUT_TYPE)
input_page.test_entity.account.wait_for_values()
self.assert_util(
len(
input_page.test_entity.multi_select.search_get_list(
"Device"
)
),
3,
)
self.assert_util(
len(
input_page.test_entity.multi_select.search_get_list(
"Alert"
)
),
2,
)
Cause:
For multipleSelect component, there is no method to clear the search textbox in multi_select.py file.
Adding this function in multi_select.py will solve this issue.
def clear_text(self):
"""
Clears the search box value in the multi-select field
"""
self.input.clear()
Updated Test Case
def test_inputs_multiple_select_field(
self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
):
"""
Check the list of options for the 'multi_select' field
"""
input_page = InputPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
input_page.inputs_dropdown.select(const.INPUT_TYPE)
input_page.test_entity.account.wait_for_values()
self.assert_util(
len(
input_page.test_entity.multi_select.search_get_list(
"Device"
)
),
3,
)
# updated test case with clear_text() function
input_page.test_entity.multi_select.clear_text()
self.assert_util(
len(
input_page.test_entity.multi_select.search_get_list(
"Alert"
)
),
2,
)