mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
WebPage增加quit();修复MixPage的download属性
This commit is contained in:
parent
94b6c2f339
commit
1d4b6290ac
@ -335,6 +335,13 @@ class ChromiumBase(BasePage):
|
||||
result_cookies.append(c)
|
||||
self._wait_driver.Network.setCookies(cookies=result_cookies)
|
||||
|
||||
# def set_headers(self, headers: dict) -> None:
|
||||
# """设置固定发送的headers \n
|
||||
# :param headers: dict格式的headers数据
|
||||
# :return: None
|
||||
# """
|
||||
# self.run_cdp('Network.setExtraHTTPHeaders', headers=headers)
|
||||
|
||||
def ele(self,
|
||||
loc_or_ele: Union[Tuple[str, str], str, ChromiumElement, 'ChromiumFrame'],
|
||||
timeout: float = None) -> Union[ChromiumElement, 'ChromiumFrame', None]:
|
||||
|
@ -53,7 +53,6 @@ class MixPage(SessionPage, DriverPage, BasePage):
|
||||
self._wait_object = None
|
||||
self._response = None
|
||||
self._scroll = None
|
||||
self._download_kit = None
|
||||
|
||||
if self._mode == 'd':
|
||||
try:
|
||||
|
@ -317,6 +317,16 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
if set_session:
|
||||
super().set_cookies(cookies)
|
||||
|
||||
# def set_headers(self, headers: dict) -> None:
|
||||
# """设置固定发送的headers \n
|
||||
# :param headers: dict格式的headers数据
|
||||
# :return: None
|
||||
# """
|
||||
# if self._mode == 's':
|
||||
# self.session.headers = headers
|
||||
# elif self._mode == 'd':
|
||||
# super(SessionPage, self).set_headers(headers)
|
||||
|
||||
def check_page(self, by_requests: bool = False) -> Union[bool, None]:
|
||||
"""d模式时检查网页是否符合预期 \n
|
||||
默认由response状态检查,可重载实现针对性检查 \n
|
||||
@ -346,6 +356,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
"""关闭session"""
|
||||
if self._has_session:
|
||||
self.change_mode('d')
|
||||
self._session.close()
|
||||
self._session = None
|
||||
self._response = None
|
||||
self._has_session = None
|
||||
@ -430,3 +441,16 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
|
||||
else:
|
||||
raise TypeError('session_or_options参数只能接收Session, dict, SessionOptions或False。')
|
||||
|
||||
def quit(self) -> None:
|
||||
"""关闭浏览器,关闭session"""
|
||||
if self._has_session:
|
||||
self._session.close()
|
||||
self._session = None
|
||||
self._response = None
|
||||
self._has_session = None
|
||||
if self._has_driver:
|
||||
self._tab_obj.Browser.close()
|
||||
self._tab_obj.stop()
|
||||
self._tab_obj = None
|
||||
self._has_driver = None
|
||||
|
2
setup.py
2
setup.py
@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
|
||||
|
||||
setup(
|
||||
name="DrissionPage",
|
||||
version="3.0.15",
|
||||
version="3.0.16",
|
||||
author="g1879",
|
||||
author_email="g1879@qq.com",
|
||||
description="A module that integrates selenium and requests session, encapsulates common page operations.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user