Skip to content

Commit c0d73e0

Browse files
committed
Add methods to help with css selector processing
1 parent 7e65050 commit c0d73e0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,22 @@ def _pick_select_option(self, dropdown_selector, option,
13211321

13221322
############
13231323

1324+
def _recalculate_selector(self, selector, by):
1325+
# Try to determine the type of selector automatically
1326+
if page_utils.is_xpath_selector(selector):
1327+
by = By.XPATH
1328+
if page_utils.is_link_text_selector(selector):
1329+
selector = page_utils.get_link_text_from_selector(selector)
1330+
by = By.LINK_TEXT
1331+
return (selector, by)
1332+
1333+
def _make_css_match_first_element_only(self, selector):
1334+
# Only get the first match
1335+
last_syllable = selector.split(' ')[-1]
1336+
if ':' not in last_syllable and ':contains' not in selector:
1337+
selector += ':first'
1338+
return selector
1339+
13241340
def _demo_mode_pause_if_active(self, tiny=False):
13251341
if self.demo_mode:
13261342
if self.demo_sleep:

0 commit comments

Comments
 (0)