diff --git a/airgun/entities/host_new.py b/airgun/entities/host_new.py index e172114be..78aff809e 100644 --- a/airgun/entities/host_new.py +++ b/airgun/entities/host_new.py @@ -61,6 +61,23 @@ def create(self, values): host_view.flash.assert_no_error() host_view.flash.dismiss() + def search_autocomplete(self, value): + """Search the All Hosts page and return autocomplete suggestions or error messages.""" + view = self.navigate_to(self, 'NewUIAll') + view.searchbox.clear() + view.searchbox.fill(value) + results = ( + wait_for( + view.autocomplete_menu.read, + timeout=5, + delay=0.5, + handle_exception=True, + silent_failure=True, + )[0] + or [] + ) + return results + def get_details(self, entity_name, widget_names=None): """Read host values from Host Details page, optionally only the widgets in widget_names will be read.""" view = self.navigate_to(self, 'NewDetails', entity_name=entity_name) diff --git a/airgun/views/all_hosts.py b/airgun/views/all_hosts.py index e0655a9d8..b89fa19ee 100644 --- a/airgun/views/all_hosts.py +++ b/airgun/views/all_hosts.py @@ -35,7 +35,7 @@ WizardStepView, ) from airgun.views.host_new import ManageColumnsView, PF5CheckboxTreeView -from airgun.widgets import ItemsList, SearchInput +from airgun.widgets import ItemsList, PF5NavSearchMenu, SearchInput class MenuToggleDropdownInTable(PF5Dropdown): @@ -122,6 +122,7 @@ class AllHostsTableView(BaseLoggedInView, SearchableViewMixinPF4): 2: MenuToggleDropdownInTable(), }, ) + autocomplete_menu = PF5NavSearchMenu(component_id='search-autocomplete-menu') alert_message = Text('.//div[contains(@class, "pf-v5-c-alert")]') # Host status icon and popover widgets