Sobes.tech
Middle

How to test the display of banners on the website if they can vary depending on locales?

sobes.tech AI

Answer from AI

  1. Identification of locales and banners: Determine which locales (languages, regions) the site supports and for which locales banners are provided. Obtain a list of all possible banners for each locale.

  2. Test cases: Create test cases for each combination of locale and banner. For each test case, describe:

    • Input conditions (selected locale, user actions leading to banner display).
    • Expected result (correct display of the specific banner for the selected locale).
    • Acceptance criteria (e.g., correct text, image, clickability).
  3. Manual testing:

    • Manually switch the site locale via UI.
    • Navigate through the site to trigger banner display in each locale.
    • Visually verify the correctness of banner display (text, image, placement).
    • Check clickability (redirect to the correct URL).
  4. Automated testing:

    • Use a web automation framework (e.g., Selenium, Cypress).
    • Create tests that:
      • Set the required locale (via cookies, URL parameters, or site functionality).
      • Navigate to pages with banners.
      • Check for the presence and visibility of banner elements (e.g., via CSS selectors or XPath).
      • Verify banner content (text, image URL) matches the expected for the given locale (can compare with reference data).
      • Check the href attribute of the banner link.
# Example using Selenium WebDriver
from selenium import webdriver
from selenium.webdriver.common.by import By

def test_banner_display(driver, locale, expected_banner_text):
    # Set locale (example: via cookies)
    driver.add_cookie({'name': 'locale', 'value': locale})
    driver.refresh()

    # Navigate to the page with the banner
    driver.get("https://your-website.com/page-with-banner")

    # Find the banner element (example: by CSS class)
    banner_element = driver.find_element(By.CSS_SELECTOR, ".banner-class")

    # Check banner text
    assert banner_element.text == expected_banner_text, f"Banner text does not match for locale {locale}"

    # Check banner link URL (if present)
    banner_link = banner_element.find_element(By.TAG_NAME, "a").get_attribute("href")
    # Add validation for banner_link against expected value for this locale
  1. Testing on different devices and browsers: Ensure banners display correctly across various browsers and screen sizes/devices for each locale.

  2. Content testing: Verify that banner text is correctly translated for each locale, free of grammatical errors, and images match regional cultural features (if necessary).

  3. Regression testing: Include banner display tests for different locales in the regression suite to ensure new code changes do not break their display.

  4. Monitoring: After deployment, implement monitoring to track loading or display errors of banners in production for different locales.