| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
import http.client as http_client |
| 19 |
|
| 20 |
from selenium.webdriver.common.driver_finder import DriverFinder |
| 21 |
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver |
| 22 |
|
| 23 |
from .options import Options |
| 24 |
from .service import Service |
| 25 |
|
| 26 |
|
| 27 |
class WebDriver(RemoteWebDriver): |
| 28 |
"""Controls the WebKitGTKDriver and allows you to drive the browser.""" |
| 29 |
|
| 30 |
def __init__( |
| 31 |
self, |
| 32 |
options=None, |
| 33 |
service: Service = None, |
| 34 |
): |
| 35 |
"""Creates a new instance of the WebKitGTK driver. |
| 36 |
|
| 37 |
Starts the service and then creates new instance of WebKitGTK Driver. |
| 38 |
|
| 39 |
:Args: |
| 40 |
- options : an instance of WebKitGTKOptions |
| 41 |
- service : Service object for handling the browser driver if you need to pass extra details |
| 42 |
""" |
| 43 |
|
| 44 |
options = options if options else Options() |
| 45 |
self.service = service if service else Service() |
| 46 |
self.service.path = DriverFinder(self.service, options).get_driver_path() |
| 47 |
self.service.start() |
| 48 |
|
| 49 |
super().__init__(command_executor=self.service.service_url, options=options) |
| 50 |
self._is_remote = False |
| 51 |
|
| 52 |
def quit(self): |
| 53 |
"""Closes the browser and shuts down the WebKitGTKDriver executable |
| 54 |
that is started when starting the WebKitGTKDriver.""" |
| 55 |
try: |
| 56 |
super().quit() |
| 57 |
except http_client.BadStatusLine: |
| 58 |
pass |
| 59 |
finally: |
| 60 |
self.service.stop() |