mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
quit()的force参数改为立即执行;其它微调
This commit is contained in:
parent
ddd7aba9ae
commit
af6a759b4a
@ -13,4 +13,4 @@ from ._configs.chromium_options import ChromiumOptions
|
||||
from ._configs.session_options import SessionOptions
|
||||
|
||||
__all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__']
|
||||
__version__ = '4.0.0b13'
|
||||
__version__ = '4.0.0b15'
|
||||
|
@ -156,15 +156,22 @@ class Browser(object):
|
||||
"""
|
||||
return self.run_cdp('Browser.getWindowForTarget', targetId=tab_id or self.id)['bounds']
|
||||
|
||||
def quit(self, timeout=5, force=True):
|
||||
def quit(self, timeout=5, force=False):
|
||||
"""关闭浏览器
|
||||
:param timeout: 等待浏览器关闭超时时间
|
||||
:param force: 关闭超时是否强制终止进程
|
||||
:param force: 是否立刻强制终止进程
|
||||
:return: None
|
||||
"""
|
||||
self.run_cdp('Browser.close')
|
||||
self.driver.stop()
|
||||
|
||||
if force:
|
||||
ip, port = self.address.split(':')
|
||||
if ip not in ('127.0.0.1', 'localhost'):
|
||||
return
|
||||
stop_process_on_port(port)
|
||||
return
|
||||
|
||||
if self.process_id:
|
||||
from os import popen
|
||||
from platform import system
|
||||
@ -180,11 +187,5 @@ class Browser(object):
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
if force:
|
||||
ip, port = self.address.split(':')
|
||||
if ip not in ('127.0.0.1', 'localhost'):
|
||||
return
|
||||
stop_process_on_port(port)
|
||||
|
||||
def _on_quit(self):
|
||||
Browser.BROWSERS.pop(self.id, None)
|
||||
|
@ -57,6 +57,6 @@ class Browser(object):
|
||||
|
||||
def _onTargetDestroyed(self, **kwargs) -> None: ...
|
||||
|
||||
def quit(self, timeout: float = 5, force: bool = True) -> None: ...
|
||||
def quit(self, timeout: float = 5, force: bool = False) -> None: ...
|
||||
|
||||
def _on_quit(self) -> None: ...
|
||||
|
@ -40,7 +40,7 @@ class ChromiumOptions(object):
|
||||
self._load_mode = options.get('load_mode', 'normal')
|
||||
self._proxy = om.proxies.get('http', None)
|
||||
self._system_user_path = options.get('system_user_path', False)
|
||||
self._existing_only = options.get('is_existing_only', False)
|
||||
self._existing_only = options.get('existing_only', False)
|
||||
|
||||
user_path = user = False
|
||||
for arg in self._arguments:
|
||||
|
@ -12,7 +12,6 @@ load_mode = normal
|
||||
user = Default
|
||||
auto_port = False
|
||||
system_user_path = False
|
||||
is_existing_only = False
|
||||
existing_only = False
|
||||
|
||||
[session_options]
|
||||
|
@ -165,7 +165,6 @@ class ChromiumBase(BasePage):
|
||||
return True
|
||||
|
||||
except:
|
||||
print('获取文档失败')
|
||||
if self._debug:
|
||||
print('获取文档失败')
|
||||
return False
|
||||
|
@ -27,8 +27,7 @@ class ChromiumPage(ChromiumBase):
|
||||
:param tab_id: 要控制的标签页id,不指定默认为激活的
|
||||
:param timeout: 超时时间
|
||||
"""
|
||||
if not addr_or_opts and addr_driver_opts:
|
||||
addr_or_opts = addr_driver_opts
|
||||
addr_or_opts = addr_or_opts or addr_driver_opts
|
||||
self._page = self
|
||||
address = self._handle_options(addr_or_opts)
|
||||
self._run_browser()
|
||||
|
@ -22,8 +22,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
:param chromium_options: ChromiumDriver对象,只使用s模式时应传入False
|
||||
:param session_or_options: Session对象或SessionOptions对象,只使用d模式时应传入False
|
||||
"""
|
||||
if not chromium_options and driver_or_options:
|
||||
chromium_options = driver_or_options
|
||||
chromium_options = chromium_options or driver_or_options
|
||||
self._mode = mode.lower()
|
||||
if self._mode not in ('s', 'd'):
|
||||
raise ValueError('mode参数只能是s或d。')
|
||||
|
2
setup.py
2
setup.py
@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
|
||||
|
||||
setup(
|
||||
name="DrissionPage",
|
||||
version="4.0.0b13",
|
||||
version="4.0.0b15",
|
||||
author="g1879",
|
||||
author_email="g1879@qq.com",
|
||||
description="Python based web automation tool. It can control the browser and send and receive data packets.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user