Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Best practices for agentic testing in Low Code Automation

Learn how to prepare your website, write test cases, and review results so that AI automates your tests reliably.

In agentic testing, AI automates your test case the way a manual tester would. It reads your steps, opens your website in a real cloud browser, and finds buttons and fields by what they show on screen. The clearer your test case and the easier your website is to reach, the more cases AI automates on the first attempt, and the more of those tests keep passing when they run in your test suites.

Follow these guidelines:

For tests you record yourself, see Best practices for recording tests.

Prepare your website for AI automation

AI can automate only what it can reach and see. Many runs fail before AI records a single step because the website is blocked, is private, or needs data that the test case doesn’t give. Check the following before you automate:

  • Make private websites reachable: If your website runs on an internal network, on a staging server, or behind an IP allowlist, turn on Enable local testing in the run settings. Keep BrowserStack Local running on your machine while AI automates. For more information, see Test on internal network.
  • Let test traffic through bot protection: AI doesn’t solve CAPTCHAs or get past bot-protection challenges, such as Cloudflare, reCAPTCHA, or a web application firewall. On your test environment, turn these off. If you can’t, add your own header or cookie in Additional config in the run settings, and add a rule to your firewall that allows requests with that value. Use a private value, and use it only on test environments. Headers in the run settings take plain text values, not variables. For more information, see Advanced options.
  • Turn off multi-factor authentication for test accounts: AI can’t enter codes from an authenticator app. Use a test account that doesn’t need multi-factor authentication, or a fixed code on your test environment. For codes sent by email, see Use BrowserStack test email IDs for email and OTP steps.
  • Reduce pop-ups and changing content: Cookie banners, newsletter pop-ups, onboarding tours, chat widgets, A/B tests, and location-based redirects can differ from one run to the next. A test that AI recorded with one version of the page can then fail on the next run. On your test environment, turn off what you can. For what stays:
    • Tell AI how to handle it in the test case, for example If a newsletter pop-up appears, close it.
    • To always get the same A/B version, set a cookie or local storage value in Additional config.
    • To test a region, start from that region’s URL, or turn on Enable IP geolocation. For more information, see IP geolocation.
  • Give elements clear, visible names: AI finds elements by their visible text and by their accessible name, which is the label that a screen reader reads out. Buttons that show only an icon, or several buttons with the same text, are harder for AI to pick out. Ask your developers to give icon buttons a name, such as aria-label="Delete item", and to add stable test attributes, such as data-testid="checkout-button". These also make the saved test more stable when it runs again.

Write test cases that AI can automate

AI follows your test case as written and can’t ask what you meant. Write each case the way you would brief a new tester:

  • Cover one workflow per test case: For example, Log in, or Add a product to the cart and check out. Don’t combine several workflows into one case. Short, focused cases run on their own, fail for one clear reason, and are easier to fix. Very long cases are also more likely to run out of time.
  • Start with a goal and a starting URL: Use the title to say what a pass looks like. AI follows your steps to reach this goal, and can adjust them when your website needs it, so a clear goal matters. Include the URL in the objective, for example Test the add to cart flow on https://shop.example.com. If a case has no starting URL, AI asks for one when you click Automate.
  • Write steps as tasks a person can follow: A step can be a whole task. You don’t need to list every click, because AI works out the actions for each step. For example, Search for "wireless headphones" and open the first result. Avoid vague steps, such as Test the page.
  • Refer to what users see on screen: Name the visible label, for example Click Add to cart or Enter the email in the Email field. Don’t use CSS selectors, XPath, or element IDs. If more than one element matches, say which one, for example Click Delete in the row for order 1042.
  • Set the starting state in the steps: Each run starts in a new browser, so the user is not logged in and the cart is empty. AI treats Preconditions as facts that are already true and doesn’t perform them. If the test needs a logged-in user or an item in the cart, add the steps that get there, or add a recorded module for them.
  • Add an expected result where you want a check: AI checks a step only when the step has an expected result. A step without one is treated as an action. Add checks at the points that matter, for example after you log in, on the cart page, and after payment.
  • Check what’s visible on screen: Check text, values, and whether an element is shown, hidden, enabled, or disabled. AI can’t check database values, network calls, or browser console logs inside a test.
  • Write expected results that stay true on every run: Avoid exact values that change between runs, such as dates, prices, order numbers, or stock counts. Describe the pattern instead, for example An order number is shown, or use a variable.
  • Say when to repeat or when something is optional: AI repeats actions only when the case says so, for example Add the product to the cart 3 times. If something may or may not appear, say what to do when it does, for example If a cookie banner appears, click Accept all.

