← All Insights

Demystifying NER: How Named Entity Recognition Helps Understand Test Cases

One of the most time-consuming activities in software quality assurance is translating human-written test cases into executable automation scripts. A tester writes "Open the Login screen and insert valid credentials," and an automation engineer must interpret what that means, map it to UI elements, and write the corresponding code.

What if a machine could understand those test steps directly?

Named Entity Recognition, an NLP technique, makes this possible by identifying key elements like actions, screens, and objects from everyday language. The goal is converting human-readable test steps into machine-executable automation scripts without manual translation.


What is Named Entity Recognition (NER)?

NER is a Natural Language Processing subtask that identifies and classifies words or phrases in a sentence into predefined categories.

Within QA automation contexts, it deconstructs English test steps into actionable components:

  • Screens: UI areas like "Login screen" or "Job Order page"
  • Actions: Operations including "insert," "submit," "delete," "click," "open"
  • Objects: Functional items such as "Job order," "form," "button," or "user"

Once a model can reliably extract these entities from plain English, the path to automation becomes structured and programmable.


Why BERT?

For this project, I fine-tuned a BERT-based NER model specifically trained on test case language.

The bert-base-cased model was selected for three reasons:

  • It is pre-trained on a massive corpus of English text
  • It preserves capitalization, which is useful for identifying UI element names
  • It demonstrates strong performance on token-level classification tasks

BERT's bidirectional nature allows it to understand context from both directions in a sentence, which matters when a word like "Submit" could be an action in one context and a button label in another.


Fine-Tuning the Model

The fine-tuning process used task-focused datasets with tokenized test steps and IOB tagging schemes.

A sentence like "Create Job Order Screen" becomes tokens labeled with tags:

  • "Create" → B-ACTION
  • "Job" → B-ORDER
  • "Order" → I-ORDER
  • "Screen" → B-TOOL

The training pipeline followed these steps:

  1. Tokenization: Applied BertTokenizerFast for input tokenization with label alignment
  2. Dataset Preparation: Created synthetic yet diverse train/test datasets using Hugging Face's datasets.Dataset class
  3. Label Alignment: Managed alignment between original tokens and subwords, marking unaligned subwords with -100 to exclude them from loss calculation
  4. Fine-Tuning: Used Hugging Face Trainer API with learning rate 2e-5, batch size 16, and 5 epochs
  5. Model Saving: Preserved the fine-tuned model and tokenizer locally for inference

Results

The saved model successfully processes test steps like "Open Job Order Screen" and accurately tags entities using B-SCREEN, I-SCREEN, and B-ACTION labels.

What was previously a manual interpretation process, a QA engineer reading a test step and deciding what it means, becomes an automated extraction. The structured output can then feed into an intent detection layer that maps entities to actual automation commands.


Why This Matters for Engineering Teams

Manual test automation is one of the biggest bottlenecks in QA-heavy organizations. Engineers spend significant time writing boilerplate automation that mirrors what testers already wrote in plain English.

NER-based test understanding is the first step toward closing that gap. Once a model reliably extracts screens, actions, and objects from test language, the next layer, intent detection and code generation, becomes tractable.

This approach does not replace QA engineers. It removes the translation work so they can focus on designing better test coverage rather than writing automation scripts.


What Comes Next

The trained NER model converts plain English test steps into structured, automation-ready formats. The next part of this series covers intent detection: how to map extracted entities to concrete automation actions and generate executable test code from natural language descriptions.