mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
update DrissionPage/_elements/session_element.py.
Signed-off-by: Wen-Ming21 <3348431908@qq.com>
This commit is contained in:
parent
f2547421ad
commit
cde7fc7b8d
@ -155,11 +155,14 @@ class SessionElement(DrissionElement):
|
||||
if id_:
|
||||
path_str = f'>{ele.tag}#{id_}{path_str}'
|
||||
break
|
||||
brothers = len(ele.eles(f'xpath:./preceding-sibling::*'))
|
||||
path_str = f'>{ele.tag}:nth-child({brothers + 1}){path_str}'
|
||||
before_brothers = len(ele.eles(f'xpath:./preceding-sibling::*'))
|
||||
after_brothers = len(ele.eles(f'xpath:./following-sibling::*'))
|
||||
path_str = f'>{ele.tag}:nth-child({before_brothers + 1}){path_str}' if (
|
||||
before_brothers or after_brothers) else f'>{ele.tag}{path_str}'
|
||||
else:
|
||||
brothers = len(ele.eles(f'xpath:./preceding-sibling::{ele.tag}'))
|
||||
path_str = f'/{ele.tag}[{brothers + 1}]{path_str}' if brothers > 0 else f'/{ele.tag}{path_str}'
|
||||
before_brothers = len(ele.eles(f'xpath:./preceding-sibling::{ele.tag}'))
|
||||
after_brothers = len(ele.eles(f'xpath:./following-sibling::{ele.tag}'))
|
||||
path_str = f'/{ele.tag}[{before_brothers + 1}]{path_str}' if before_brothers > 0 else f'/{ele.tag}[1]{path_str}' if after_brothers > 0 else f'/{ele.tag}{path_str}'
|
||||
|
||||
ele = ele.parent()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user