public class FetchUtil extends Object
Example usage: FetchUtil.save(driver, name.html)
| Modifier and Type | Field and Description |
|---|---|
static String |
ASSET_DIR |
static String |
ASSET_FOLDER |
static String |
OUTPUT_DIR |
| Constructor and Description |
|---|
FetchUtil() |
| Modifier and Type | Method and Description |
|---|---|
static List<String> |
extractFiles(String html)
Extract source location of all files related to HTML.
|
static void |
getFiles(List<String> files,
org.openqa.selenium.WebDriver driver)
Download all external files to local directory.
|
static String |
getHost(org.openqa.selenium.WebDriver driver) |
static String |
parseHtml(String html,
List<String> files)
Updates the HTML with the new locations of assets.
|
static List<String> |
parseURL(List<String> files,
String baseUrl,
String currentURL)
Parses file paths to URLs.
|
protected static File |
retrieveFile(String resourceUrl,
org.apache.http.impl.client.CloseableHttpClient client,
File output)
Retrieve file with authentication, using
WebDriver cookie we
keep the session and use HttpClient to download files that requires
user to be authenticated. |
static void |
save(org.openqa.selenium.WebDriver driver,
String filename)
Saves the current page as seen by the WebDriver
|
static String |
stripBaseTag(String value)
Checks and removes base tags such as:
|
public static final String OUTPUT_DIR
public static final String ASSET_FOLDER
public static final String ASSET_DIR
public static void save(org.openqa.selenium.WebDriver driver,
String filename)
throws IOException
driver - WebDriverfilename - name of the HTML file outputPageCaptureException - if errorIOExceptionpublic static String getHost(org.openqa.selenium.WebDriver driver)
public static List<String> extractFiles(String html)
html - public static List<String> parseURL(List<String> files, String baseUrl, String currentURL)
files - collection of pathsbaseUrl - Site domain URL, http://localhost:8080currentURL - the driver.getCurrentUrl() valuepublic static void getFiles(List<String> files, org.openqa.selenium.WebDriver driver) throws IOException
files - collection to downloaddriver - WebDriverIOExceptionpublic static String parseHtml(String html, List<String> files)
html - files - protected static File retrieveFile(String resourceUrl, org.apache.http.impl.client.CloseableHttpClient client, File output) throws IOException
WebDriver cookie we
keep the session and use HttpClient to download files that requires
user to be authenticated.resourceUrl - path to file to downloaddriver - WebDriveroutput - path to output the fileIOException - if errorCopyright © 2016. All rights reserved.