Skip to content
QA Knowledge Hub

Test cases for a search box

Updated 2026-11-12 · 4 min read

Search looks easy until you list what it must handle. These 32 cases cover matching rules, input edge cases, suggestions, results, performance and security, with a CSV download.

Assumes a site search for products or articles with a search box, a button, optional suggestions as you type, and a results page with sorting and pagination.

How to answer in an interview

Start by asking what is searched (titles only, descriptions, categories?) and what the matching rules are (exact, partial, typo-tolerant, synonyms?). Then cover input, matching, suggestions, results page, performance and security.

Input

IDCategoryTest caseExpected result
S01FunctionalSearch a word that exists in several itemsRelevant results, best matches first
S02FunctionalPress Enter, and click the search buttonBoth run the search
S03NegativeEmpty searchStays on page with a prompt, or shows all items, as specified
S04NegativeOnly spacesTreated as empty
S05FunctionalLeading and trailing spaces around a wordTrimmed
S06FunctionalUpper, lower and mixed caseSame results
S07BoundaryOne character; the maximum length; one over the maximumHandled with clear behaviour; no server error
S08FunctionalVery long text pastedTruncated or rejected politely
S09FunctionalNumbers, hyphens and units (iphone 15, usb-c, 500ml)Match as expected
S10FunctionalNon-English text and emojiWorks or is rejected cleanly; no garbled text

Matching

IDCategoryTest caseExpected result
S11FunctionalPartial word (mobi for mobile)Matches if partial matching is specified
S12FunctionalPlural and singular (shoe, shoes)Same or equivalent results
S13FunctionalA common misspelling (samsng)"Did you mean" or typo tolerance, if specified
S14FunctionalMultiple words in a different orderMatches if specified (all words, any word)
S15FunctionalQuotes around a phrase, or -word to excludeWorks if advanced syntax is supported
S16NegativeSearch for something that does not existA helpful "no results" page with suggestions, not a blank page or error

Suggestions

IDCategoryTest caseExpected result
S17FunctionalType slowly: suggestions appear after the minimum charactersRelevant, limited in number
S18FunctionalChoose a suggestion with mouse and with arrow keys plus EnterSearch runs for that suggestion
S19FunctionalType fast, then change textSuggestions match the latest text, not an old response
S20FunctionalSuggestions do not include hidden or out-of-stock items, if specifiedAs specified

Results

IDCategoryTest caseExpected result
S21FunctionalResult count matches the number of items across all pagesEqual
S22FunctionalPagination: next, previous, last page, and a page beyond the lastCorrect; no duplicates between pages
S23FunctionalSort and filter results, then change the queryBehaviour as specified (filters kept or reset)
S24FunctionalOpen a result, press BackReturns to the same results at the same position
S25FunctionalThe search term is shown in the results heading and in the URLYes; the URL can be shared

Performance and security

IDCategoryTest caseExpected result
S26PerformanceResults appear within the agreed time on a normal connection and on slow 3GWithin limit; a loading state shows
S27PerformanceMany searches in quick successionNo crash; older requests do not overwrite newer ones
S28Security<script>alert(1)</script> as the queryNot executed; shown as text, encoded
S29Security' OR 1=1 -- and similarNo error page or data leak
S30SecuritySpecial characters (% _ \ " & #)Handled as text
S31UIPhone-size screen; the keyboard Search keyWorks; layout intact
S32CompatibilityRepeat S01 on Chrome, Firefox, Safari and EdgeSame behaviour

Downloads

Want a project you can show in interviews?

The portfolio project kit walks you through testing a deliberately buggy app with Selenium or Playwright and API tests, then explaining it. The app itself is free.