Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/ie/webdriver.py
3989 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 selenium.webdriver.common.driver_finder import DriverFinder
19
from selenium.webdriver.common.webdriver import LocalWebDriver
20
from selenium.webdriver.ie.options import Options
21
from selenium.webdriver.ie.service import Service
22
from selenium.webdriver.remote.client_config import ClientConfig
23
from selenium.webdriver.remote.remote_connection import RemoteConnection
24
25
26
class WebDriver(LocalWebDriver):
27
"""Control the IEServerDriver and drive Internet Explorer."""
28
29
def __init__(
30
self,
31
options: Options | None = None,
32
service: Service | None = None,
33
keep_alive: bool = True,
34
) -> None:
35
"""Creates a new instance of the Ie driver.
36
37
Starts the service and then creates new instance of Ie driver.
38
39
Args:
40
options: Instance of Options.
41
service: Service object for handling the browser driver if you need to pass extra details.
42
keep_alive: Whether to configure RemoteConnection to use HTTP keep-alive.
43
"""
44
self.service = service if service else Service()
45
self.options = options if options else Options()
46
47
self.service.path = self.service.env_path() or DriverFinder(self.service, self.options).get_driver_path()
48
self.service.start()
49
50
client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)
51
executor = RemoteConnection(
52
ignore_proxy=self.options._ignore_local_proxy,
53
client_config=client_config,
54
)
55
56
try:
57
super().__init__(command_executor=executor, options=self.options)
58
except Exception:
59
self.quit()
60
raise
61
62