Path: blob/trunk/py/selenium/webdriver/webkitgtk/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.1617import http.client as http_client18from typing import Optional1920from selenium.webdriver.common.driver_finder import DriverFinder21from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver2223from .options import Options24from .service import Service252627class WebDriver(RemoteWebDriver):28"""Controls the WebKitGTKDriver and allows you to drive the browser."""2930def __init__(31self,32options=None,33service: Optional[Service] = None,34):35"""Creates a new instance of the WebKitGTK driver.3637Starts the service and then creates new instance of WebKitGTK Driver.3839:Args:40- options : an instance of WebKitGTKOptions41- service : Service object for handling the browser driver if you need to pass extra details42"""4344options = options if options else Options()45self.service = service if service else Service()46self.service.path = DriverFinder(self.service, options).get_driver_path()47self.service.start()4849super().__init__(command_executor=self.service.service_url, options=options)50self._is_remote = False5152def quit(self):53"""Closes the browser and shuts down the WebKitGTKDriver executable54that is started when starting the WebKitGTKDriver."""55try:56super().quit()57except http_client.BadStatusLine:58pass59finally:60self.service.stop()6162def download_file(self, *args, **kwargs):63raise NotImplementedError6465def get_downloadable_files(self, *args, **kwargs):66raise NotImplementedError676869