The following table shows how to improve common test case steps:

Instead of Write
Click #btn-submit-2 Click Place order
Test login Log in as the standard user. Expected: The Dashboard page opens and shows Welcome.
Log in with admin / Passw0rd! Log in with the username variable and the password secret. Add both with @.
Verify the total is $499.00 Verify that the cart total matches the product price.
Verify the API returns 200 Verify that the confirmation message is shown.
One case that signs up, logs in, buys a product, and cancels the order Three separate cases: sign up, buy a product, and cancel an order

The following example shows a complete test case:

Title: Buy a product as a guest
Objective: Check that a guest can buy a product on https://shop.example.com
Steps:
1. Search for "wireless headphones" and add the first result to the cart.
   Expected: The cart icon shows 1 item.
2. Open the cart and click Checkout.
   Expected: The checkout page shows the product in the order summary.
3. Fill the shipping details with test data and place the order.
   Expected: The message "Order confirmed" is shown with an order number.

Give AI test data, credentials, and context

AI pauses and asks you when a case needs information it doesn’t have, such as a password or a value to enter. To let AI finish the case without waiting for you, give it everything up front:

  • Never type real passwords in a test case or in the chat: Save passwords as secrets and add them to the step with @. Secrets show only their name. The value is filled in when the test runs, and it is never saved in the test.
  • Give every input the case needs: Include the test account, search terms, and form values. AI uses the credentials in the test case’s steps, preconditions, or description before it asks you for them. If something is still missing, AI pauses the run and asks you in the chat. If no one answers within 3 minutes, the run stops.
  • Use variables for values that change: Type @ in a step to add a variable:
    • Use global variables for values that many tests share, such as a username.
    • Use functions to generate a new value on every run, such as a new email address for a sign-up test.
    • Use a test dataset to run the same case with many rows of data, instead of writing a separate case for each row. While AI automates, it uses the first row. Cloud runs use every row you select.
  • Use BrowserStack test email IDs for email and OTP steps: AI reads emails only from BrowserStack test email IDs. Use a temporary email ID, which is new on every run, for sign-up tests. Use a permanent email ID for an account that already exists. Write the step plainly, for example Open the verification email and enter the 6-digit code. For more information, see Test email workflows.
  • Attach files to the step that uploads them: Attach one file to each upload step. For more information, see Upload files.
  • Reuse recorded modules for common flows: If many tests log in the same way, record the login once as a module. Type # in the refine box to add it, and AI places it at the right step. Steps inside a module run exactly as recorded, and AI doesn’t re-record them. When your login page changes, update the module.
  • Describe your application in Instructions: Instructions are files that tell AI what a new tester would need to know about your application. To add one, click Instructions, enter a file name such as rules.md, then click Add. Write your instructions, click Save, and turn the file on. AI uses the instruction files you turn on when it generates test cases and when it explores a URL. It doesn’t use them when it automates test cases. So when you automate test cases you already have, put details such as how to log in and which pop-ups to close in the test case itself. Keep instructions factual and short, and never put passwords in them.

The Instructions dialog with an instruction file toggle and the field to add a new file.

Delete the sections that don’t apply to you, and start with the application, login, things to close first, and what success looks like. Use the following template for your instructions:

1. About the application:
   What the application does, its main areas, and its user roles.

2. Environments and URLs:
   The environment to test, its starting URL, and what not to touch, such as production.

3. Login:
   How to log in and which test account to use. Name the variable or secret. Don't write the password.

4. Navigation:
   Where the main menu is, whether menus open on click or hover, and how dialogs close.

5. Things to handle first:
   Cookie banners, tours, pop-ups, and loading spinners, and how to close or wait for each one.

6. Test data:
   Default values to use, values that must be new on every run, and datasets to use.

