This commit is contained in:
g1879 2023-01-17 00:18:06 +08:00
parent 3150449ab2
commit 2bafcef885
4 changed files with 8 additions and 14 deletions

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from functools import partial
from json import dumps, loads
from logging import getLogger
from os import getenv
from threading import Thread, Event
@ -13,8 +12,6 @@ try:
except ImportError:
import queue
logger = getLogger(__name__)
class GenericAttr(object):
def __init__(self, name, tab):
@ -48,7 +45,7 @@ class ChromiumDriver(object):
self._websocket_url = kwargs.get("webSocketDebuggerUrl")
self._kwargs = kwargs
self._cur_id = 1000
self._cur_id = 0
self._ws = None
@ -144,7 +141,7 @@ class ChromiumDriver(object):
try:
self.event_handlers[event['method']](**event['params'])
except Exception as e:
logger.error(f"callback {event['method']} exception", exc_info=True)
raise RuntimeError(f"回调函数 {event['method']} 错误:{e}")
self.event_queue.task_done()

View File

@ -47,7 +47,7 @@ class SessionPage(BasePage):
def _set_session(self, opt):
"""根据传入字典对session进行设置 \n
:param data: session配置字典
:param opt: session配置字典
:return: None
"""
self._session = Session()

View File

@ -430,15 +430,12 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
else:
if se_opt is None:
so = SessionOptions().as_dict()
so = SessionOptions()
elif se_opt is False:
so = SessionOptions(read_file=False).as_dict()
so = SessionOptions(read_file=False)
elif isinstance(se_opt, SessionOptions):
so = se_opt.as_dict()
elif isinstance(se_opt, dict):
so = se_opt
else:
@ -447,7 +444,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
self._session_options = so
if se_opt is not False:
self.set_timeouts(implicit=self._session_options.get('timeout', 10))
self.set_timeouts(implicit=self._session_options.timeout)
if dr_opt is not False:
t = self._driver_options.timeouts

View File

@ -29,8 +29,8 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
self._mode: str = ...
self._has_driver: bool = ...
self._has_session: bool = ...
self._session_options: dict = ...
self._driver_options: DriverOptions = ...
self._session_options: Union[SessionOptions, None] = ...
self._driver_options: Union[DriverOptions, None] = ...
self._setting_tab_id: str = ...
self._download_kit: DownloadKit = ...
self._download_set: WebPageDownloadSetter = ...