This website uses cookies to improve your browsing experience and help us with our marketing and analytics efforts. By continuing to use this website, you are giving your consent for us to set cookies.

Find out more Accept
AI Automation
40 views 13 mins read

Inside an AI Agent Framework for Mobile Testing: Map, Generate, Triage 

Published: – Updated:

An AI agent can write a week’s worth of regression tests in half a day. Deciding whether that code reflects actual application logic and will survive the next deployment can take the rest of the week.  

This is the QA dilemma AI has introduced. Leadership sees a faster path to cover regression. QA engineers see a growing volume of unvetted code they are expected to vouch for.  

Both sides have a point. AI agents for software testing address both needs when they work with well-mapped, repeatable workflows, and someone on the QA team validates their output.  

With that idea in mind, we built TestKit Mobile, a framework that helps small QA teams spend less time investigating false alarms and ship updates faster. In this article, we’ll examine how the framework copes with ambiguous failures, where its capabilities end, and how to ensure AI-generated tests hold up in day-to-day test runs.       

Design principles of AI agents for software testing  

Many QA teams hesitate to bring generative AI into software testing because of its reputation for trading quality for speed. Instead of accelerating releases, it may add review and maintenance work. So, the potential value may seem relatively low compared to the effort invested. 

We built our framework around three principles that address mobile QA’s biggest bottleneck: the time engineers spend creating, checking, and maintaining automated tests.   

First, agents need an accurate picture of the app they will test. More specifically, they need the screens, interactive elements, and identifiers they can use to interact with. Context is vital for agents to write meaningful tests, just as it is for human testers. 

Second, every output is built for human review. That’s why, for every test it generates, the agent returns two things: plain-English Gherkin scenarios understandable by QA and product owners, along with corresponding automation code.   

Third, the agent must diagnose first to apply the right healing. The logic behind many self-healing test automation tools is to make the build pass, so they immediately rewrite locators. This speeds up short-term test runs, though it introduces significant risks to test reliability and bug detection. In our case, the agent determines what went wrong and whether the problem is in the test, the app, or the environment.   

How does our AI agent mobile test framework work 

AI agent's workflow for app mapping, test generation, and failure diagnosis

Stage 1. Mapping a mobile application 

The first command, /ingest-app, solves a common mobile testing challenge related to finding stable identifiers for UI elements. Apps built with Compose, Flutter, and React Native often lack identifiers. Android and iOS also structure screens differently. If an agent guesses the wrong attribute to identify a button, the test either fails right away or, worse, finds the wrong element and passes.  

To avoid that, our agent examines the app file itself, the APK or IPA you’d install on a phone. No physical device or source code is required. On Android, it reads the app’s build settings and interface strings from the package, and detects the UI framework the app uses. The work with iOS is a bit limited because element identifiers only appear once the app is running.  

AI agent mapping mobile app screens

The second half of the map comes from the running app. A script installs the build on a device or emulator and records each screen’s UI hierarchy and a screenshot. The agent can’t navigate the app on its own; it builds the map based on the screens captured by the script and an engineer who opens each screen by hand. Yes, this part remains manual.      

With the UI framework identified, the agent picks a locator strategy: 

UI framework Locator priority 
Native Android and iOS Accessibility ID, then resource ID, then visible text 
Jetpack Compose Content description, then visible text, then testTag (if exposed) 
Flutter Accessibility label, with a recommendation for developers to add Semantics or ValueKey 
React Native accessibilityLabel or testID 

By tying every locator to a real node in a captured screen, we ensure AI agents for mobile app testing can’t invent identifiers. If it needs to fall back on the visible text, it marks that locator for review.  

Stage 2. Turning app context into executable steps 

The command /generate-tests kicks off the second step and assembles a first working suite. The agent creates one smoke scenario per key screen that launches the app, reaches the screen, and performs the main action. It doesn’t need additional documentation to write these basic checks; the app context and captured UI contain all the info it needs.  

A typical generated scenario will look something like this:

Scenario: Add a product to the cart  
Given the app is open on the catalog screen  
When I tap "Add to cart" on the first product  
Then the cart badge shows 1 item

If your repository already has feature files, the agent reads them to match the style and reuse existing steps. This prevents flooding your repo with duplicates, a common pitfall when using generative AI in software testing. The same scenario works on Android and iOS, which you can select during a test run.  

