Here’s a comprehensive solution that addresses dynamic table parsing, header-based mapping, and UI change resilience for your RPA bot.
Dynamic Table Parsing with Header-Based Mapping:
Replace your fixed column index approach with dynamic header mapping. Add an ‘Execute JavaScript’ action in your RPA bot workflow after navigating to the order table:
// Build dynamic column mapping from headers
var headers = document.querySelectorAll('table.orders thead th');
var columnMap = {};
headers.forEach((header, index) => {
var headerText = header.textContent.trim().toLowerCase();
columnMap[headerText] = index;
});
// Extract data using mapped indexes
var rows = document.querySelectorAll('table.orders tbody tr');
var orders = [];
rows.forEach(row => {
var cells = row.querySelectorAll('td');
orders.push({
status: cells[columnMap['order status']]?.textContent.trim(),
deliveryDate: cells[columnMap['delivery date']]?.textContent.trim(),
orderNumber: cells[columnMap['order #']]?.textContent.trim()
});
});
return JSON.stringify(orders);
This script builds a mapping from header text to column index, then uses that mapping to extract data regardless of column position changes.
Header Text Variations and Resilience:
To handle header text changes (“Order Status” vs “Status” vs “Current Status”), implement flexible matching:
function findColumnIndex(headers, searchTerms) {
for (let i = 0; i < headers.length; i++) {
var headerText = headers[i].textContent.trim().toLowerCase();
for (let term of searchTerms) {
if (headerText.includes(term.toLowerCase())) {
return i;
}
}
}
return -1;
}
var statusIndex = findColumnIndex(headers, ['order status', 'status', 'current status']);
var dateIndex = findColumnIndex(headers, ['delivery date', 'delivery', 'ship date']);
This searches for multiple possible header variations, making your bot resilient to minor UI text changes.
Handling Asynchronous Table Loading:
Before executing the extraction script, add a ‘Wait for Element’ action that ensures the table is fully loaded:
- Add ‘Wait for Element’ action with condition:
table.orders tbody tr exists and count > 0
- Set timeout to 30 seconds
- Only then execute the JavaScript extraction
This prevents incomplete data extraction when the table loads asynchronously via AJAX.
UI Change Resilience Strategy:
Since the supplier is continuously updating for mobile responsiveness, implement these defensive patterns:
1. Multiple Table Selectors: Use a fallback chain for table selection:
var table = document.querySelector('table.orders') ||
document.querySelector('table#order-list') ||
document.querySelector('div.order-data table');
2. Validation and Error Handling: After extraction, validate that critical fields were found:
if (statusIndex === -1 || dateIndex === -1) {
throw new Error('Critical columns not found. Table structure may have changed.');
}
This triggers the bot’s error handling workflow to notify your team immediately when table structure changes significantly.
3. Structure Fingerprinting: Log the detected column structure each run:
var structure = Array.from(headers).map(h => h.textContent.trim()).join('|');
console.log('Table structure: ' + structure);
Store this in Creatio logs. When extraction starts failing, compare recent structure logs to identify what changed.
Bot Workflow Configuration:
Update your RPA bot workflow sequence:
- Navigate to Portal (existing web recorder action)
- Wait for Table Load (new: explicit wait for table element)
- Extract Column Structure (new: JavaScript to build header mapping)
- Validate Structure (new: check critical columns exist)
- Extract Order Data (modified: use dynamic column mapping)
- Transform to Creatio Format (existing: map to Creatio order objects)
- Import to Creatio (existing: bulk insert action)
Add error handling at step 4: if validation fails, send notification to RPA team and log the current table structure for analysis.
Testing and Monitoring:
Implement continuous monitoring:
-
Dry Run Mode: Add a bot parameter for dry-run mode that extracts and logs data without importing. Run this hourly to detect structure changes early.
-
Structure Change Detection: Compare the column structure fingerprint from each run. If it differs from the previous run, send an alert even if extraction succeeds.
-
Extraction Quality Metrics: Track the percentage of rows where all critical fields were successfully extracted. Alert if this drops below 95%.
Why This Approach Works:
- Header-based mapping eliminates dependency on fixed column positions
- Flexible string matching handles minor header text variations
- Explicit waits ensure data is fully loaded before extraction
- Structure validation catches breaking changes immediately
- Monitoring provides early warning of UI changes
This solution transforms your bot from brittle fixed-index extraction to a resilient system that adapts to UI changes. The 40% failure rate should drop to near-zero, and when the supplier makes breaking changes, you’ll be notified immediately with enough diagnostic data to adapt quickly.