Assert CSS Selector Exists

Verify critical DOM elements are present on every page.

The Problem

pSEO templates depend on specific DOM structures: a product card, a breadcrumb nav, a FAQ section. When a data source is empty or a component fails to render, the element silently disappears. This assertion checks that a CSS selector matches at least one element, with context about what is present when it fails.

The Hard Way

Open DevTools on every page and check the DOM manually, or write a Playwright script for each selector you care about. Neither scales to thousands of pages checked on every deployment.

The SEODiff Way

One API call. Results in under 2 seconds.

POST https://seodiff.io/api/v1/agent/evaluate

{"urls": ["https://example.com/product/widget-a"], "assertions": [{"rule": "selector_exists", "value": ".product-card"}]}
ParameterTypeExample
valueCSS selector.product-card

Code Examples

Copy-paste examples in your preferred language:

cURL

See the full evaluation example in cURL →

Python

See the full evaluation example in Python →

Node.js

See the full evaluation example in Node.js →

Go

See the full evaluation example in Go →

PHP

See the full evaluation example in PHP →

Related Assertions

selector_count

Verify a minimum number of matching elements on each page.

has_h1

Ensure every page has exactly one H1 heading tag.

has_schema

Ensure every page has valid JSON-LD schema markup for rich results.

Use in CI/CD

Add this assertion to your deployment pipeline. Works with any CI platform:

🐙 GitHub Actions

Block bad deployments with automated SEO checks in your GitHub Actions CI/CD pipeline.

🦊 GitLab CI

Add automated SEO quality gates to your GitLab CI/CD pipelines.

▲ Vercel

Automatically validate SEO on every Vercel preview deployment before promoting to production.

Start testing in 30 seconds

Get an API key and run your first evaluation with a single cURL command.

Get API Key or Read full API docs