Path: blob/trunk/java/src/org/openqa/selenium/HasDownloads.java
1865 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.1617package org.openqa.selenium;1819import java.io.IOException;20import java.nio.file.Path;21import java.util.List;2223/** Indicates that a driver supports downloading remote files. */24public interface HasDownloads {2526/**27* Requires downloads to be enabled.28*29* <p>TODO: Create an example in the documentation and provide a link to it.30*31* @param capabilities the capabilities object32* @throws WebDriverException if capability to enable downloads is not set33*/34default void requireDownloadsEnabled(Capabilities capabilities) {35if (!isDownloadsEnabled(capabilities)) {36throw new WebDriverException(37"You must enable downloads in order to work with downloadable files.");38}39}4041/**42* Checks if downloads are enabled43*44* @return true if this webdriver has capability "se:downloadsEnabled" = true45*/46boolean isDownloadsEnabled();4748static boolean isDownloadsEnabled(Capabilities capabilities) {49return capabilities.is("se:downloadsEnabled");50}5152/**53* Gets the downloadable files.54*55* @return a list of downloadable files for each key56*/57List<String> getDownloadableFiles();5859/**60* Downloads a file to a given location.61*62* @param fileName the name of the file to be downloaded63* @param targetLocation the location where the file will be downloaded to64* @throws IOException if an I/O error occurs while downloading the file65*/66void downloadFile(String fileName, Path targetLocation) throws IOException;6768/** Deletes the downloadable files. */69void deleteDownloadableFiles();70}717273