Underneath every plain-English scenario lies the execution code that locates UI elements and verifies app behavior. Separated layers speed up pull-request review and simplify change classification. If you see edits to the scenario, the test’s actual purpose was changed. Edits to the code usually signify minor fixes like locator updates. The exception that should alarm you is weakened assertions.

Gherkin scenario mapped to Java step definitions and Appium screen object methods

Deep regression coverage is a different story. Acceptance criteria and API specs are out of the agent’s scope. To enable the agent to handle business-specific edge cases, such as an expired promo code or a declined payment, describe the steps and expected outcomes. Make sure you captured error states too. Otherwise, you’ll get flagged locators waiting for you in review.  

Stage 3. Diagnosis and self-healing automation 

How do self-healing tests work when the goal is a correct suite, not just a green one? In our framework, /retry-failures first checks whether the failure persists. The command reruns failed scenarios once, marks successful retries as one-off flakes, and investigates recurring failures. 

Its investigation begins with the failed step and error details from cucumber.json, then checks a screenshot, the current UI hierarchy (page-source.xml), and the last 500 lines of Android device log if ADB is available. The agent then compares these artifacts with the app context to see what the screen should contain and understand what went wrong.

How an AI testing agent investigates failed mobile tests

A cheaper model scans massive logs and extracts relevant lines for a stronger reasoning model to diagnose.  

Armed with those clues, the agent puts the failure into one of four buckets. 

Category What the evidence shows What the agent does 
Locator drift The element is in the fresh UI hierarchy, but with a different ID, text, or path Updates the locator, shows the old and new versions, and reruns the test 
Flaky timing The element appears late or inconsistently  Replaces the wait with a better condition; fixed pauses aren’t allowed 
Real defect The expected element or state is missing Reports a suspected app bug, with no repair 
Environment issue A driver, session, network, or external service problem, such as a 5xx from an API Flags it for an engineer, with no repair 

A repair is checked through a rerun. For an obvious issue, like an outdated XPath, one successful run confirms the fix. If the problem persists, the agent stops and hands it to an engineer. It won’t loop endlessly until the test turns green, as some self-healing tests do to hide real bugs. 

Unresolved failures go into a report for your team together with evidence and a suggested next step. Redesigns that add steps or screens are handled the same way. Any fixes the agent makes must undergo code review before landing in your repository.  

What AI testing agents can and can't do

What can go wrong when AI agents for software testing fix tests? 

Give an agent freedom to make the failing tests pass, and you’ll see the same tricks for faking progress that research and practitioner reports describe. In one industrial case study, an agent replaced a strict equality check with a truthiness check and deleted a failing navigation test after seven retries. The final report proudly showed a 100% pass rate on the surviving suite. 

Our framework closes off most of those loopholes with guardrails at every step. 

Risk  Framework countermeasure 
Weakened assertions The agent isn’t allowed to loosen checks. If a fix requires that, it hands the failure to an engineer 
Deleted or skipped failing tests No automatic rule. Mandatory review catches removed tests and steps 
Invented locators Every locator has to match an element in captured screens, and guesses are flagged 
Tests for non-existent flows  Scenarios are generated only for captured screens 
Change to app code The framework is a separate test project. Limit the agent’s access to the test repository, and app code stays out of reach 
Endless retrying The agent reruns a failure once, classifies recurring issues, and stops after a reasonable repair attempt 
Longer pauses masking slow responses Fixed pauses are prohibited. The agent can improve wait conditions instead. 

None of these rules take QA out of the loop. People approve what the agent fixes, resolve what it escalates, and take over complex cases.       

Practices for keeping AI-generated tests reliable 

Someone has to review the agent’s work to make sure it hasn’t missed important scenarios or introduced unsafe repairs. That doesn’t mean reading every line of generated code. Some parts are more vulnerable to errors and worth checking first.   

Since AI testing agents can’t decide what correct feature behavior looks like for your product, the first thing to check is acceptance criteria (AC). The point is that the agent inspects the current version of the app, which may already contain bugs. It can mistake faulty behavior for the expected one and give green checks that validate a defect.   

