@Override
public File execute(SelenideElement proxy, WebElementSource linkWithHref, Object[] args) throws IOException {
WebElement link = linkWithHref.findAndAssertElementIsInteractable();
Config config = linkWithHref.driver().config();
long timeout = getTimeout(config, args);
if (config.fileDownload() == HTTPGET) {
LOG.config("selenide.fileDownload = " + System.getProperty("selenide.fileDownload") + " download file via http get");
return downloadFileWithHttpRequest.download(linkWithHref.driver(), link, timeout);
}
if (!config.proxyEnabled()) {
throw new IllegalStateException("Cannot download file: proxy server is not enabled. Setup proxyEnabled");
}
if (linkWithHref.driver().getProxy() == null) {
throw new IllegalStateException("Cannot download file: proxy server is not started");
}
return downloadFileWithProxyServer.download(linkWithHref, link, linkWithHref.driver().getProxy(), timeout);
}