4.1.0.0b17修复小问题

This commit is contained in:
g1879 2024-07-30 17:59:14 +08:00
parent cf858d5574
commit cae2151795
3 changed files with 13 additions and 10 deletions

View File

@ -14,4 +14,4 @@ from ._pages.chromium_page import ChromiumPage
from ._pages.mix_page import MixPage from ._pages.mix_page import MixPage
from ._pages.mix_page import MixPage as WebPage from ._pages.mix_page import MixPage as WebPage
__version__ = '4.1.0.0b16' __version__ = '4.1.0.0b17'

View File

@ -109,7 +109,7 @@ class ChromiumBase(BasePage):
self._ready_state = 'complete' self._ready_state = 'complete'
def _driver_init(self, target_id): def _driver_init(self, target_id):
"""新建页面、页面刷新、切换标签页后要进行的cdp参数初始化 """新建页面、页面刷新后要进行的cdp参数初始化
:param target_id: 要跳转到的target id :param target_id: 要跳转到的target id
:return: None :return: None
""" """

View File

@ -30,15 +30,15 @@ class ChromiumFrame(ChromiumBase):
:param ele: frame所在元素 :param ele: frame所在元素
:param info: frame所在元素信息 :param info: frame所在元素信息
""" """
node = info['node'] if info else owner._run_cdp('DOM.describeNode', backendNodeId=ele._backend_id)['node'] fid = info['node']['frameId'] if info else owner._run_cdp('DOM.describeNode',
if Settings.singleton_tab_obj and node['frameId'] in cls._Frames: backendNodeId=ele._backend_id)['node']['frameId']
r = cls._Frames[node['frameId']] if Settings.singleton_tab_obj and fid in cls._Frames:
while not hasattr(r, '_frame_id'): r = cls._Frames[fid]
while not hasattr(r, '_type') or r._type != 'ChromiumFrame':
sleep(.1) sleep(.1)
return r return r
r = object.__new__(cls) r = object.__new__(cls)
r._frame_id = node['frameId'] cls._Frames[fid] = r
cls._Frames[node['frameId']] = r
return r return r
def __init__(self, owner, ele, info=None): def __init__(self, owner, ele, info=None):
@ -47,6 +47,10 @@ class ChromiumFrame(ChromiumBase):
:param ele: frame所在元素 :param ele: frame所在元素
:param info: frame所在元素信息 :param info: frame所在元素信息
""" """
if Settings.singleton_tab_obj and hasattr(self, '_created'):
return
self._created = True
self._tab = owner._tab self._tab = owner._tab
self._target_page = owner self._target_page = owner
self._backend_id = ele._backend_id self._backend_id = ele._backend_id
@ -54,6 +58,7 @@ class ChromiumFrame(ChromiumBase):
self._reloading = False self._reloading = False
node = info['node'] if info else owner._run_cdp('DOM.describeNode', backendNodeId=ele._backend_id)['node'] node = info['node'] if info else owner._run_cdp('DOM.describeNode', backendNodeId=ele._backend_id)['node']
self._frame_id = node['frameId']
if self._is_inner_frame(): if self._is_inner_frame():
self._is_diff_domain = False self._is_diff_domain = False
self.doc_ele = ChromiumElement(self._target_page, backend_id=node['contentDocument']['backendNodeId']) self.doc_ele = ChromiumElement(self._target_page, backend_id=node['contentDocument']['backendNodeId'])
@ -195,8 +200,6 @@ class ChromiumFrame(ChromiumBase):
"""同域变异域""" """同域变异域"""
self.browser._frames.pop(kwargs['frameId'], None) self.browser._frames.pop(kwargs['frameId'], None)
ChromiumFrame._Frames.pop(kwargs['frameId'], None) ChromiumFrame._Frames.pop(kwargs['frameId'], None)
while not hasattr(self, '_frame_id'):
sleep(.1)
if kwargs['frameId'] == self._frame_id: if kwargs['frameId'] == self._frame_id:
self._reload() self._reload()