Debian Codegraph @

selenium/webdriver/webkitgtk/webdriver.py

raw symbols SCIP
1 # Licensed to the Software Freedom Conservancy (SFC) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The SFC licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
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()