Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/ie/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
from typing import Optional
19
20
from selenium.webdriver.common.driver_finder import DriverFinder
21
from selenium.webdriver.remote.client_config import ClientConfig
22
from selenium.webdriver.remote.remote_connection import RemoteConnection
23
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
24
25
from .options import Options
26
from .service import Service
27
28
29
class WebDriver(RemoteWebDriver):
30
"""Controls the IEServerDriver and allows you to drive Internet
31
Explorer."""
32
33
def __init__(
34
self,
35
options: Optional[Options] = None,
36
service: Optional[Service] = None,
37
keep_alive: bool = True,
38
) -> None:
39
"""Creates a new instance of the Ie driver.
40
41
Starts the service and then creates new instance of Ie driver.
42
43
:Args:
44
- options - IE Options instance, providing additional IE options
45
- service - (Optional) service instance for managing the starting and stopping of the driver.
46
- keep_alive - Whether to configure RemoteConnection to use HTTP keep-alive.
47
"""
48
49
self.service = service if service else Service()
50
options = options if options else Options()
51
52
self.service.path = self.service.env_path() or DriverFinder(self.service, options).get_driver_path()
53
self.service.start()
54
55
client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)
56
executor = RemoteConnection(
57
ignore_proxy=options._ignore_local_proxy,
58
client_config=client_config,
59
)
60
61
try:
62
super().__init__(command_executor=executor, options=options)
63
except Exception:
64
self.quit()
65
raise
66
67
self._is_remote = False
68
69
def quit(self) -> None:
70
"""Closes the browser and shuts down the IEServerDriver executable."""
71
try:
72
super().quit()
73
except Exception:
74
# We don't care about the message because something probably has gone wrong
75
pass
76
finally:
77
self.service.stop()
78
79
def download_file(self, *args, **kwargs):
80
raise NotImplementedError
81
82
def get_downloadable_files(self, *args, **kwargs):
83
raise NotImplementedError
84
85