4.1.0.2修复tab的post()报错;修复get_frame()不能输入数字

This commit is contained in:
g1879 2024-09-19 11:18:01 +08:00
parent a8b89b51e2
commit 705fbb398c
4 changed files with 13 additions and 4 deletions

View File

@ -12,4 +12,4 @@ from ._pages.chromium_page import ChromiumPage
from ._pages.session_page import SessionPage
from ._pages.web_page import WebPage
__version__ = '4.1.0.1'
__version__ = '4.1.0.2'

View File

@ -180,13 +180,14 @@ def make_session_ele(html_or_ele, loc=None, index=1, method=None):
raise ValueError("定位符必须为str或长度为2的tuple。")
# ---------------根据传入对象类型获取页面对象和lxml元素对象---------------
the_type = getattr(html_or_ele, '_type', None)
# 直接传入html文本
if isinstance(html_or_ele, str):
page = None
html_or_ele = fromstring(html_or_ele)
# SessionElement
elif html_or_ele._type == 'SessionElement':
elif the_type == 'SessionElement':
page = html_or_ele.owner
loc_str = loc[1]
@ -207,7 +208,7 @@ def make_session_ele(html_or_ele, loc=None, index=1, method=None):
loc = loc[0], loc_str
elif html_or_ele._type == 'ChromiumElement':
elif the_type == 'ChromiumElement':
loc_str = loc[1]
if loc[0] == 'xpath' and loc[1].lstrip().startswith('/'):
loc_str = f'.{loc[1]}'
@ -230,7 +231,7 @@ def make_session_ele(html_or_ele, loc=None, index=1, method=None):
html_or_ele = fromstring(html)
html_or_ele = html_or_ele.xpath(xpath)[0]
elif html_or_ele._type == 'ChromiumFrame':
elif the_type == 'ChromiumFrame':
page = html_or_ele
html_or_ele = fromstring(html_or_ele.inner_html)

View File

@ -309,6 +309,12 @@ def get_frame(owner, loc_ind_ele, timeout=None):
raise TypeError('该定位符不是指向frame元素。')
r = ele
elif isinstance(loc_ind_ele, int):
ele = owner._ele('@|tag():iframe@|tag():frame', timeout=timeout, index=loc_ind_ele)
if ele and ele._type != 'ChromiumFrame':
raise TypeError('该定位符不是指向frame元素。')
r = ele
elif getattr(loc_ind_ele, '_type', None) == 'ChromiumFrame':
r = loc_ind_ele

View File

@ -100,6 +100,8 @@ class MixTab(SessionPage, ChromiumTab, BasePage):
self.cookies_to_session()
if timeout is None:
kwargs['timeout'] = self.timeouts.page_load
if self._session is None:
self._create_session()
super().post(url, show_errmsg, retry, interval, **kwargs)
return self.response