[{"data":1,"prerenderedAt":20},["ShallowReactive",2],{"blog-post-en-build-browser-workflows-selectors-survive-page-changes":3},{"slug":4,"lang":5,"title":6,"summary":7,"date":8,"tags":9,"tag_slugs":15,"thumbnail_url":16,"translations":17,"body":18,"asset_base":19},"build-browser-workflows-selectors-survive-page-changes","en","Build Browser Workflows With Selectors That Survive Page Changes","Learn how to choose durable browser selectors and build a repeatable workflow in Broma that keeps running even when supplier pages change.","2026-10-29",[10,11,12,13,14],"browser-automation","selectors","workflow","broma","no-code",[10,11,12,13,14],"https:\u002F\u002Fblog-api.bromaapp.com\u002Fapi\u002Fblog\u002Fposts\u002Fbuild-browser-workflows-selectors-survive-page-changes\u002Fthumbnail.svg?lang=en",[5],"## Why most browser workflows break after the first page update\n\nA 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.\n\nThe 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.\n\n## Principles for selectors that survive\n\nIn 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.\n\n**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`.\n\n**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.\n\n**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.\n\n**Combine attributes when one is not enough.** `[data-testid=\"inventory-row\"][aria-label=\"SKU-1024\"]` is more resilient than either alone.\n\n**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.\n\n## Real-world example: a weekly supplier stock check\n\nImagine 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.\n\nHere is how to build it in Broma, step by step.\n\n### Step 1: Use a dedicated browser profile\n\nCreate 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.\n\n### Step 2: Open the login page\n\nAdd an **Open page** step and enter the supplier login URL. Set a reasonable wait so the page finishes loading before the next step.\n\n### Step 3: Sign in once, then rely on the profile\n\nIf 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.\n\n### Step 4: Navigate to inventory\n\nAdd a **Click** step on the inventory menu item. Use a selector based on visible text or `aria-label`, for example:\n\n```\n[aria-label=\"Inventory\"]\n```\n\nor a text match such as:\n\n```\n\u002F\u002Fbutton[normalize-space(text())=\"Inventory\"]\n```\n\n### Step 5: Wait for the inventory table\n\nBefore 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.\n\n```\n[data-testid=\"inventory-table\"]\n```\n\n### Step 6: Read stock for each SKU\n\nAdd a **Loop** step over your list of SKUs. Inside the loop:\n\n1. **Type** the SKU into the search input:\n   ```\n   [name=\"sku-search\"]\n   ```\n2. **Click** the search button:\n   ```\n   [data-testid=\"search-btn\"]\n   ```\n3. **Wait for element** for the result row:\n   ```\n   [data-testid=\"stock-row\"]\n   ```\n4. **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:\n   ```\n   [data-testid=\"stock-row\"] [data-testid=\"available-qty\"]\n   ```\n\n### Step 7: Handle missing data with a branch\n\nAdd 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.\n\n### Step 8: Save results\n\nWrite 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.\n\n## Reviewing an AI-built workflow\n\nBroma 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.\n\nWhen the agent returns a workflow, review it before scheduling:\n\n1. Open each step and inspect the selector.\n2. Replace positional selectors like `div:nth-child(2)` with attribute-based ones.\n3. Make sure every **Wait for element** targets something visible after the page loads.\n4. Run the workflow once manually and watch the step highlights.\n\nCorrecting selectors at this stage takes minutes. Fixing them after ten failed scheduled runs takes hours.\n\n## Fixing a flow after the supplier changes its page\n\nPage changes are inevitable. When a step fails, do not re-record the whole workflow.\n\n1. Open the run log and find the failed step.\n2. Open the page in a normal browser window and inspect the element.\n3. Identify what changed: a new class, a moved button, a renamed label.\n4. Update the selector in Broma to use the stable attribute or text you found.\n5. Run the step in isolation, then run the full workflow.\n\nIf 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\"]`.\n\n## Reusing the workflow across your team\n\nOnce 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.\n\n## Quick selector checklist\n\nBefore you save a step, ask:\n\n- Does this selector rely on an auto-generated class or ID?\n- Would adding one new banner break this selector?\n- Can I use `data-testid`, `aria-label`, or visible text instead?\n- Did I wait for the element before reading or clicking it?\n- Is the JavaScript expression short and easy to read?\n\nIf the answer to the first two is yes, rewrite the selector before you schedule the flow.\n\nDurable 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.\n","https:\u002F\u002Fblog-api.bromaapp.com\u002Fapi\u002Fblog\u002Fposts\u002Fbuild-browser-workflows-selectors-survive-page-changes\u002Fassets",1794729624908]