Skip to content

Commit 84ca2d3

Browse files
committed
Add new way of extracting link text from a selector
1 parent 4b52668 commit 84ca2d3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

seleniumbase/fixtures/page_utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ def is_xpath_selector(selector):
4343
return False
4444

4545

46+
def is_link_text_selector(selector):
47+
"""
48+
A basic method to determine if a selector is a link text selector.
49+
"""
50+
if (selector.startswith('link=') or
51+
selector.startswith('link_text=')):
52+
return True
53+
return False
54+
55+
56+
def get_link_text_from_selector(selector):
57+
"""
58+
A basic method to get the link text from a link text selector.
59+
"""
60+
if selector.startswith('link='):
61+
return selector.split('link=')[1]
62+
elif selector.startswith('link_text='):
63+
return selector.split('link_text=')[1]
64+
return selector
65+
66+
4667
def is_valid_url(url):
4768
regex = re.compile(
4869
r'^(?:http)s?://' # http:// or https://

0 commit comments

Comments
 (0)