Skip to content

Commit edf0fce

Browse files
committed
Add "locator()" as a shortcut for "get_element()"
1 parent eea2441 commit edf0fce

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

help_docs/method_summary.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ self.generate_traffic_chain(pages, loops=1)
744744

745745
self.get_element(selector, by="css selector", timeout=None)
746746
# Duplicates:
747+
# self.locator(selector, by="css selector", timeout=None)
747748
# self.wait_for_element_present(selector, by="css selector", timeout=None)
748749

749750
self.wait_for_query_selector(selector, by="css selector", timeout=None)

seleniumbase/fixtures/base_case.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8898,12 +8898,11 @@ def wait_for_element(self, selector, by="css selector", timeout=None):
88988898
def get_element(self, selector, by="css selector", timeout=None):
88998899
"""Same as wait_for_element_present() - returns the element.
89008900
The element does not need be visible (it may be hidden)."""
8901-
self.__check_scope()
8902-
if not timeout:
8903-
timeout = settings.LARGE_TIMEOUT
8904-
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
8905-
timeout = self.__get_new_timeout(timeout)
8906-
selector, by = self.__recalculate_selector(selector, by)
8901+
return self.wait_for_element_present(selector, by=by, timeout=timeout)
8902+
8903+
def locator(self, selector, by="css selector", timeout=None):
8904+
"""Same as wait_for_element_present() - returns the element.
8905+
The element does not need be visible (it may be hidden)."""
89078906
return self.wait_for_element_present(selector, by=by, timeout=timeout)
89088907

89098908
def wait_for_query_selector(
@@ -9000,11 +8999,6 @@ def assert_elements_present(self, *args, **kwargs):
90008999

90019000
def find_element(self, selector, by="css selector", timeout=None):
90029001
"""Same as wait_for_element_visible() - returns the element"""
9003-
self.__check_scope()
9004-
if not timeout:
9005-
timeout = settings.LARGE_TIMEOUT
9006-
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
9007-
timeout = self.__get_new_timeout(timeout)
90089002
return self.wait_for_element_visible(selector, by=by, timeout=timeout)
90099003

90109004
def assert_element(self, selector, by="css selector", timeout=None):

0 commit comments

Comments
 (0)