Search in sources :

Example 1 with HarEntry

use of net.lightbody.bmp.core.har.HarEntry in project selenium-tests by Wikia.

the class NetworkTrafficInterceptor method logDFP.

/**
   * Looks for correlator pattern in requests query strings to DFP domain, and logs if all the calls
   * have the same correlator ID. Any difference is ID is logged as failure.
   */
public void logDFP(String skinCorrelator) {
    har = getHar();
    String expectedCorrelator = null;
    Pattern pt = Pattern.compile("(correlator=)\\d*");
    for (HarEntry entry : har.getLog().getEntries()) {
        if (entry.getRequest().getUrl().contains("pubads.g.doubleclick.net") && entry.getRequest().getQueryString().toString().contains(skinCorrelator)) {
            Matcher matcher = pt.matcher(entry.getRequest().getQueryString().toString());
            if (matcher.find()) {
                String correlatorID = matcher.group(0);
                if (expectedCorrelator == null) {
                    expectedCorrelator = correlatorID;
                }
                PageObjectLogging.log("CORRELATOR CHECK", "CORRELATOR ID: " + correlatorID, correlatorID.equals(expectedCorrelator));
            } else {
                throw new WebDriverException("Missing correlator param in query string");
            }
        }
    }
}
Also used : HarEntry(net.lightbody.bmp.core.har.HarEntry) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) WebDriverException(org.openqa.selenium.WebDriverException)

Example 2 with HarEntry

use of net.lightbody.bmp.core.har.HarEntry in project selenium-tests by Wikia.

the class TestAdsVelesTracking method adsTrackingVelesTracked.

@NetworkTrafficDump()
@Test(groups = "AdsTrackingVeles", dataProviderClass = AdsDataProvider.class, dataProvider = "adsVelesTracking")
public void adsTrackingVelesTracked(final Page page, final Map<String, String> positionsAndPrices) {
    networkTrafficInterceptor.startIntercepting();
    AdsBaseObject pageObject = new AdsBaseObject(driver, urlBuilder.getUrlForPage(page));
    Set<HarEntry> entries = findEntriesByUrlPart(pageObject, VELES_TRACKING_REQUEST_PART, positionsAndPrices);
    Assertion.assertTrue(wasVelesTrackedIn(entries, positionsAndPrices), "Veles should be tracked only in " + positionsAndPrices);
}
Also used : HarEntry(net.lightbody.bmp.core.har.HarEntry) AdsBaseObject(com.wikia.webdriver.pageobjectsfactory.pageobject.adsbase.AdsBaseObject) NetworkTrafficDump(com.wikia.webdriver.common.core.annotations.NetworkTrafficDump) Test(org.testng.annotations.Test)

Aggregations

HarEntry (net.lightbody.bmp.core.har.HarEntry)2 NetworkTrafficDump (com.wikia.webdriver.common.core.annotations.NetworkTrafficDump)1 AdsBaseObject (com.wikia.webdriver.pageobjectsfactory.pageobject.adsbase.AdsBaseObject)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 WebDriverException (org.openqa.selenium.WebDriverException)1 Test (org.testng.annotations.Test)1