<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sinan Gumuskabak</title>
    <description>The latest articles on DEV Community by Sinan Gumuskabak (@sinan_gumuskabak_45e9d8a8).</description>
    <link>https://dev.to/sinan_gumuskabak_45e9d8a8</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4142047%2Fa9093e32-a1fe-4288-b2b0-4bbfd2abfa0b.png</url>
      <title>DEV Community: Sinan Gumuskabak</title>
      <link>https://dev.to/sinan_gumuskabak_45e9d8a8</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sinan_gumuskabak_45e9d8a8"/>
    <language>en</language>
    <item>
      <title>Stop letting your AI agent test Android apps with screenshots</title>
      <dc:creator>Sinan Gumuskabak</dc:creator>
      <pubDate>Thu, 24 Sep 2026 23:24:13 +0000</pubDate>
      <link>https://dev.to/sinan_gumuskabak_45e9d8a8/stop-letting-your-ai-agent-test-android-apps-with-screenshots-1ki7</link>
      <guid>https://dev.to/sinan_gumuskabak_45e9d8a8/stop-letting-your-ai-agent-test-android-apps-with-screenshots-1ki7</guid>
      <description>&lt;p&gt;I shipped an Android app mostly by pairing with Claude Code. Writing features went fine. Testing them on a real phone did not.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;When an AI coding agent tests an app on a device, the usual loop is: take a screenshot, look at it, decide where to tap, tap, take another screenshot. Every step sends an image to the model. A 20-step login-and-checkout flow can cost thousands of image tokens, fill the context window, and the agent still sometimes taps the wrong thing.&lt;/p&gt;

&lt;p&gt;Most of that work doesn't need eyes. "Tap &lt;em&gt;Sign in&lt;/em&gt;, wait, check that &lt;em&gt;Home&lt;/em&gt; is on screen" is a text problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;Android can already describe the screen as text: &lt;code&gt;uiautomator dump&lt;/code&gt; returns every visible node with its text and bounds. So instead of the agent driving the phone step by step, it writes the steps once as JSON:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Login works"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"app"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"com.example.app"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"steps"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"app"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"restart"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Email"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"test@example.com"&lt;/span&gt;&lt;span class="p"&gt;]},&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Password"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"secret123"&lt;/span&gt;&lt;span class="p"&gt;]},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"tap"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Sign in"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"exact"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"expect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Home"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"wait"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and runs it with one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;python scenario.py scenarios/login.json
&lt;span class="go"&gt;PASS Login works (5 steps, 12 s)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One line back. If a step fails, the runner prints the failing step, what &lt;em&gt;was&lt;/em&gt; on screen, and saves a screenshot, which is usually enough for the model to fix either the test or the app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  ✗  5 expect: expected ['Home'] (found []); screen: ['Sign in', 'Wrong password', ...]
FAIL Login works step 5/5 (9 s)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model only opens a screenshot when a visual decision is actually needed (layout, colours).&lt;/p&gt;

&lt;h2&gt;
  
  
  What real devices taught me
&lt;/h2&gt;

&lt;p&gt;Most of the code is not the happy path; it's the stuff that broke on real phones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stale dumps.&lt;/strong&gt; When &lt;code&gt;uiautomator dump&lt;/code&gt; fails during an animation, the old &lt;code&gt;ui.xml&lt;/code&gt; is still on the device and gets pulled again, so the test "sees" the previous screen. The runner deletes the file on both sides before every dump.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The navigation bar.&lt;/strong&gt; Text drawn under the translucent system bar is "visible", but tapping it presses Home. Those nodes are ignored.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Password fields drop characters&lt;/strong&gt; when &lt;code&gt;adb input text&lt;/code&gt; sends the whole string at once. Type character by character.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other apps steal the foreground&lt;/strong&gt; (ads, OEM notification managers). The runner notices and brings the app back.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Switches on settings rows&lt;/strong&gt; with a multi-line description sit ~180 px below the title. Matching by distance fails; matching the smallest container that holds both the text and one Switch works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Airplane mode lies.&lt;/strong&gt; Android remembers Wi-Fi you turned on manually while in airplane mode, so an "offline" test can silently run online. The runner turns Wi-Fi off explicitly and waits until &lt;code&gt;wlan0&lt;/code&gt; has no IP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Airplane mode kills wireless adb&lt;/strong&gt;, stranding the phone. It's refused unless you're on USB.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Using it from an agent
&lt;/h2&gt;

&lt;p&gt;Add a few lines to your &lt;code&gt;CLAUDE.md&lt;/code&gt; / &lt;code&gt;AGENTS.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Device testing&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Never drive the phone step by step with screenshots. Write a scenario in
  scenarios/&lt;span class="nt"&gt;&amp;lt;name&amp;gt;&lt;/span&gt;.json and run: python scenario.py scenarios/&lt;span class="nt"&gt;&amp;lt;name&amp;gt;&lt;/span&gt;.json | tail -3
&lt;span class="p"&gt;-&lt;/span&gt; To see the current screen as text: python ui.py dump
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I ran ~90 scenarios this way on my own app before extracting the runner into its own repo. It's Python standard library + adb, nothing to install on the phone, MIT licensed:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/sinangumuskabak-sys/android-scenario-runner" rel="noopener noreferrer"&gt;https://github.com/sinangumuskabak-sys/android-scenario-runner&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It isn't a replacement for Espresso or Maestro. It's a single file you can hand to an agent so it tests cheaply. Issues and PRs welcome, especially from people on OEM skins I haven't tried.&lt;/p&gt;

</description>
      <category>android</category>
      <category>testing</category>
      <category>ai</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