Also, pay attention to these four details:   

  • Do the generated scenarios include the failure paths from the AC?  
    The baseline suite covers the main action on each screen, which is usually the happy path. Your team should describe the failure path separately. When reviewing, read the Gherkin against the AC to see that the expected behavior is right and no conditions are missing. Only after that, review the automation code.  
  • Have any assertions become weaker?  
    Compare current assertions with the previous version, especially after a repair. An agent might replace an exact-value check with a simple “is not empty” assertion. The test turns green, but no longer verifies whether the application returns the correct result.     
  • Are there fewer tests and steps than before? 
    Count steps and tests in every merge request against the previous one. A shorter suite may be easier to maintain, yet double-check the agent hasn’t removed critical regression coverage.   
  • Do the test logs back up the repair?  
    For anything beyond a routine locator update or small wait adjustment, review the original failure and the agent’s repair trail. Pay particular attention to changes affecting assertions or high-risk user flows. A green rerun doesn’t prove the repair was correct if the test now checks something different. If the agent’s diagnosis contradicts the screenshot or device logs, the failure may point to an actual application defect.      

Last, don’t judge by a single run; watch the trend. If the number of repairs increases from release to release, that’s a reason to reconsider the locator strategy or UI stability. Neither issue is something an agent can or should fix on its own. 

The right boundaries are your leverage 

AI agents in software testing can save your team time, but only when they know what they can and can’t do. An agent that uses only captured screens to choose locators and hands off cases it can’t confidently diagnose shortens review.  

Your testers don’t need to untangle a series of unexplained edits to work out how a test ended up passing. Instead, they gain the hours saved from rerunning flaky tests to think about coverage. And it’s up to you whether your team continues at the current pace or scales automation to the next app. 

Curious which of your flows can be automated?

We’ll look at your app, show where our AI agent framework for mobile testing fits your QA workflow, and tell you in plain terms what it can’t do.

Discuss your project

Start with one app. No full rollout required.

FAQ

How do self-healing tests work? 

When a test step fails, a self-healing tool looks for the expected element using backup attributes such as its text, type, or position, and updates the locator if it finds a close match. Simpler tools stop there and rerun the test. More advanced ones first classify the failure and repair only when the evidence points to a test-side problem.  

Can a self-healing agent hide a bug? 

Yes. If an agent tries to fix every failed test by changing its locator, it may find a similar element and continue the test even though the application is broken. The test passes, but the original problem remains. An agent should first assess why the test failed and escalate suspected defects instead of patching it.    

What’s the difference between self-healing and an AI agent that understands the app? 

A self-healing tool reacts to a broken locator by grabbing the closest match on the screen. An agent maps your app first, learning which screens and elements should be there, so it can distinguish a moved button from a broken feature. That’s the difference between fixing the test and faking a pass.    

Can the agent change my app’s code?  

Only if you give it access. The framework is a separate test project, so it can fix test code such as locators, waits, and test steps. If it’s an app bug, the agent attaches failure logs and screenshots, so your team can pass it to developers. Every change an agent makes undergoes engineer review before it’s added to the suite.   

Let’s talk

The most impactful partnerships start from a first conversation – so let’s have one!

Contact the Aimprosoft team directly using the form on the right. Simply enter your details and we will get back to you shortly, usually in less than 24 hours.

Contact us directly via

+35777788978

contacts@aimprosoft.com

Visit our HQ in

Cyprus, Nicosia, Griva Digeni, 81-83 Jacovides Tower, 1st floor

Meet our representatives in

The UK, Spain, Bulgaria, Poland, and over 15 other European countries

Hey Aimprosoft,

    My name is
    from
    and
    I know you from
    In short,

    Thank you for reaching out!

    We’ve received your message and will get back to you shortly.

    Contact us directly via

    +35777788978

    contacts@aimprosoft.com

    Visit our HQ in

    Cyprus, Nicosia, Griva Digeni, 81-83 Jacovides Tower, 1st floor

    Meet our representatives in

    The UK, Spain, Bulgaria, Poland, and over 15 other European countries

    Learn more

    You may also want to read

    Articles How To Build an IoT Application – The Challenge of The Future cover img
    02 July 2021 31 mins read
    How To Build an IoT Application – The Challenge of The Future
    IoTTelecommunications
    AI Automation How to Evaluate Business Processes for Automation: A Step-by-Step Guide cover img
    19 September 2025 14 mins read
    How to Evaluate Business Processes for Automation: A Step-by-Step Guide
    AI AutomationArtificial Intelligence
    Articles What Is a Dedicated Software Development Team? Pros, Cons, and When to Use One cover img
    01 December 2025 14 mins read
    What Is a Dedicated Software Development Team? Pros, Cons, and When to Use One
    Business Management
    lightbox image
    lightbox image
    lightbox image
    lightbox image
    lightbox image

    Enter your email to download PDF