Path: blob/trunk/py/selenium/webdriver/ie/webdriver.py
1864 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617from typing import Optional1819from selenium.webdriver.common.driver_finder import DriverFinder20from selenium.webdriver.remote.client_config import ClientConfig21from selenium.webdriver.remote.remote_connection import RemoteConnection22from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver2324from .options import Options25from .service import Service262728class WebDriver(RemoteWebDriver):29"""Controls the IEServerDriver and allows you to drive Internet30Explorer."""3132def __init__(33self,34options: Optional[Options] = None,35service: Optional[Service] = None,36keep_alive: bool = True,37) -> None:38"""Creates a new instance of the Ie driver.3940Starts the service and then creates new instance of Ie driver.4142:Args:43- options - IE Options instance, providing additional IE options44- service - (Optional) service instance for managing the starting and stopping of the driver.45- keep_alive - Whether to configure RemoteConnection to use HTTP keep-alive.46"""4748self.service = service if service else Service()49options = options if options else Options()5051self.service.path = self.service.env_path() or DriverFinder(self.service, options).get_driver_path()52self.service.start()5354client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)55executor = RemoteConnection(56ignore_proxy=options._ignore_local_proxy,57client_config=client_config,58)5960try:61super().__init__(command_executor=executor, options=options)62except Exception:63self.quit()64raise6566self._is_remote = False6768def quit(self) -> None:69"""Closes the browser and shuts down the IEServerDriver executable."""70try:71super().quit()72except Exception:73# We don't care about the message because something probably has gone wrong74pass75finally:76self.service.stop()7778def download_file(self, *args, **kwargs):79raise NotImplementedError8081def get_downloadable_files(self, *args, **kwargs):82raise NotImplementedError838485