mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
优化逻辑
This commit is contained in:
parent
5feb58bc65
commit
73b6f1c475
@ -78,23 +78,28 @@ def get_ele_txt(e):
|
||||
if re_str and re_str[-1] == '\n':
|
||||
re_str.pop()
|
||||
|
||||
re_str = [i if i is not True else '\n' for i in re_str]
|
||||
l = len(re_str)
|
||||
if l > 1:
|
||||
r = []
|
||||
for i in range(0, l - 1, 2):
|
||||
for i in range(l - 1):
|
||||
i1 = re_str[i]
|
||||
i2 = re_str[i + 1]
|
||||
if i1 is True:
|
||||
r.append('\n')
|
||||
continue
|
||||
if i2 is True:
|
||||
r.append(i1)
|
||||
continue
|
||||
if i1.endswith(' ') and i2.startswith(' '):
|
||||
i1 = i1[:-1]
|
||||
r.append(i1)
|
||||
r.append(i2)
|
||||
r.append('\n' if re_str[-1] is True else re_str[-1])
|
||||
re_str = ''.join(r)
|
||||
|
||||
elif not l:
|
||||
re_str = ''
|
||||
else:
|
||||
re_str = re_str[0]
|
||||
re_str = re_str[0] if re_str[0] is not True else '\n'
|
||||
|
||||
return format_html(re_str.strip())
|
||||
|
||||
|
@ -19,6 +19,7 @@ from .._elements.chromium_element import run_js, make_chromium_eles
|
||||
from .._elements.none_element import NoneElement
|
||||
from .._elements.session_element import make_session_ele
|
||||
from .._functions.cookies import CookiesList
|
||||
from .._functions.elements import SessionElementsList
|
||||
from .._functions.locator import get_loc, is_loc
|
||||
from .._functions.settings import Settings
|
||||
from .._functions.tools import raise_error
|
||||
@ -547,8 +548,8 @@ class ChromiumBase(BasePage):
|
||||
:param index: 获取第几个,从1开始,可传入负数获取倒数第几个
|
||||
:return: SessionElement对象或属性、文本
|
||||
"""
|
||||
if locator:
|
||||
self.wait.eles_loaded(locator)
|
||||
if locator and not self.wait.eles_loaded(locator):
|
||||
return NoneElement(self, method='s_ele()', args={'locator': locator, 'index': index})
|
||||
return make_session_ele(self, locator, index=index, method='s_ele()')
|
||||
|
||||
def s_eles(self, locator):
|
||||
@ -556,7 +557,8 @@ class ChromiumBase(BasePage):
|
||||
:param locator: 元素的定位信息,可以是loc元组,或查询字符串
|
||||
:return: SessionElement对象组成的列表
|
||||
"""
|
||||
self.wait.eles_loaded(locator)
|
||||
if not self.wait.eles_loaded(locator):
|
||||
return SessionElementsList()
|
||||
return make_session_ele(self, locator, index=None)
|
||||
|
||||
def _find_elements(self, locator, timeout=None, index=1, relative=False, raise_err=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user