
Collabotics builds Robotic Process Automation (RPA) software: robots that take over repetitive work in digital applications. To click the right button or read the right field, the robot needs to find that element on screen. It does this by turning the interface into an XML tree and pointing at the element with an XPath expression.
The problem is that interfaces change. The same screen can look different per device, browser or operating system, and an XPath that works on one version can break on the next. A previous Zuyd project built a genetic algorithm that generates these XPaths automatically. In this project, together with my team and under supervision of Zuyd's Research Centre for Data Intelligence, we made that algorithm more robust, more flexible and easier to use.
Because the work was done for a real client with real customer data, the dataset (160 invoices and order confirmations converted to XML) stays private under NDA. The page below therefore shows the ideas, not the data.
The existing algorithm worked, but it had four clear limits. It could only target one element per run, it used one fixed definition of a "good" XPath, its evolutionary operators were hardcoded, and there was no interface: changing a setting meant editing and recompiling the code.
Before we could change anything we had to understand a codebase we did not write. Issues like the "single-target anchoring" were hidden deep in the generation loop and only showed up after long code analysis and testing. That taught me a lot about reading, questioning and safely improving someone else's work.
Multi-target seeding. The starting population now contains candidates for every target element, and mutation and replenishment pick a random target each generation. The algorithm can now find XPaths that match several elements at once.
Configurable fitness presets. Readability, Speed and Flexibility each tune a set of fitness weights. Three sliders blend them, so the user can steer the result anywhere between the three goals.
New sub-algorithms. Tournament Selection and Uniform Crossover were added next to Roulette Wheel and Two-Point Crossover, and can be switched at runtime.
Prototype interface. A WinForms app (XPathGenUI) lets you load XML files, pick target elements in a tree view, set the sliders and strategies, and inspect the results with fitness, precision and recall.
We followed Design Science Research: requirements, design and build, evaluate, and repeat. Every sprint ended in a meeting with the technical project owner at Collabotics, whose feedback went far beyond requirements. He spotted, for example, that our Speed preset behaved like a readability preset, and that attributes such as @Handle and @ProcessId are volatile and should be avoided.
Our group mixed IT and non-IT backgrounds. That made the documentation and stakeholder communication stronger, but it also meant the core development work was not evenly spread, and we learned to plan around that.
The presets produce clearly different XPaths. Speed gives longer paths with direct child steps, which are cheaper to evaluate. Readability and Flexibility both prefer short paths with // that point straight at the element type, without volatile attributes.
Multi-target seeding now finds all targets, but full recall needs more general expressions, which lowers precision (83.3% in the five-button test). The choice of selection and crossover strategy hardly changed the result, so the fitness function matters more than the operators for this problem.
| Preset | Typical XPath | Character |
|---|---|---|
| Readability | //Word[@Text='20'] | Short, concise |
| Speed | /Document/Page/Paragraph/Line/Word[...] | Longer, explicit child steps, fast to evaluate |
| Flexibility | //Word[@Text='20'] | Short, no volatile structure, survives UI changes |
Targets in different subtrees cannot be matched precisely with the current XPath grammar. The next step is to extend the chromosome to support disjunctive predicates. The Flexibility preset also reduces attribute use in general, instead of filtering only volatile attributes; adding volatility metadata to the metadata provider would fix that. Finally, the algorithm should be validated on more application types.
The three sliders always add up to 100%, just like in the prototype. The weights are blended with the formula from the project, w = αr·wread + αs·wspeed + αf·wflex, using the real preset values. Parameters a preset does not set are treated as a neutral 1.0 here, and the XPath shown is an illustration of the behaviour we measured, not a live run of the algorithm.