Add "locator()" as a shortcut for "get_element()"

This commit is contained in:
Michael Mintz 2023-10-01 12:58:23 -04:00
parent eea244127c
commit edf0fce6e7
2 changed files with 6 additions and 11 deletions

View File

@ -744,6 +744,7 @@ self.generate_traffic_chain(pages, loops=1)
self.get_element(selector, by="css selector", timeout=None)
# Duplicates:
# self.locator(selector, by="css selector", timeout=None)
# self.wait_for_element_present(selector, by="css selector", timeout=None)
self.wait_for_query_selector(selector, by="css selector", timeout=None)

View File

@ -8898,12 +8898,11 @@ class BaseCase(unittest.TestCase):
def get_element(self, selector, by="css selector", timeout=None):
"""Same as wait_for_element_present() - returns the element.
The element does not need be visible (it may be hidden)."""
self.__check_scope()
if not timeout:
timeout = settings.LARGE_TIMEOUT
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
timeout = self.__get_new_timeout(timeout)
selector, by = self.__recalculate_selector(selector, by)
return self.wait_for_element_present(selector, by=by, timeout=timeout)
def locator(self, selector, by="css selector", timeout=None):
"""Same as wait_for_element_present() - returns the element.
The element does not need be visible (it may be hidden)."""
return self.wait_for_element_present(selector, by=by, timeout=timeout)
def wait_for_query_selector(
@ -9000,11 +8999,6 @@ class BaseCase(unittest.TestCase):
def find_element(self, selector, by="css selector", timeout=None):
"""Same as wait_for_element_visible() - returns the element"""
self.__check_scope()
if not timeout:
timeout = settings.LARGE_TIMEOUT
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
timeout = self.__get_new_timeout(timeout)
return self.wait_for_element_visible(selector, by=by, timeout=timeout)
def assert_element(self, selector, by="css selector", timeout=None):