use of net.lightbody.bmp.core.har.Har in project sdc by onap.
the class SetupCDTest method addTrafficFileToReport.
private void addTrafficFileToReport(ITestResult result) {
try {
// Get the HAR data
Har har = MobProxy.getPoxyServer().getHar();
String shortUUID = UUID.randomUUID().toString().split("-")[0];
File harFile = new File(getHarFilesFolder() + result.getName() + shortUUID + ".har");
new File(getHarFilesFolder()).mkdirs();
har.writeTo(harFile);
String pathToFileFromReportDirectory = HAR_FILES_FOLDER_NAME + File.separator + harFile.getName();
ExtentTestActions.addFileToReportAsLink(harFile, pathToFileFromReportDirectory, "File with captured traffic");
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
use of net.lightbody.bmp.core.har.Har in project staf by simpleworks-gmbh.
the class APITestCase method createArtefact.
@Override
public HarFile createArtefact() {
final BrowserMobProxyServer proxy = client.getBrowserMobProxyServer();
if (proxy == null) {
return null;
}
HarFile result = null;
try {
final Har har = proxy.getHar();
if (har != null) {
final File tempFile = File.createTempFile(UUID.randomUUID().toString(), ".har");
if (APITestCase.logger.isDebugEnabled()) {
APITestCase.logger.debug(String.format("write HAR into file: '%s'.", tempFile));
}
tempFile.deleteOnExit();
har.writeTo(tempFile);
result = new HarFile(tempFile);
}
} catch (final Exception ex) {
APITestCase.logger.error("can't create artifact.", ex);
}
return result;
}
use of net.lightbody.bmp.core.har.Har in project selenium-webdriver-java by bonigarcia.
the class HarCreatorJupiterTest method teardown.
@AfterEach
void teardown() throws IOException {
Har har = proxy.getHar();
File harFile = new File("login.har");
har.writeTo(harFile);
proxy.stop();
driver.quit();
}
use of net.lightbody.bmp.core.har.Har in project selenium-webdriver-java by bonigarcia.
the class HarCreatorSelJupTest method teardown.
@AfterEach
void teardown() throws IOException {
Har har = proxy.getHar();
File harFile = new File("login.har");
har.writeTo(harFile);
proxy.stop();
}
use of net.lightbody.bmp.core.har.Har in project selenium-tests by Wikia.
the class Log method stop.
public static void stop() {
WikiaWebDriver driver = DriverProvider.getActiveDriver();
if (driver.getProxy() != null && Configuration.getForceHttps()) {
Har har = driver.getProxy().getHar();
for (HarEntry entry : har.getLog().getEntries()) {
URL url;
try {
url = new URL(entry.getRequest().getUrl());
if (url.getHost().contains("wikia")) {
boolean isHttps = entry.getRequest().getUrl().startsWith("https");
Log.log("VISITED URL", "Url: " + entry.getRequest().getUrl(), !Configuration.getForceHttps() || isHttps);
}
} catch (MalformedURLException e) {
Log.log("MALFORMED URL", "Url: " + entry.getRequest().getUrl(), false);
}
}
}
if (driver.getProxy() != null && Configuration.getAdsData()) {
Har har = driver.getProxy().getHar();
for (HarEntry entry : har.getLog().getEntries()) {
try {
if (entry.getRequest().getUrl().contains("adeng")) {
String[] urlValue = entry.getRequest().getUrl().split("(adeng).+\\?");
String[] values = urlValue[1].split("&");
Log.info("Ad parameters", "Header: " + Arrays.toString(values));
}
} catch (NullPointerException ex) {
Log.info("Did not get successful response", ex);
}
}
Pattern pt = Pattern.compile("\\d{2,}");
WebElement mercuryScriptVersion = null;
if (Configuration.getEmulator().isMobile()) {
mercuryScriptVersion = driver.findElement(By.cssSelector("script[src*='mercury_ads_js']"));
}
String mercuryAdsJsValue = mercuryScriptVersion.getAttribute("src");
Matcher matcher = pt.matcher(mercuryAdsJsValue);
if (matcher.find()) {
mercuryAdsJsValue = matcher.group(0);
} else {
throw new WebDriverException("Missing mobile param in query string");
}
Log.info("Mercury Ads Version: " + mercuryAdsJsValue);
}
if (Configuration.getMobileWikiVersion() != null) {
Log.info("Mobile Wiki Version: " + Configuration.getMobileWikiVersion());
}
String html = VelocityWrapper.fillLastLogRow();
CommonUtils.appendTextToFile(Log.LOG_PATH, html);
Log.testStarted = false;
}
Aggregations