mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
quit()会等待浏览器进程关闭
This commit is contained in:
parent
03ae186f06
commit
fa918f105a
@ -9,7 +9,6 @@ from .chromium_base import ChromiumBase, Timeout
|
||||
from .chromium_driver import ChromiumDriver
|
||||
from .chromium_tab import ChromiumTab
|
||||
from .commons.browser import connect_browser
|
||||
from .commons.tools import port_is_using
|
||||
from .configs.chromium_options import ChromiumOptions
|
||||
from .errors import BrowserConnectError
|
||||
from .setter import ChromiumPageSetter
|
||||
@ -338,9 +337,16 @@ class ChromiumPage(ChromiumBase):
|
||||
"""关闭浏览器"""
|
||||
self._tab_obj.call_method('Browser.close')
|
||||
self._tab_obj.stop()
|
||||
ip, port = self.address.split(':')
|
||||
while port_is_using(ip, port):
|
||||
sleep(.1)
|
||||
|
||||
if self.process_id:
|
||||
from os import popen
|
||||
from platform import system
|
||||
txt = f'tasklist | findstr {self.process_id}' if system().lower() == 'windows' \
|
||||
else f'ps -ef | grep {self.process_id}'
|
||||
while True:
|
||||
p = popen(txt)
|
||||
if f' {self.process_id} ' not in p.read():
|
||||
break
|
||||
|
||||
def _on_alert_close(self, **kwargs):
|
||||
"""alert关闭时触发的方法"""
|
||||
|
@ -421,8 +421,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
self._response = None
|
||||
self._has_session = None
|
||||
if self._has_driver:
|
||||
self._tab_obj.call_method('Browser.close')
|
||||
self._tab_obj.stop()
|
||||
super(SessionPage, self).quit()
|
||||
self._tab_obj = None
|
||||
self._has_driver = None
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user