mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
查找元素语句增加超简洁方式
This commit is contained in:
parent
6421b43aa9
commit
c262a978f7
@ -113,6 +113,18 @@ def str_to_loc(loc: str) -> tuple:
|
|||||||
else:
|
else:
|
||||||
loc = loc.replace('#', '@id=', 1)
|
loc = loc.replace('#', '@id=', 1)
|
||||||
|
|
||||||
|
if loc.startswith(('x:', 'x=')):
|
||||||
|
loc = f'xpath:{loc[2:]}'
|
||||||
|
|
||||||
|
if loc.startswith(('c:', 'c=')):
|
||||||
|
loc = f'css:{loc[2:]}'
|
||||||
|
|
||||||
|
if loc.startswith(('t:', 't=')):
|
||||||
|
loc = f'tag:{loc[2:]}'
|
||||||
|
|
||||||
|
if loc.startswith(('tx:', 'tx=')):
|
||||||
|
loc = f'text{loc[2:]}'
|
||||||
|
|
||||||
# 根据属性查找
|
# 根据属性查找
|
||||||
if loc.startswith('@'):
|
if loc.startswith('@'):
|
||||||
r = re_SPLIT(r'([:=])', loc[1:], maxsplit=1)
|
r = re_SPLIT(r'([:=])', loc[1:], maxsplit=1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user