Skip to content

Commit 554cd02

Browse files
committed
Refactor Undetectable Mode
1 parent fe3d30e commit 554cd02

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

seleniumbase/undetected/__init__.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import re
55
import sys
66
import time
7+
import selenium.webdriver.chrome.service
78
import selenium.webdriver.chrome.webdriver
89
import selenium.webdriver.common.service
9-
from selenium.webdriver.chrome.service import Service as ChromeService
10+
import selenium.webdriver.remote.command
1011
from .dprocess import start_detached
1112
from .options import ChromeOptions
1213
from .patcher import IS_POSIX
@@ -29,20 +30,17 @@
2930

3031
class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
3132
"""
32-
Controls the ChromeDriver and allows you to drive the browser.
33-
The webdriver file will be downloaded by this module automatically.
33+
Controls chromedriver to drive a browser.
34+
The driver gets downloaded automatically.
3435
35-
Methods
36-
-------
37-
38-
reconnect()
36+
*** Methods ***
37+
---------------
3938
39+
* reconnect()
4040
This can be useful when sites use heavy detection methods:
4141
- Stops the chromedriver service that runs in the background.
4242
- Starts the chromedriver service that runs in the background.
4343
- Recreates the session.
44-
45-
start_session(capabilities=None, browser_profile=None)
4644
"""
4745
_instances = set()
4846
session_id = None
@@ -263,7 +261,7 @@ def __init__(
263261
close_fds=IS_POSIX,
264262
)
265263
self.browser_pid = browser.pid
266-
service_ = ChromeService(
264+
service_ = selenium.webdriver.chrome.service.Service(
267265
executable_path=patcher.executable_path,
268266
log_path=os.devnull,
269267
)
@@ -410,6 +408,12 @@ def clear_cdp_listeners(self):
410408
if self.reactor and isinstance(self.reactor, Reactor):
411409
self.reactor.handlers.clear()
412410

411+
def window_new(self):
412+
self.execute(
413+
selenium.webdriver.remote.command.Command.NEW_WINDOW,
414+
{"type": "window"},
415+
)
416+
413417
def tab_new(self, url):
414418
"""This opens a url in a new tab."""
415419
if not hasattr(self, "cdp"):

0 commit comments

Comments
 (0)