Assert CSS Selector Count

Verify a minimum number of matching elements on each page.

The Problem

Sometimes you need more than “present” — you need “at least 5 product cards” or “at least 3 FAQ items.” This assertion counts matching elements against a minimum threshold, catching partial renders where only some items loaded.

The Hard Way

Run document.querySelectorAll('.item').length in the browser console — one page at a time. At pSEO scale, you’d need a headless browser pipeline.

The SEODiff Way

One API call. Results in under 2 seconds.

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

{"urls": ["https://example.com/category/widgets"], "assertions": [{"rule": "selector_count", "value": 5, "selector": ".product-card"}]}
ParameterTypeExample
valueinteger (minimum match count)5

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_exists

Verify critical DOM elements are present on every page.

min_word_count

Prevent thin content by requiring a minimum number of words per page.

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