7. What success looks like:
   The message or page that shows that a key action worked.

8. Known issues to avoid:
   Elements not to click, areas that load slowly, and flows that are no longer used.

9. Glossary:
   Terms your application uses and what they mean.

For example:

2. Environments and URLs: Test on https://staging.shop.example.com. Never run tests on production.
3. Login: Click Sign in at the top right. Use the test_username variable and the shop_password secret.
5. Things to handle first: Click Accept all on the cookie banner. Click Skip tour if the welcome tour opens.
7. What success looks like: After Add to cart, the cart count in the header goes up by one. After checkout, "Order confirmed" and an order number are shown.
8. Known issues to avoid: Don't click the chat bubble at the bottom right. It can cover buttons.

Automate and review results

  • Check the run settings first: Click the settings icon beside Automate to set local testing, resolution, headers, cookies, and other options. The settings apply to every case in the batch. AI uses the same settings when it replays and fixes the test. For the full list, see Automate tests and configuration.
  • Try one case before you automate many: Automate one case and check that it passes, then select the rest. Problems with your setup, such as a blocked website, BrowserStack Local not running, or a missing login, then show up once instead of in every case. This also saves your monthly limit.
  • Review the cases before you automate: Read each case’s Description, Preconditions, and Test steps. Edit or delete what you don’t need. To change several cases at once, describe the change in the refine box, for example add a negative case for an empty email field.
  • Stay with the session to answer questions: Watch the live session while AI works. Answer when AI asks for information, so the run doesn’t stop.
  • When a run fails, add context instead of starting over: Read the AI reasoning to see where it got stuck. Reply in the chat with what AI missed, for example The Submit button is on the Billing tab.
  • Treat a possible website issue as a possible bug: Possible website issue means that your website didn’t do what the expected result says. Check your website before you change the expected result. If the expected result is out of date, update it.
  • Take over with the recorder when AI can’t finish: If AI can’t automate a case, click Record this test manually to continue it in the recorder.
  • Review the test before you save it: Nothing is added to your tests until you click Save. Open each step to see the actions AI recorded under it. Check that each expected result was checked, and remove steps you don’t need. After AI records a test, it replays the whole test once to check that it works. Save tests that passed this check.

Maintain AI-automated tests

  • Run saved tests like any other test: A saved AI test is a standard Low Code Automation test. Add it to test suites, schedule it, and run it on other browsers, as you do with tests you record.
  • Change a step by editing its intent: To change what a step does, open the test, click the step’s text, and change it. AI records the step again from there. If you edit the test in the recorder instead and save it, it becomes a standard recorded test. AI then no longer records steps again when your website changes, though element-level AI self-healing still applies. To undo this, restore the earlier version from version history.
  • Review tests that AI healed: When adaptive healing fixes a test in a build, it saves the fix as a new version of the test. Open the test’s version history to see what changed. Healing doesn’t hide real failures. If your website shows a wrong value or a missing message, the test still fails, so check it as a possible bug. For more information, see Test versioning.
  • Use your monthly limit on tests that matter: You can automate up to 100 test cases each month, shared by everyone on your account. Automate the cases you plan to run again and again, not one-time checks. Each new test case that AI automates counts once, and each URL exploration counts once. Stopping a run doesn’t give the count back. Guiding a running session in the chat, refining cases before you automate, and AI fixing a test while it automates don’t count.

AI currently has the following limitations. To handle these scenarios, build your test steps using the recorder instead:

  • Browser support: AI only automates, validates, and heals tests on Chrome. However, you can still run your saved tests across other browsers within your test suites.
  • CAPTCHAs and bot protection: AI cannot solve CAPTCHAs or bypass bot-protection challenges.
  • Authenticator codes: AI can’t enter codes from an authenticator app. To automate two-factor logins, use the built-in TOTP authenticator in the recorder.
  • Canvas elements: AI cannot interact with HTML <canvas> elements, such as charts, maps, or drawing areas. See Canvas for workarounds.
  • Touch gestures: AI does not support swipes or other touch-based gestures.
  • Database queries: AI cannot add database query steps to a test.
  • Email verification: AI can only read emails sent to BrowserStack test email IDs.

Need more help?

If you need any additional help, feel free to contact us.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle