Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加is_force_run_browser参数实现强制启动浏览器,解决浏览器无法连接异常 #368

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DrissionPage/_configs/chromium_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, read_file=True, ini_path=None):
self.clear_file_flags = False
self._is_headless = False
self._ua_set = False
self.is_force_run_browser = False

if read_file is False:
ini_path = False
Expand Down
3 changes: 2 additions & 1 deletion DrissionPage/_functions/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
def connect_browser(option):
address = option.address.replace('localhost', '127.0.0.1').lstrip('htps:/')
browser_path = option.browser_path
is_force_run_browser = option.is_force_run_browser

ip, port = address.split(':')
using = port_is_using(ip, port)
if ip != '127.0.0.1' or using or option.is_existing_only:
if (is_force_run_browser == None or is_force_run_browser == False) and (ip != '127.0.0.1' or using or option.is_existing_only):
if test_connect(ip, port):
return True
elif ip != '127.0.0.1':
Expand Down