Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/wpewebkit/webdriver.py
1864 views
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
from typing import Optional
20
21
from selenium.webdriver.common.driver_finder import DriverFinder
22
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
23
24
from .options import Options
25
from .service import Service
26
27
28
class WebDriver(RemoteWebDriver):
29
"""Controls the WPEWebKitDriver and allows you to drive the browser."""
30
31
def __init__(
32
self,
33
options=None,
34
service: Optional[Service] = None,
35
):
36
"""Creates a new instance of the WPEWebKit driver.
37
38
Starts the service and then creates new instance of WPEWebKit Driver.
39
40
:Args:
41
- options : an instance of ``WPEWebKitOptions``
42
- service : Service object for handling the browser driver if you need to pass extra details
43
"""
44
45
options = options if options else Options()
46
self.service = service if service else Service()
47
self.service.path = DriverFinder(self.service, options).get_driver_path()
48
self.service.start()
49
50
super().__init__(command_executor=self.service.service_url, options=options)
51
self._is_remote = False
52
53
def quit(self):
54
"""Closes the browser and shuts down the WPEWebKitDriver executable
55
that is started when starting the WPEWebKitDriver."""
56
try:
57
super().quit()
58
except http_client.BadStatusLine:
59
pass
60
finally:
61
self.service.stop()
62
63
def download_file(self, *args, **kwargs):
64
raise NotImplementedError
65
66
def get_downloadable_files(self, *args, **kwargs):
67
raise NotImplementedError
68
69