|
4 | 4 | import re
|
5 | 5 | import sys
|
6 | 6 | import time
|
| 7 | +import selenium.webdriver.chrome.service |
7 | 8 | import selenium.webdriver.chrome.webdriver
|
8 | 9 | import selenium.webdriver.common.service
|
9 |
| -from selenium.webdriver.chrome.service import Service as ChromeService |
| 10 | +import selenium.webdriver.remote.command |
10 | 11 | from .dprocess import start_detached
|
11 | 12 | from .options import ChromeOptions
|
12 | 13 | from .patcher import IS_POSIX
|
|
29 | 30 |
|
30 | 31 | class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
|
31 | 32 | """
|
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. |
34 | 35 |
|
35 |
| - Methods |
36 |
| - ------- |
37 |
| -
|
38 |
| - reconnect() |
| 36 | + *** Methods *** |
| 37 | + --------------- |
39 | 38 |
|
| 39 | + * reconnect() |
40 | 40 | This can be useful when sites use heavy detection methods:
|
41 | 41 | - Stops the chromedriver service that runs in the background.
|
42 | 42 | - Starts the chromedriver service that runs in the background.
|
43 | 43 | - Recreates the session.
|
44 |
| -
|
45 |
| - start_session(capabilities=None, browser_profile=None) |
46 | 44 | """
|
47 | 45 | _instances = set()
|
48 | 46 | session_id = None
|
@@ -263,7 +261,7 @@ def __init__(
|
263 | 261 | close_fds=IS_POSIX,
|
264 | 262 | )
|
265 | 263 | self.browser_pid = browser.pid
|
266 |
| - service_ = ChromeService( |
| 264 | + service_ = selenium.webdriver.chrome.service.Service( |
267 | 265 | executable_path=patcher.executable_path,
|
268 | 266 | log_path=os.devnull,
|
269 | 267 | )
|
@@ -410,6 +408,12 @@ def clear_cdp_listeners(self):
|
410 | 408 | if self.reactor and isinstance(self.reactor, Reactor):
|
411 | 409 | self.reactor.handlers.clear()
|
412 | 410 |
|
| 411 | + def window_new(self): |
| 412 | + self.execute( |
| 413 | + selenium.webdriver.remote.command.Command.NEW_WINDOW, |
| 414 | + {"type": "window"}, |
| 415 | + ) |
| 416 | + |
413 | 417 | def tab_new(self, url):
|
414 | 418 | """This opens a url in a new tab."""
|
415 | 419 | if not hasattr(self, "cdp"):
|
|
0 commit comments