From bb92657901ca046a40627313fbaa4afb327ce74f Mon Sep 17 00:00:00 2001 From: lyousan <2762027866@qq.com> Date: Tue, 23 Jul 2024 02:19:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E4=BF=AE=E6=94=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E5=B0=BD=E5=8F=AF=E8=83=BD=E7=BC=A9=E5=B0=8F?= =?UTF-8?q?=E5=BD=B1=E5=93=8D=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/_base/browser.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/DrissionPage/_base/browser.py b/DrissionPage/_base/browser.py index 997a7ea..71f6864 100644 --- a/DrissionPage/_base/browser.py +++ b/DrissionPage/_base/browser.py @@ -22,6 +22,7 @@ from .._functions.settings import Settings from .._functions.tools import PortFinder from .._functions.tools import raise_error from .._pages.chromium_base import Timeout +from .._pages.chromium_frame import ChromiumFrame from .._pages.tabs import ChromiumTab, MixTab from .._units.downloader import DownloadManager from .._units.setter import BrowserSetter @@ -457,10 +458,18 @@ class Chromium(object): :param owner: 使用该驱动的对象 :return: Driver对象 """ - d = self._drivers.get(tab_id, None) + if isinstance(owner, ChromiumFrame): + d = self._drivers.get(tab_id, None) + if not d: + d = Driver(tab_id, 'page', self.address) + d.owner = owner + self._drivers[tab_id] = d + self._all_drivers.setdefault(tab_id, set()).add(d) + return d + + d = self._drivers.pop(tab_id, None) if not d: d = Driver(tab_id, 'page', self.address) - self._drivers[tab_id] = d d.owner = owner self._all_drivers.setdefault(tab_id, set()).add(d) return d