Back to Practice

Dynamic Ads Testing

Dynamic Ads Testing

Practice automating dynamic ad scenarios with all ad types. Features infinite scroll loading, delayed ads, and interactive controls - simulating real-world ad behavior.

Dynamic Scenarios

  • Infinite Scroll - Ads load as you scroll down
  • All Ad Types - Horizontal, Rectangle, In-Article, Matched Content, In-Feed
  • • Delayed ad loading (wait for ads to appear)
  • • User-triggered ad display (click to show)
  • • Multiple dynamic ad slots

All Ad Types

Horizontal Banner Ad

Rectangle Ad (300x250)

In-Article Ad

Matched Content Ad

In-Feed Ad

Delayed Loading Ad

This ad appears 2 seconds after page load

Loading...
Loading ad...

Click-to-Show Ad

Click the button to reveal the ad

Click button to load ad

Multiple Ad Slots

Add or remove ad slots dynamically

Ad Slot #1

Current ad count: 1

Refreshable Ad

Click to refresh/reload the delayed ad

Infinite Scroll Ads

Scroll down to load more ads automatically

Infinite Ad #1

horizontal

Infinite Ad #2

rectangle

Infinite Ad #3

auto

Scroll down for more ads

Total infinite ads loaded: 3

Example Test Code

// Selenium - Wait for infinite scroll to load more
int initialCount = driver.findElements(
    By.cssSelector("[data-testid^='infinite-ad-']")
).size();
((JavascriptExecutor) driver).executeScript(
    "window.scrollTo(0, document.body.scrollHeight);"
);
wait.until(d -> d.findElements(
    By.cssSelector("[data-testid^='infinite-ad-']")
).size() > initialCount);

// Cypress - Verify all ad types exist
cy.get('[data-ad-type="horizontal"]').should('exist');
cy.get('[data-ad-type="rectangle"]').should('exist');
cy.get('[data-ad-type="in-article"]').should('exist');
cy.get('[data-ad-type="matched-content"]').should('exist');
cy.get('[data-ad-type="in-feed"]').should('exist');

// Playwright - Test infinite scroll
const initialCount = await page.locator(
    '[data-testid^="infinite-ad-"]'
).count();
await page.evaluate(() => 
    window.scrollTo(0, document.body.scrollHeight)
);
await page.waitForFunction(
    (count) => document.querySelectorAll(
        '[data-testid^="infinite-ad-"]'
    ).length > count,
    initialCount
);