Path: blob/trunk/py/selenium/webdriver/common/webdriver.py
4020 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 selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver181920class LocalWebDriver(RemoteWebDriver):21"""Base class for local WebDrivers."""2223def __init__(self, *args, **kwargs):24super().__init__(*args, **kwargs)25self._is_remote = False2627def __new__(cls, *args, **kwargs):28if cls is LocalWebDriver:29raise TypeError(f"Only children of '{cls.__name__}' may be instantiated")30return object.__new__(cls)3132def quit(self) -> None:33"""Closes the browser and shuts down the driver executable."""34try:35super().quit()36except Exception:37# We don't care about the message because something probably has gone wrong38pass39finally:40if hasattr(self, "service") and self.service is not None:41self.service.stop()4243def download_file(self, *args, **kwargs):44"""Only implemented in RemoteWebDriver."""45raise NotImplementedError4647def get_downloadable_files(self, *args, **kwargs):48"""Only implemented in RemoteWebDriver."""49raise NotImplementedError5051def delete_downloadable_files(self, *args, **kwargs):52"""Only implemented in RemoteWebDriver."""53raise NotImplementedError545556