def search_entity(self, element_name, element_locator, search_key=None, katello=None, timeout=None): """Uses the search box to locate an element from a list of elements.""" search_key = search_key or 'name' element = None if katello: searchbox = self.wait_until_element(common_locators['kt_search']) search_button = self.wait_until_element( common_locators['kt_search_button']) else: searchbox = self.wait_until_element(common_locators['search']) search_button = self.wait_until_element( common_locators['search_button']) # Do not proceed if searchbox is not found if searchbox is None: # For katello, search box should be always present on the page # no matter we have entity on the page or not... if katello: raise UINoSuchElementError('Search box not found.') # ...but not for foreman return None else: searchbox.clear() if search_button: searchbox.send_keys( u'{0} = {1}'.format( search_key, escape_search(element_name)) ) search_button.click() else: searchbox.send_keys(escape_search(element_name)) if timeout: element = self.wait_until_element( (element_locator[0], element_locator[1] % element_name), timeout=timeout, ) else: element = self.wait_until_element( (element_locator[0], element_locator[1] % element_name)) return element
def search(self, element_name): """Searches existing Subscription from UI""" strategy = locators["subs.subscription_search"][0] value = locators["subs.subscription_search"][1] searchbox = self.wait_until_element(common_locators["kt_search"]) if searchbox: searchbox.clear() searchbox.send_keys(escape_search(element_name)) self.find_element(common_locators["kt_search_button"]).click() self.wait_for_ajax() return self.wait_until_element((strategy, value))
def search_entity(self, element_name, element_locator, search_key=None, katello=None, timeout=None): """ Uses the search box to locate an element from a list of elements. """ search_key = search_key or "name" element = None if katello: searchbox = self.wait_until_element(common_locators["kt_search"]) search_button = self.wait_until_element(common_locators ["kt_search_button"]) else: searchbox = self.wait_until_element(common_locators["search"]) search_button = self.wait_until_element(common_locators ["search_button"]) # Do not proceed if searchbox is not found if searchbox is None: raise Exception("Search box not found.") else: searchbox.clear() if search_button: searchbox.send_keys(search_key + " = " + escape_search(element_name)) search_button.click() else: searchbox.send_keys(escape_search(element_name)) if timeout: element = self.wait_until_element( (element_locator[0], element_locator[1] % element_name), timeout=timeout, ) else: element = self.wait_until_element( (element_locator[0], element_locator[1] % element_name)) return element
def search(self, element_name): """Uses the search box to locate an element from a list of elements """ element = None strategy = locators["contentviews.key_name"][0] value = locators["contentviews.key_name"][1] searchbox = self.wait_until_element(common_locators["kt_search"]) if searchbox: searchbox.clear() searchbox.send_keys(escape_search(element_name)) self.find_element(common_locators["kt_search_button"]).click() self.wait_for_ajax() element = self.wait_until_element((strategy, value % element_name)) return element
def search(self, element_name): """Uses the search box to locate an element from a list of elements.""" Navigator(self.browser).go_to_gpg_keys() self.wait_for_ajax() element = None strategy, value = locators["gpgkey.key_name"] searchbox = self.wait_until_element(common_locators["kt_search"]) if searchbox: searchbox.clear() searchbox.send_keys(escape_search(element_name)) self.wait_for_ajax() self.click(common_locators["kt_search_button"]) element = self.wait_until_element((strategy, value % element_name)) return element
def search(self, element_name): """ Uses the search box to locate an element from a list of elements. """ Navigator(self.browser).go_to_gpg_keys() self.wait_for_ajax() element = None strategy, value = locators["gpgkey.key_name"] searchbox = self.wait_until_element(common_locators["kt_search"]) if searchbox: searchbox.clear() searchbox.send_keys(escape_search(element_name)) self.wait_for_ajax() self.wait_until_element( common_locators["kt_search_button"]).click() element = self.wait_until_element((strategy, value % element_name)) return element
def test_escapes_double_quotes_and_backslash(self): """Tests if escape search escapes backslashes""" self.assertEqual(escape_search('termwith"and\\')[1:-1], 'termwith\\"and\\\\')
def test_wraps_in_double_quotes(self): """Tests if escape search wraps the term in double quotes""" term = escape_search('term') self.assertEqual(term[0], '"') self.assertEqual(term[-1], '"')
def test_escapes_double_quotes(self): """Tests if escape search escapes double quotes""" self.assertEqual(escape_search('termwith"')[1:-1], 'termwith\\"')
def test_escapes_backslash(self): """Tests if escape search escapes backslashes""" self.assertEqual(escape_search('termwith\\')[1:-1], 'termwith\\\\')
def test_return_type(self): """Tests if escape search returns a unicode string""" self.assertIsInstance(escape_search('search term'), unicode)