Build Browser Workflows With Selectors That Survive Page Changes
Why most browser workflows break after the first page update
A browser workflow is only as reliable as its selectors. When a supplier dashboard adds a new banner, renames a CSS class, or reorders a table, a step that worked yesterday can fail today. For operations staff and e-commerce sellers running the same check every morning, that means manual rework, missed stock alerts, and lost trust in automation.
The fix is not to record more steps. It is to choose selectors that describe what an element is, not where it happens to sit on the page today.
Principles for selectors that survive
In Broma, every step that interacts with the page needs a way to find the target: a button, an input field, a stock number, a status badge. Durable selectors follow these rules.
Prefer stable attributes. Look for attributes that developers change less often than layout classes: data-testid, aria-label, id when it is semantic, or name. Avoid auto-generated classes like .css-1ab23d or IDs like btn_4829.
Use visible text and roles. A button labeled "Export CSV" is easier to locate reliably than the third button in a card. Use text-matching selectors when the label is stable.
Anchor to structure, not position. Instead of div:nth-child(4), locate a section by its heading and then find the table inside it. If a new row is inserted at the top, your flow still finds the right table.
Combine attributes when one is not enough. [data-testid="inventory-row"][aria-label="SKU-1024"] is more resilient than either alone.
Keep JavaScript expressions short and local. Broma supports short JavaScript expressions for custom checks, but long scripts are harder to debug. Use them only for simple text normalization or attribute checks.
Real-world example: a weekly supplier stock check
Imagine an e-commerce seller who checks five SKUs on a supplier portal every Monday. The workflow should open the portal, sign in, go to the inventory page, read the available quantity for each SKU, take a screenshot if a value is missing, and write the results to a sheet.
Here is how to build it in Broma, step by step.
Step 1: Use a dedicated browser profile
Create a Broma profile just for the supplier portal. The profile keeps its own cookies, login session, and extensions. When the workflow runs, it opens in that profile so you do not have to sign in every time, and your personal browsing stays separate.
Step 2: Open the login page
Add an Open page step and enter the supplier login URL. Set a reasonable wait so the page finishes loading before the next step.
Step 3: Sign in once, then rely on the profile
If you are not already signed in, add Type steps for username and password, then a Click step on the sign-in button. After the first successful run, Broma remembers the session in that profile. Remove or disable the sign-in steps for future runs so the workflow starts directly on the dashboard.
Step 4: Navigate to inventory
Add a Click step on the inventory menu item. Use a selector based on visible text or aria-label, for example:
[aria-label="Inventory"]
or a text match such as:
//button[normalize-space(text())="Inventory"]
Step 5: Wait for the inventory table
Before reading anything, add a Wait for element step targeting the table or container that holds stock data. This prevents the flow from reading stale or missing content while the page is still fetching.
[data-testid="inventory-table"]
Step 6: Read stock for each SKU
Add a Loop step over your list of SKUs. Inside the loop:
- Type the SKU into the search input:
[name="sku-search"] - Click the search button:
[data-testid="search-btn"] - Wait for element for the result row:
[data-testid="stock-row"] - Read text from the available quantity cell. Use a selector scoped to the current row so you do not accidentally read the first row on the page:
[data-testid="stock-row"] [data-testid="available-qty"]
Step 7: Handle missing data with a branch
Add a Branch step: if the stock cell is empty or says "Out of stock," take a Screenshot step and flag the SKU for review. Otherwise, continue to the next SKU. This keeps the loop running even when one product has no data.
Step 8: Save results
Write the SKU and quantity to your output. In Broma this is usually a built-in step or a short JavaScript expression to format the text before saving.
Reviewing an AI-built workflow
Broma can generate a first draft of a workflow from a plain-language description, such as "Check stock for these five SKUs on the supplier portal every Monday." The AI does not come with Broma; you connect your own AI provider through an API key or your ChatGPT or Claude subscription.
When the agent returns a workflow, review it before scheduling:
- Open each step and inspect the selector.
- Replace positional selectors like
div:nth-child(2)with attribute-based ones. - Make sure every Wait for element targets something visible after the page loads.
- Run the workflow once manually and watch the step highlights.
Correcting selectors at this stage takes minutes. Fixing them after ten failed scheduled runs takes hours.
Fixing a flow after the supplier changes its page
Page changes are inevitable. When a step fails, do not re-record the whole workflow.
- Open the run log and find the failed step.
- Open the page in a normal browser window and inspect the element.
- Identify what changed: a new class, a moved button, a renamed label.
- Update the selector in Broma to use the stable attribute or text you found.
- Run the step in isolation, then run the full workflow.
If the supplier added a cookie banner that blocks the inventory button, add a Click step to dismiss the banner before the inventory step, using a selector like [data-testid="cookie-accept"].
Reusing the workflow across your team
Once the stock-check flow is stable, export it from your Broma profile and import it into your teammates' profiles. Each teammate signs into the supplier portal in their own profile, so no one shares login cookies. The selectors stay the same because the supplier page is identical for everyone, but each run uses its own session and history.
Quick selector checklist
Before you save a step, ask:
- Does this selector rely on an auto-generated class or ID?
- Would adding one new banner break this selector?
- Can I use
data-testid,aria-label, or visible text instead? - Did I wait for the element before reading or clicking it?
- Is the JavaScript expression short and easy to read?
If the answer to the first two is yes, rewrite the selector before you schedule the flow.
Durable selectors turn browser automation from a weekend project into a weekday habit. Spend ten minutes choosing the right attribute today, and your Broma workflows will keep running while you focus on the exceptions.
