<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashish Kharche on Medium]]></title>
        <description><![CDATA[Stories by Ashish Kharche on Medium]]></description>
        <link>https://medium.com/@thekharche?source=rss-84a554db6f22------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*b7WKaXq6Ui0aTXtY6qjnKA.jpeg</url>
            <title>Stories by Ashish Kharche on Medium</title>
            <link>https://medium.com/@thekharche?source=rss-84a554db6f22------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 04:49:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thekharche/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Music App UI Testing Series: End-to-End Flutter Testing with Maestro — Part 2]]></title>
            <link>https://medium.com/@thekharche/music-app-ui-testing-series-end-to-end-flutter-testing-with-maestro-part-2-dc38403ff7b6?source=rss-84a554db6f22------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc38403ff7b6</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[maestros]]></category>
            <category><![CDATA[ui-testing]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-ui]]></category>
            <dc:creator><![CDATA[Ashish Kharche]]></dc:creator>
            <pubDate>Tue, 17 Oct 2023 22:27:28 GMT</pubDate>
            <atom:updated>2025-01-09T19:38:59.744Z</atom:updated>
            <content:encoded><![CDATA[<h3>Music App UI Testing Series: End-to-End Flutter Testing with Maestro — Part 2</h3><h4>Write UI tests for your Flutter Apps</h4><p><em>Looking for the easiest way to test iOS, Android, and Web with a single platform? Check out </em><a href="https://www.robintest.com/"><strong><em>Robin — The new standard in Mobile and Web end-to-end testing</em></strong></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lpEx5DuQY5FBY7xPZPBzg.png" /><figcaption>UI Testing a Flutter Music App with Maestro</figcaption></figure><p>In app development, testing is crucial for ensuring an app works well and is user-friendly. <strong>Maestro</strong> is a <strong>UI testing</strong> tool designed to work with <strong>Flutter</strong> apps on Android and iOS. This guide will help you perform end-to-end tests on a music app using Maestro.</p><h3>Prerequisites</h3><p>Before jumping into the setup, it’s essential that you’ve explored the first part of this series.</p><p><strong>Read blog:</strong> <a href="https://blog.mobile.dev/music-app-ui-testing-series-getting-started-with-maestro-in-flutter-part-1-01c6f71f0eb4">Music App UI Testing Series: Getting Started with Maestro in Flutter — Part 1</a></p><p>It lays down the groundwork by guiding you through setting up Flutter and getting the music app up and running locally to ensure a smooth follow-along experience.</p><h3>Setting Up Your Workspace</h3><p>Before delving into UI test scripting with Maestro, getting your workspace in order is useful. Generate a config.yaml file within the .maestro directory, populating it with the following content:</p><pre># config.yaml<br>flows:<br>  - journey/*<br><br>executionOrder:<br>  continueOnFailure: false # default is true<br>  flowsOrder:<br>    - play-music<br>    - view-stats</pre><p>This configuration directs Maestro to look for flows within the journey directory, which will house the Flow files. Moreover, the executionOrder section <strong>outlines the sequence</strong> and behavior of flow executions, ensuring a structured testing procedure​​.</p><p>We’ll delve into the significance of this <strong>specific order</strong> of Flows later in the blog in the “Transitioning to Viewing Stats Journey” section.</p><h4>Source Code</h4><p>Find the GitHub repo with source code and Maestro UI testing Flow files:</p><p><a href="https://github.com/thekharche/maestro-flutter-music-app">GitHub - thekharche/maestro-flutter-music-app: UI Testing a Flutter Music App</a></p><h3>Structuring Your Tests</h3><p>Just as we organized our tests in the <a href="https://blog.mobile.dev/pokedex-ui-testing-series-a-guide-to-end-to-end-react-native-testing-with-maestro-part-2-fe3c4d67c994">React Native series</a>, Maestro tests here allow for a structured layout, letting you arrange your tests in a way that aligns with your app’s needs. For a deeper dive into structuring your test suite, check out this <a href="https://blog.mobile.dev/maestro-best-practices-structuring-your-test-suite-54ec390c5c82">Maestro Best Practices blog post</a>.</p><p>In this guide, like the last, we’ll structure our tests by <strong>journey</strong> and <strong>subflow</strong>. Create a journey directory in the .maestro directory. This is where our tests will live, referring to subflows. Subflows can stand alone, being run as a Flow individually using maestro test, or they can be portioned out into <strong>reusable</strong> <strong>segments of a larger Flow</strong>.</p><h4>Why this structure?</h4><p>Segmenting tests by <strong>journey</strong> and <strong>subflow</strong> aids in breaking down the tests into smaller, more manageable chunks. Each journey mirrors a user’s path through the app, and each subflow represents a portion of that journey. This setup simplifies understanding, writing, and maintaining the tests.</p><p>We’re keeping the file naming relaxed. In this blog, we’ve chosen to use <strong>kebab-case</strong>, just as before.</p><p>Here’s a glance at the structure:</p><pre>(inside .maestro)<br><br>&gt; tree<br>.<br>├── common<br>│   ├── allow-permission.yaml<br>│   └── back.yaml<br>├── config.yaml<br>├── journey<br>│   ├── play-music.yaml<br>│   └── view-stats.yaml<br>└── subflow<br>    ├── check-lyrics.yaml<br>    ├── onboarding-screen.yaml<br>    ├── play-song.yaml<br>    └── search-song.yaml<br><br>4 directories, 9 files</pre><h3>Journey 1: Playing Music</h3><p>Starting with your test, first outline the user journey you want to test. This journey breaks down into subflows, each representing a different user interaction.</p><p>In this guide, let’s work with a single journey. Create a file named play-music.yaml in the journey directory.</p><pre># play-music.yaml<br>appId: ${APP_ID}<br>---<br>- launchApp:<br>    clearState: true<br><br># Onboarding<br>- runFlow: ../subflow/onboarding-screen.yaml<br><br># Search for a song<br>- runFlow: ../subflow/search-song.yaml<br><br># Play a song<br>- runFlow: ../subflow/play-song.yaml<br><br># Check Lyrics<br>- runFlow: ../subflow/check-lyrics.yaml</pre><p>Here’s a breakdown:</p><ul><li>appId: Your app&#39;s identifier.</li><li>launchApp: Starts the app with a clean slate.</li><li>runFlow: Lists the subflows, covering onboarding, song search, playback, and checking lyrics.</li></ul><h3>Subflow 1: Navigating the Onboarding Screen</h3><p>This subflow checks the user’s interaction with the onboarding screen, ensuring they can enter their name, change language and country preferences.</p><p>Create a file named onboarding-screen.yaml in the subflow directory with the following content:</p><pre># onboarding-screen.yaml<br>appId: ${APP_ID}<br>---<br># Onboarding flow<br>- tapOn: &quot;Enter Your Name&quot;<br>- inputText: &quot;Shadow&quot;<br>- tapOn: &quot;Get Started&quot;<br><br># Change language<br>- assertVisible: &quot;Hindi&quot;<br>- tapOn: &quot;Hindi&quot;<br>- tapOn: &quot;English&quot;<br>- tapOn: &quot;Hindi&quot;<br>- tapOn: &quot;Ok&quot;<br><br># Change country<br>- assertVisible: &quot;India&quot;<br>- tapOn: &quot;India&quot;<br>- scrollUntilVisible:<br>    element: &quot;USA&quot;<br>    direction: DOWN<br>- tapOn: &quot;USA&quot;<br>- assertVisible: &quot;USA&quot;<br>- tapOn: &quot;Finish&quot;<br><br>- takeScreenshot: &quot;onboarding-screen&quot;</pre><p>The scrollUntilVisible action is crucial here, ensuring that the desired option, &quot;USA&quot;, is brought into view before attempting to select it. This <strong>mirrors real user interaction</strong> and verifies the scroll functionality, making your tests robust against potential UI changes or differing screen sizes.</p><h3>mobile.dev on Twitter: &quot;Scroll Until Visible is a good way to scroll until an element becomes visible→ https://t.co/soBGzXBEyl pic.twitter.com/6r0T2xcI7q / Twitter&quot;</h3><p>Scroll Until Visible is a good way to scroll until an element becomes visible→ https://t.co/soBGzXBEyl pic.twitter.com/6r0T2xcI7q</p><h3>Subflow 2: Song Search</h3><p>This subflow ensures the user can search for a song by tapping on the search bar, entering text, and selecting a song from the suggestions.</p><pre># search-song.yaml<br>appId: ${APP_ID}<br>---<br># Search for song<br>- tapOn: &quot;Songs, albums or artists&quot;<br>- waitForAnimationToEnd<br>- inputText: &quot;Sia Chand&quot;<br>- tapOn: &quot;sia chandelier&quot;<br><br># Back (to hide keyboard)<br>- runFlow: ../common/back.yaml<br><br># Tap on search in keyboard for iOS (to hide keyboard)<br>- runFlow:<br>    when:<br>      platform: iOS<br>    commands:<br>      - tapOn: &quot;search&quot;</pre><p>In this subflow, we also utilized the back.yaml flow to handle hiding the keyboard based on the platform as back command is only available for Android. Here&#39;s how we tailored the flow:</p><pre># back.yaml in common directory:<br>appId: ${APP_ID}<br>---<br>- runFlow:<br>    when:<br>      platform: Android<br>    commands:<br>      - back</pre><p>With this setup, we ensure that on Android, the back button is pressed to hide the keyboard, making our test adaptable across platforms.</p><p><strong>Actions:</strong></p><ol><li>Tap on the search bar.</li><li>Wait for any animation to end.</li><li>Input the text “Sia Chand”.</li><li>Select “sia chandelier” from the suggestions.</li><li>Hit back to hide the keyboard for Android or tap on search in the keyboard for iOS to proceed.</li></ol><p>The back.yaml in the common directory ensures that the back action is performed correctly based on the platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*nLmpVmoa7bmTOhvy4Nks_g@2x.png" /><figcaption>Searching for Song</figcaption></figure><h3>Subflow 3: Playing a Song</h3><p>This subflow ensures the user can play a song by navigating to the YtMusic, selecting a song, and interacting with the audio player view.</p><pre># play-song.yaml<br>appId: ${APP_ID}<br>---<br>#  Play a song<br>- tapOn: &quot;YtMusic&quot;<br>- assertVisible: &quot;Chandelier.*&quot;<br>- tapOn: &quot;Chandelier.*&quot;<br><br># Allow permission<br>- runFlow:<br>    when:<br>      platform: Android<br>    file: ../common/allow-permission.yaml<br><br># To bring up the audio player view<br>- tapOn: &quot;player&quot;<br><br>- takeScreenshot: &quot;play-song&quot;</pre><p><strong>Actions:</strong></p><ol><li>Tap on “YtMusic” to navigate to the music section.</li><li>Assert that “Chandelier” is visible. The usage of RegEx is shown here.</li><li>Select “Chandelier” or a similar matching title from the list.</li><li>If on Android, a permission prompt may appear, handled by allow-permission.yaml.</li><li>Tap on “player” to bring up the audio player view.</li><li>Take a screenshot to capture the current state, saved as “play-song.png”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*7xbPONaen1LR1uVuDqoraA@2x.png" /><figcaption>Audio Player</figcaption></figure><h3>Subflow 4: Checking Lyrics</h3><p>To ensure our tests could interact with the lyrics icon, we added a descriptive label to it:</p><pre>IconButton(<br>  icon: const Icon(<br>    Icons.lyrics_rounded,<br>    semanticLabel: &quot;icon-lyrics&quot;, // Descriptive label for accessibility<br>  ),<br>  tooltip: AppLocalizations.of(context)!.lyrics,<br>  onPressed: () =&gt; cardKey.currentState!.toggleCard(),<br>),</pre><p>With the semanticLabel set to &quot;icon-lyrics,&quot; our tests can now easily identify and interact with the lyrics icon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*lBkqrB3UpKt-2s75xQ3zFg@2x.png" /><figcaption>icon-lyrics as seen in Maestro Studio</figcaption></figure><p>This subflow verifies that the user can view the lyrics of the currently playing song.</p><pre># check-lyrics.yaml<br>appId: ${APP_ID}<br>---<br>- assertVisible: &quot;.*icon-lyrics.*&quot;<br>- tapOn: &quot;.*icon-lyrics.*&quot;<br><br># Check if correct lyrics are displayed<br>- assertVisible: &quot;.*Party girls.*&quot;</pre><p><strong>Actions:</strong></p><ol><li>Check if the lyrics icon is visible.</li><li>Tap on the lyrics icon.</li><li>Verify if the correct lyrics, starting with “Party girls”, are displayed.</li></ol><h3>Transitioning to Viewing Stats Journey</h3><p>Moving on from the play-music journey, we now step into the view-stats journey. This new journey aims to showcase the stats, revealing how many songs we&#39;ve played so far and how many times.</p><p>In our config.yaml, we<strong> set the order to play music <em>first</em></strong> in a clean state, <strong>and then view stats</strong> without resetting, to keep track of the music played. This setup ensures that view-stats reflects the musical activity from the play-music journey, providing a <strong>continuous flow</strong> between these journeys.</p><pre># config.yaml<br>flows:<br>  - journey/*<br><br>executionOrder:<br>  continueOnFailure: false # default is true<br>  flowsOrder:<br>    - play-music<br>    - view-stats</pre><h3>Journey 2: Viewing Stats</h3><pre># view-stats.yaml<br>appId: ${APP_ID}<br>---<br>- launchApp<br>- tapOn: &quot;Library&quot;<br>- tapOn: &quot;Stats&quot;<br>- assertVisible: &quot;.*Chandelier.*&quot;<br><br>- takeScreenshot: &quot;view-stats&quot;</pre><p><strong>In this journey, we:</strong></p><ol><li>Launch the app.</li><li>Navigate to “Library.”</li><li>Access “Stats” to view the musical statistics.</li><li>Check if the song “Chandelier” is listed.</li><li>Capture a screenshot named “view-stats” to document the current state.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*1JGTmy6lWw4ZbgOlfCGrjg@2x.png" /><figcaption>Song Stats</figcaption></figure><h3>Running Your Test</h3><p>With all the subflows in place, it’s time to run your test. Execute the following command:</p><p><strong>For Android:</strong></p><pre>maestro test -e APP_ID=com.shadow.blackhole .maestro/</pre><p><strong>For iOS:</strong></p><pre>maestro test -e APP_ID=com.shadow.blackhole.ios .maestro/</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FvGnzVpM3cQM&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DvGnzVpM3cQM&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ae63c23593880851a4c487261218e9f/href">https://medium.com/media/4ae63c23593880851a4c487261218e9f/href</a></iframe><h3>Configuring Flutter for Maestro UI Testing</h3><p>In Part 1, we discussed enhancing UI testing accuracy in Flutter with Maestro Studio by using <strong>Semantics</strong> and <strong>explicitChildNodes</strong>. This setup aids in precise identification and interaction with text elements. Check out the <a href="https://blog.mobile.dev/music-app-ui-testing-series-getting-started-with-maestro-in-flutter-part-1-01c6f71f0eb4"><strong>detailed setup in Part 1</strong></a> to revisit how Semantics and explicitChildNodes contribute to effective UI testing.</p><p><strong>Note:</strong> In this guide, we didn’t showcase <a href="https://maestro.mobile.dev/getting-started/maestro-studio"><strong>Maestro Studio</strong></a>, but it’s a valuable tool for crafting UI tests visually. It simplifies the test creation process, identifying UI elements and could be a useful addition to your testing toolkit.</p><h3>Running on CI</h3><p>Stay tuned for the next part of this series where we’ll delve into running UI tests on a <strong>cloud</strong> infrastructure. We’ll explore screen-recorded UI testing among other advanced topics to further enhance your testing workflow.</p><h3>Conclusions</h3><p>We’ve walked through setting up Maestro UI tests for a Flutter music app on Android and iOS. This setup is a step towards ensuring a smoother user experience through meticulous testing. With the groundwork laid, we’re now set for diving into continuous integration (CI) in the next part.</p><p>Stay tuned!</p><h3>References</h3><p><strong>Part 1 — Getting Started with Maestro:</strong></p><p><a href="https://blog.mobile.dev/music-app-ui-testing-series-getting-started-with-maestro-in-flutter-part-1-01c6f71f0eb4">Music App UI Testing Series: Getting Started with Maestro in Flutter — Part 1</a></p><p><strong>Source Code with Maestro Flow files:</strong></p><p><a href="https://github.com/thekharche/maestro-flutter-music-app">GitHub - thekharche/maestro-flutter-music-app: UI Testing a Flutter Music App</a></p><p><strong>Maestro for Flutter:</strong></p><p><a href="https://maestro.mobile.dev/platform-support/flutter">Flutter</a></p><p><strong>Maestro Best Practices:</strong></p><p><a href="https://blog.mobile.dev/maestro-best-practices-structuring-your-test-suite-54ec390c5c82">Maestro Best Practices: Structuring your Test Suite</a></p><p>🎹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc38403ff7b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Music App UI Testing Series: Getting Started with Maestro in Flutter — Part 1]]></title>
            <link>https://medium.com/@thekharche/music-app-ui-testing-series-getting-started-with-maestro-in-flutter-part-1-01c6f71f0eb4?source=rss-84a554db6f22------2</link>
            <guid isPermaLink="false">https://medium.com/p/01c6f71f0eb4</guid>
            <category><![CDATA[ui-testing]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[maestros]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Ashish Kharche]]></dc:creator>
            <pubDate>Thu, 05 Oct 2023 03:47:40 GMT</pubDate>
            <atom:updated>2025-01-09T19:39:08.526Z</atom:updated>
            <content:encoded><![CDATA[<h3>Music App UI Testing Series: Getting Started with Maestro in Flutter — Part 1</h3><h4>Setup and Configure Flutter for Maestro UI Testing</h4><p><em>Looking for the easiest way to test iOS, Android, and Web with a single platform? Check out </em><a href="https://www.robintest.com/"><strong><em>Robin — The new standard in Mobile and Web end-to-end testing</em></strong></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wymbqc9hMSy6MZxyJuPtkg.png" /><figcaption>Maestro UI Test for Flutter</figcaption></figure><p><strong>Maestro</strong> is a robust UI testing framework for Android and iOS applications. In this guide, we’ll walk you through the process of UI testing a <strong>Flutter app locally</strong> using Maestro, using the <strong>Blackhole</strong> Music app as our example.</p><p>This article provides a step-by-step guide on using <a href="https://maestro.mobile.dev/">Maestro</a> for UI testing in Flutter, emphasizing the importance of configuring Flutter for precise testing with Maestro. Using the Blackhole Music app as an example, it covers setup and configuration. The piece concludes with a practical demonstration through a sample Maestro UI test.</p><p>This is a multi-part series. Upcoming parts revolve around UI testing the real-world Blackhole Music Flutter App.</p><h3>Getting Started</h3><p>1. <strong>Clone the Repository</strong></p><p>Start by cloning the Blackhole Music App repository:</p><pre>git clone https://github.com/thekharche/maestro-flutter-music-app</pre><p>2.<strong> Navigate to the Directory</strong></p><p>After cloning, navigate into the directory:</p><pre>cd maestro-flutter-music-app</pre><p>3. <strong>Installation</strong></p><p>Install the required packages:</p><pre>flutter pub get</pre><h3>Running the Flutter Application in VS Code</h3><p>After getting the code ready, the next step is to run your Flutter application to validate its functionality. Here’s a streamlined guide on how to achieve this using Visual Studio Code:</p><p>1.<strong> Opening the Project</strong></p><ul><li>Launch Visual Studio Code.</li><li>Navigate to <strong>File</strong> -&gt; <strong>Open</strong>, then select and open your Flutter project directory.</li></ul><p>2. <strong>Starting the Emulator/Simulator</strong></p><ul><li>Within VS Code, go to the <strong>View</strong> menu -&gt; <strong>Command Palette</strong> (or press <strong>Ctrl+Shift+P</strong> on Windows/Linux, <strong>Cmd+Shift+P</strong> on macOS).</li><li>Type <strong>Flutter: Launch Emulator</strong> and select it from the list. Choose an Android or iOS device from the list.</li></ul><p>3. <strong>Running the Application</strong></p><ul><li>Ensure your Flutter project is open and navigate to the <strong>main.dart</strong> file.</li><li>On the right top, you can see options to run the Flutter app with the play button as well as select emulator.</li><li>You can also press <strong>F5</strong> to run the app. This will also enable debugging, allowing you to set breakpoints and inspect variables. Use <strong>Ctrl + F5</strong> to run without debugging.</li><li>Alternatively, navigate to the <strong>Run</strong> menu at the top and select Start Debugging or Run without Debugging.</li></ul><p>4. <strong>Interacting with the Running Application</strong></p><ul><li>The app will launch in the chosen emulator or connected device.</li><li>Any code changes can be instantly reflected in the running app by clicking on a Flutter hot reload button.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BsJ36AS4zqkN9gYa2veznA@2x.png" /><figcaption>Running the Flutter Music App</figcaption></figure><h3>Starting Up Maestro Studio</h3><p>Run the command <strong>maestro studio</strong> in your terminal, which will launch Maestro Studio in your web browser. The GUI allows for UI testing, visually and interactively.</p><p><a href="https://maestro.mobile.dev/getting-started/maestro-studio"><strong>Maestro Studio</strong></a> serves as a personal assistant designed to streamline the process of writing Maestro Flows. With its intuitive interface, users can effortlessly identify and interact with UI elements in their apps, use AI to auto-generate test commands, search for all the elements and many more niceties. The platform offers features such as visual selection of UI components</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ICyBKc4HRWpI1PlzpVHdew@2x.png" /><figcaption>Maestro Studio</figcaption></figure><h3>Configuring Flutter for effective Maestro UI testing</h3><p><strong>Note</strong>: While this section introduces <strong>Semantics</strong> and <strong>explicitChildNodes</strong>, their practical usage in UI testing will be extensively covered in <strong>Part 2</strong> of this blog series.</p><p>In a scenario where your Flutter app features a list of songs, each with a title and subtitle, employing <strong>Semantics</strong> and <strong>explicitChildNodes</strong> becomes crucial for UI testing with Maestro Studio. This setup helps in accurately identifying and interacting with specific text elements during testing, ensuring that the title and subtitle for each song are correctly displayed and accessible. By wrapping each <strong>Text</strong> widget with a <strong>Semantics</strong> widget and setting <strong>explicitChildNodes</strong> to true, you create a clear semantic boundary that Maestro Studio can recognize and interact with, making your UI tests more precise and reliable.</p><p>Notice below, the <strong>title</strong> and <strong>subtitle</strong> is not explicitly identifiable. Follow the blue box.</p><p><strong>Original Code:</strong></p><pre>title: Text(<br>  widget.songs[index].title.trim() != &#39;&#39;<br>      ? widget.songs[index].title<br>      : widget.songs[index].displayNameWOExt,<br>  overflow: TextOverflow.ellipsis,<br>),<br>subtitle: Text(<br>  &#39;${widget.songs[index].artist?.replaceAll(&#39;&lt;unknown&gt;&#39;, &#39;Unknown&#39;) ?? AppLocalizations.of(context)!.unknown} - ${widget.songs[index].album?.replaceAll(&#39;&lt;unknown&gt;&#39;, &#39;Unknown&#39;) ?? AppLocalizations.of(context)!.unknown}&#39;,<br>  overflow: TextOverflow.ellipsis,<br>),</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*3N662ubwZVLr_kxV72rADw@2x.png" /><figcaption>Before — Title, Subtitle not identifiable individually</figcaption></figure><p>Adding semantics to your Flutter app and setting <strong>explicitChildNodes: true</strong> can enhance accessibility and allow for more effective UI testing. Here’s a step-by-step guide to help you achieve that.</p><h4><strong>Adding Semantics</strong></h4><p>The <strong>Semantics</strong> widget in Flutter is used to annotate widgets with a description of their meaning, which is essential for accessibility purposes. When you wrap a widget with <strong>Semantics</strong>, you can provide a meaningful label to describe the widget.</p><h4>Configuring <strong>explicitChildNodes</strong> for Precise UI Testing</h4><p>The <strong>explicitChildNodes</strong> property when set to true, directs Flutter to treat each child of the <strong>Semantics</strong> widget as a separate entity in the semantic tree, instead of merging them into one node. This is beneficial for UI testing as it allows for more precise interaction and verification of individual widgets within a complex widget tree.</p><p>Note the blue box.</p><p>When both a <strong>semanticsLabel</strong> and a <strong>text</strong> label are present, the <strong>semanticsLabel</strong> is given priority.</p><p><strong>Code After Configuration:</strong></p><pre> title: Semantics( // ADDED<br>  explicitChildNodes: true, // ADDED<br>  child: Text(<br>    widget.songs[index].title.trim() != &#39;&#39;<br>        ? widget.songs[index].title<br>        : widget.songs[index].displayNameWOExt,<br>    overflow: TextOverflow.ellipsis,<br>    semanticsLabel: &quot;${widget.songs[index].title}&quot;, // ADDED<br>  ),<br>),<br>subtitle: Semantics( // ADDED<br>  explicitChildNodes: true, // ADDED<br>  child: Text(<br>    &#39;${widget.songs[index].artist?.replaceAll(&#39;&lt;unknown&gt;&#39;, &#39;Unknown&#39;) ?? AppLocalizations.of(context)!.unknown} - ${widget.songs[index].album?.replaceAll(&#39;&lt;unknown&gt;&#39;, &#39;Unknown&#39;) ?? AppLocalizations.of(context)!.unknown}&#39;,<br>    overflow: TextOverflow.ellipsis,<br>  ),<br>),</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*MQTB1LeIRaXlOTIVq7ypmA@2x.png" /><figcaption>After — Title, Subtitle identifiable individually</figcaption></figure><h4>Sample Maestro UI Test</h4><p>To ensure our setup is functioning correctly, let’s create a basic Maestro Flow.</p><p>1.<strong> Setting up the Test</strong></p><p>Create a <strong>flow.yaml</strong> file in the <strong>.maestro</strong> directory at the root of your project. Add the following content:</p><pre>appId: com.shadow.blackhole<br>---<br>- launchApp:<br>    clearState: true<br>- assertVisible: &quot;Skip&quot;</pre><p>2. <strong>Run the Test</strong></p><p>Go to your terminal and execute:</p><pre>maestro test .maestro/flow.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U1XIShzdpLGpDRFi9OmA6Q@2x.png" /><figcaption>Running Sample UI Test on the Flutter Music App</figcaption></figure><h3>Stay Tuned</h3><p>The next part of the series will cover end-to-end UI testing of a Music App made in Flutter!</p><h3>References</h3><p><strong>Maestro and Flutter:</strong></p><p><a href="https://maestro.mobile.dev/platform-support/flutter">Flutter</a></p><p><strong>Blackhole Music App Source Code:</strong></p><p><a href="https://github.com/thekharche/maestro-flutter-music-app">GitHub - thekharche/maestro-flutter-music-app: UI Testing a Flutter Music App</a></p><p><strong>Maestro Studio:</strong></p><p><a href="https://maestro.mobile.dev/getting-started/maestro-studio">Maestro Studio</a></p><p>🎹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01c6f71f0eb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s New in Maestro: 1.33.0]]></title>
            <link>https://medium.com/@thekharche/whats-new-in-maestro-1-33-0-7ea6258646e0?source=rss-84a554db6f22------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ea6258646e0</guid>
            <category><![CDATA[ui-testing]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[maestros]]></category>
            <dc:creator><![CDATA[Ashish Kharche]]></dc:creator>
            <pubDate>Sun, 24 Sep 2023 02:21:14 GMT</pubDate>
            <atom:updated>2025-01-09T19:39:14.912Z</atom:updated>
            <content:encoded><![CDATA[<h4>New Add Media Command, Customizable iOS Timeout, Studio Facelift and More!</h4><p><em>Looking for the easiest way to test iOS, Android, and Web with a single platform? Check out </em><a href="https://www.robintest.com/"><strong><em>Robin — The new standard in Mobile and Web end-to-end testing</em></strong></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BHOAHx23B3QP0dgD-O3LDA.png" /><figcaption>Maestro New Release 1.33.0</figcaption></figure><p>We are excited to unveil version <strong>1.33.0</strong>. These updates bring additional functionalities, address various issues, and introduce new capabilities.</p><p><strong>Upgrade to 1.33.0:</strong></p><pre>curl -Ls &quot;https://get.maestro.mobile.dev&quot; | bash</pre><h3>Introduction of the “addMedia” Command</h3><p>Enhancing media integration, Maestro introduces the <a href="https://maestro.mobile.dev/api-reference/commands/addmedia">addMedia</a> command, enabling the <strong>addition of images and videos</strong> directly to iOS and Android devices. This command supports a diverse range of media formats, including JPEG, JPG, PNG, GIF, and MP4. Here’s a glimpse of how you can utilize this command:</p><pre>- addMedia:<br>   - &quot;./assets/image.jpg&quot; # path of image file in workspace<br>   - &quot;./assets/video.mp4&quot; # path of video file in workspace</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9jI4UcWqG1FkV-OK2p6eIA@2x.png" /><figcaption>Adding media files to the device</figcaption></figure><h3>Tailored Driver Startup Timeout for iOS</h3><p>In environments with performance constraints, such as CI/CD, the ability to configure driver startup times is crucial. Maestro introduces the MAESTRO_DRIVER_STARTUP_TIMEOUT feature for the iOS driver, a significant addition <a href="https://github.com/mobile-dev-inc/maestro/pull/1295">contributed by Jesse Farsong</a>.</p><p>This feature allows for the customization of the timeout duration in milliseconds, ensuring optimized reliability when initiating iOS devices. The default is set at 15 seconds, but it can be adjusted as demonstrated below:</p><pre>export MAESTRO_DRIVER_STARTUP_TIMEOUT=60000 # setting 60 seconds<br>maestro test .maestro/flow.yaml</pre><p>Learn more about configuring Maestro driver timeout for Android and iOS <a href="https://maestro.mobile.dev/advanced/configuring-maestro-driver-timeout">here</a>.</p><h3>Maestro Studio’s User Interface Revamp</h3><p>Aesthetic and functional improvements have been made to Maestro Studio’s user interface. The enhancements include the alignment of fonts with the company’s branding and the introduction of a distinct loading animation, offering users clear visual feedback when AI is processing commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HkTsqCqAQItpMJmAxviFpg@2x.png" /><figcaption>Maestro Studio</figcaption></figure><h4>AI Processing Animation</h4><h3>mobile.dev on Twitter: &quot;Introducing: ✨ Maestro AI ✨With recent advancements in LLMs, full AI-driven testing is finally within reach.And Maestro&#39;s simplicity and reliability provides the perfect foundation for AI automation.Check the first step towards something big 🚀 pic.twitter.com/hj2BlfiBRx / Twitter&quot;</h3><p>Introducing: ✨ Maestro AI ✨With recent advancements in LLMs, full AI-driven testing is finally within reach.And Maestro&#39;s simplicity and reliability provides the perfect foundation for AI automation.Check the first step towards something big 🚀 pic.twitter.com/hj2BlfiBRx</p><h3>User-Friendly Timeouts Format</h3><p>Now, values can be separated with an underscore for better readability, e.g., 30_000 instead of 30000. This fix enhances user interaction by making the specification of timeout values clearer and more user-friendly.</p><pre>- extendedWaitUntil:<br>    visible: &quot;My text that should be visible&quot; # or any other selector<br>    timeout: 30_000 # seperate values</pre><h3>Fixes</h3><p>To enhance stability and user experience, several fixes have been deployed:</p><ol><li><strong>Resolution of Crash Issue on iOS</strong>: A fix has been implemented for a crash resulting from resolving the root element for a snapshot operation on iOS.</li><li><strong>Android Driver Connectivity</strong>: The Android driver’s stability has been improved by resolving an issue where it would get stuck when the device was disconnected.</li><li><strong>Addressing XCTestUnreachable Exceptions</strong>: Adjustments have been made to handle XCTestUnreachable exceptions arising from a missing IPv6 config on /etc/hosts.</li><li><strong>Graceful Handling of App Crash Errors</strong>: The handling of app crash errors from XCUITest drivers has been refined for a smoother testing experience.</li></ol><h3>Conclusion</h3><p><strong>Version 1.33.0</strong> of Maestro makes various improvements and fixes across the framework.</p><p>Stay Tuned!</p><h3>References</h3><p><strong>Changelog:</strong></p><p><a href="https://github.com/mobile-dev-inc/maestro/blob/main/CHANGELOG.md">maestro/CHANGELOG.md at main · mobile-dev-inc/maestro</a></p><p><strong>New <em>addMedia</em> Command</strong></p><p><a href="https://maestro.mobile.dev/api-reference/commands/addmedia">addMedia</a></p><p><strong>Maestro driver timeout</strong></p><p><a href="https://maestro.mobile.dev/advanced/configuring-maestro-driver-timeout">Configuring Maestro driver timeout</a></p><p>🎹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ea6258646e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pokedex UI Testing Series: Taking Maestro to the Cloud with Expo EAS & GitHub Actions — Part 3]]></title>
            <link>https://medium.com/@thekharche/pokedex-ui-testing-series-taking-maestro-to-the-cloud-with-expo-eas-github-actions-part-3-ff6257ddd173?source=rss-84a554db6f22------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff6257ddd173</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[ui-testing]]></category>
            <category><![CDATA[maestros]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[expo]]></category>
            <dc:creator><![CDATA[Ashish Kharche]]></dc:creator>
            <pubDate>Thu, 21 Sep 2023 23:32:22 GMT</pubDate>
            <atom:updated>2025-01-09T19:39:20.490Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pokedex UI Testing Series: Taking Maestro to the Cloud with Expo EAS &amp; GitHub Actions — Part 3</h3><h4>Expo EAS / React Native UI testing on Maestro Cloud</h4><p><em>Looking for the easiest way to test iOS, Android, and Web with a single platform? Check out </em><a href="https://www.robintest.com/"><strong><em>Robin — The new standard in Mobile and Web end-to-end testing</em></strong></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z_jMuT-EmtkgXajqG1oeBQ.png" /><figcaption>UI Test Expo EAS app with Maestro Cloud and GitHub Actions</figcaption></figure><p>In our last post, <a href="https://blog.mobile.dev/pokedex-ui-testing-series-getting-started-with-maestro-in-expo-react-native-part-1-73c6dfaa072">part 1</a>, we talked about Maestro, a go-to UI testing tool for Expo React Native apps. In <a href="https://blog.mobile.dev/pokedex-ui-testing-series-a-guide-to-end-to-end-react-native-testing-with-maestro-part-2-fe3c4d67c994">Part 2</a>, we talked about End-to-End UI testing of the app. This time, we’re stepping up with <a href="https://cloud.mobile.dev/"><strong>Maestro Cloud</strong></a>, giving us more flexibility and features. To make this shift smooth, we’re using GitHub Actions, a handy CI/CD tool that’s great for automating tasks.</p><p>For those who want a <strong>quick start</strong>, you can jump right in by cloning our repo. Our GitHub repository has you covered. All the setup code and necessary configurations are readily available there. Instead of navigating through the entire blog, you can simply clone the repo and get started.</p><p><strong>GitHub repository:</strong></p><p><a href="https://github.com/thekharche/maestro-expo-pokedex">GitHub - thekharche/maestro-expo-pokedex</a></p><p>But if you’re here for the details, let’s dive in!</p><h3><strong>Why Maestro Cloud?</strong></h3><p>Maestro Cloud streamlines our UI testing in several ways:</p><p><strong>1. Efficiency</strong>: No need for manual simulator or emulator setups. Just upload the app and Flows, and it’s good to go.</p><p><strong>2. Robust Features</strong>:</p><ul><li>Managed iOS and Android testing environments.</li><li>Parallel test runs for faster feedback.</li><li>Comprehensive logs, screen recordings, and outputs for detailed insights.</li></ul><p><strong>3. Seamless CI Integration</strong>: Easily integrates with popular platforms like GitHub Actions, Bitrise, CircleCI, Jenkins, Azure Pipelines, TravisCI, GitLab CI/CD, Bitbucket Pipelines, etc.</p><p><strong>4. Versatility</strong>: Supports iOS, Android, React Native, and Flutter, ensuring broad testing coverage.</p><p><strong>5. Security</strong>: With SOC 2 compliance, our data’s security and privacy are top-notch.</p><h3>Automating with GitHub Actions</h3><p><strong>File: </strong>.github/workflows/eas-build.yaml</p><p>GitHub Actions provides automation for CI/CD. Here’s our setup:</p><pre>name: EAS Builds<br><br>on:<br>  push:<br>    branches: [main]<br><br>jobs:<br>  eas-build:<br>    name: Maestro Cloud tests for Expo EAS<br>    timeout-minutes: 15<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Setup Repository<br>        uses: actions/checkout@v3<br><br>      - name: Setup Node.js<br>        uses: actions/setup-node@v3<br>        with:<br>          node-version: 18.x<br>          cache: &quot;npm&quot;<br><br>      - name: Setup EAS<br>        uses: expo/expo-github-action@v8<br>        with:<br>          eas-version: latest<br>          token: ${{ secrets.EXPO_TOKEN }}<br><br>      - name: Install Dependencies<br>        run: npm install<br><br>      - name: Build Request for Android<br>        run: eas build --platform android --non-interactive --no-wait --profile internal-apk<br>        shell: bash<br><br>      - name: Build Request for iOS<br>        run: eas build --platform ios --non-interactive --no-wait --profile internal-simulator<br>        shell: bash</pre><p>This workflow, named “EAS Builds”, triggers on every push to the main branch and runs our Maestro Cloud tests.</p><h4><strong>Setup Expo Token</strong></h4><p>If you don’t already have an EXPO_TOKEN , create one from your account settings at <a href="https://expo.dev/">https://expo.dev/</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*LixAcfb4DOfjTSnYSmWgpQ@2x.png" /><figcaption>Get EXPO_TOKEN from Expo Dev Account</figcaption></figure><p>Remember to add the EXPO_TOKEN secret for GitHub Actions in GitHub repository settings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*vnrVLOiwW5vLsDA7RjJN5w@2x.png" /><figcaption>Add EXPO_TOKEN to Secrets of GitHub Actions</figcaption></figure><p><strong>Build Request for Android:</strong></p><p>This step initiates an Android build using EAS. It runs in a non-interactive mode (no user input required), doesn’t wait for the build to finish (--no-wait), and uses the internal-apk profile for specific build configurations.</p><p><strong>Build Request for iOS:</strong></p><p>Similarly, this step starts an iOS build using EAS. It’s also non-interactive, doesn’t wait for completion, and uses the internal-simulator profile tailored for iOS builds.</p><h3>Post-Build Maestro Cloud Integration</h3><p><strong>File:</strong> scripts/eas-build-on-success.sh</p><p>After the app builds, we run our UI tests on Maestro Cloud:</p><pre>#!/usr/bin/env bash<br><br># Check if the environment is local<br>if [ &quot;$ENV_TYPE&quot; = &quot;local&quot; ]; then<br>    echo &quot;this is local environment&quot;<br>    exit 0<br>fi<br><br># If not local, continue with the provided script<br>set -eox pipefail<br><br>curl -Ls &quot;https://get.maestro.mobile.dev&quot; | bash<br>export PATH=&quot;$PATH&quot;:&quot;$HOME/.maestro/bin&quot;<br><br>if [ &quot;$EAS_BUILD_PLATFORM&quot; = &quot;ios&quot; ]; then<br>   APP_EXECUTABLE_PATH=/Users/expo/workingdir/build/ios/build/Build/Products/Release-iphonesimulator/maestroexpopokedex.app<br>   brew install java<br>   echo &#39;export PATH=&quot;/opt/homebrew/opt/openjdk/bin:$PATH&quot;&#39; &gt;&gt; ~/.zshrc<br>   sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk<br>   export CPPFLAGS=&quot;-I/opt/homebrew/opt/openjdk/include&quot;<br>   maestro cloud -e APP_ID=com.thekharche.maestroexpopokedex --api-key=$MAESTRO_API_KEY --app-file=$APP_EXECUTABLE_PATH --flows=.maestro/<br><br>else<br>   APP_EXECUTABLE_PATH=/home/expo/workingdir/build/android/app/build/outputs/apk/release/app-release.apk<br>   maestro cloud -e APP_ID=com.thekharche.maestroexpopokedex --api-key=$MAESTRO_API_KEY --app-file=$APP_EXECUTABLE_PATH --flows=.maestro/<br>fi</pre><p>This script checks the environment, sets up Maestro, and runs platform-specific UI tests.</p><p>You can find your <strong>Maestro API Key</strong> here: <a href="https://console.mobile.dev/">https://console.mobile.dev/</a></p><p>Remember to set up your MAESTRO_API_KEY in Expo Secrets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*xpUwIMjphNQIatAYQVVwNg@2x.png" /><figcaption>Add MAESTRO_API_KEY to Secrets in Expo Dev</figcaption></figure><p>The eas-build-on-success.sh script is crucial for integrating Maestro Cloud into the post-build process. It ensures that once the application is built, it undergoes UI testing using Maestro Cloud. Here&#39;s a breakdown of its key components:</p><p><strong>Environment Check:</strong></p><pre>if [ &quot;$ENV_TYPE&quot; = &quot;local&quot; ]; then<br>    echo &quot;this is local environment&quot;<br>    exit 0<br>fi</pre><p>The script first checks if the environment is local. If true, it prints &quot;this is local environment&quot; and exits.</p><p><strong>Maestro Setup:</strong></p><pre>curl -Ls &quot;https://get.maestro.mobile.dev&quot; | bash<br>export PATH=&quot;$PATH&quot;:&quot;$HOME/.maestro/bin&quot;</pre><p>This section fetches and installs Maestro. The Maestro binaries are then added to the system’s PATH, ensuring subsequent commands can access Maestro tools without specifying their full paths.</p><p><strong>Platform-Specific UI Testing:</strong></p><p>Depending on whether the build platform is <strong>iOS</strong> or <strong>Android</strong>, different sets of commands are executed:</p><pre>if [ &quot;$EAS_BUILD_PLATFORM&quot; = &quot;ios&quot; ]; then<br>  // hidden for brevity<br>else<br>  // hidden for brevity<br>fi</pre><p>In essence, the eas-build-on-success.sh script serves as a bridge between the build process and Maestro Cloud-based UI testing. It ensures that after a successful build, the app is tested in the cloud environment, leveraging Maestro&#39;s capabilities.</p><p>Learn more about <a href="https://docs.expo.dev/build-reference/npm-hooks/"><strong>EAS Build lifecycle npm hooks</strong></a></p><h3>EAS Configuration for Expo</h3><p><strong>File:</strong> eas.json</p><p>This file defines various build profiles for both Android and iOS.</p><pre>{<br>  &quot;cli&quot;: {<br>    &quot;version&quot;: &quot;&gt;= 3.10.2&quot;<br>  },<br>  &quot;build&quot;: {<br>    // hidden for brevity<br>    &quot;development-simulator&quot;: {<br>      &quot;developmentClient&quot;: true,<br>      &quot;distribution&quot;: &quot;internal&quot;,<br>      &quot;ios&quot;: {<br>        &quot;simulator&quot;: true<br>      }<br>    },<br>    &quot;internal-simulator&quot;: {<br>      &quot;distribution&quot;: &quot;internal&quot;,<br>      &quot;ios&quot;: {<br>        &quot;simulator&quot;: true<br>      }<br>    },<br>    &quot;development-apk&quot;: {<br>      &quot;developmentClient&quot;: true,<br>      &quot;distribution&quot;: &quot;internal&quot;,<br>      &quot;android&quot;: {<br>        &quot;buildType&quot;: &quot;apk&quot;<br>      }<br>    },<br>    &quot;internal-apk&quot;: {<br>      &quot;distribution&quot;: &quot;internal&quot;,<br>      &quot;android&quot;: {<br>        &quot;buildType&quot;: &quot;apk&quot;<br>      }<br>    },<br>    // hidden for brevity<br>  },<br>  &quot;submit&quot;: {<br>    &quot;production&quot;: {}<br>  }<br>}</pre><h4><strong>Local Builds</strong>:</h4><ul><li><strong>iOS</strong>: Uses the <strong>development-simulator</strong> profile, tailored for local testing on iOS simulators.</li><li><strong>Android</strong>: Uses the <strong>development-apk</strong> profile, designed for local testing with Android APKs.</li></ul><p><a href="https://blog.mobile.dev/pokedex-ui-testing-series-getting-started-with-maestro-in-expo-react-native-part-1-73c6dfaa072">Refer to part 1 of the series for local builds use case</a></p><h4><strong>Cloud Builds</strong>:</h4><ul><li><strong>iOS</strong>: Switches to the <strong>internal-simulator</strong> profile, optimized for cloud-based testing on iOS simulators.</li><li><strong>Android</strong>: Adopts the <strong>internal-apk</strong> profile, configured for cloud-based testing with Android APKs.</li></ul><p>In essence, while local builds employ “development” profiles, cloud builds transition to “internal” profiles to cater to their specific environments.</p><h3>Package Configuration and Scripts</h3><p><strong>File:</strong> package.json</p><p>The backbone of our project:</p><pre>{<br>  &quot;name&quot;: &quot;mobile&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;main&quot;: &quot;node_modules/expo/AppEntry.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;eas-build-on-success&quot;: &quot;bash ./scripts/eas-build-on-success.sh&quot;,<br>    // hidden for brevity<br>  },<br>  // hidden for brevity<br>}</pre><p>The eas-build-on-success script triggers our post-build bash script, ensuring Maestro Cloud integration post-build.</p><h3>Maestro — Run when Local</h3><p><strong>File: </strong>.maestro/journey/pokemon-lookup.yaml</p><p>Here, we’ve introduced an optional flow. If you choose to set the TARGET_ENV variable to &#39;local&#39;, Maestro will execute the local-setup.yaml flow.</p><pre>appId: ${APP_ID}<br>---<br>- launchApp:<br>    clearState: true<br><br>- runScript: ../common/init.js<br><br>- runFlow:<br>    when:<br>      true: ${TARGET_ENV == &#39;local&#39;}<br>    file: ../common/local-setup.yaml<br><br># hidden for brevity</pre><p>This allows you to tailor your testing approach based on the environment if desired.</p><p>The local-setup.yaml flow is activated only when TARGET_ENV is set to &#39;local&#39;. This means that when tests are executed on Maestro Cloud, this particular flow is bypassed.</p><p>For local testing, run:</p><pre>maestro test -e TARGET_ENV=local -e APP_ID=com.thekharche.maestroexpopokedex .maestro/journey/pokemon-lookup.yaml</pre><p>Using the above command, the local-setup.yaml flow is included, allowing for a tailored testing experience when running tests locally.</p><h3>The Maestro — Expo EAS Cloud UI test Workflow</h3><p><strong>1.</strong> Every time a developer pushes code to the repository, the automation process begins. <strong>GitHub Actions</strong> immediately sets up a dedicated environment, creating a uniform base for all subsequent tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*36OFMI79srF3fsZ7pEJKPQ@2x.png" /><figcaption>GitHub Actions Workflow</figcaption></figure><p><strong>2. Expo EAS </strong>takes charge, constructing the application for both Android and iOS platforms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9LBu831M19JkrXAxhM34TQ@2x.png" /><figcaption>EAS Builds</figcaption></figure><p><strong>3.</strong> With the builds in place, <strong>Maestro Cloud</strong> conducts UI tests on the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*16udcDXeU7Rax82EE9F8zg@2x.png" /><figcaption>Maestro Cloud UI tests with Screen Recording and Logs</figcaption></figure><h3>Conclusion</h3><p>Taking UI testing to the cloud with Maestro and automating with GitHub Actions ensures a robust, scalable, and efficient testing process. This setup gives us confidence in our Expo React Native apps’ consistent and high-quality user experience.</p><h3>References</h3><p>Thanks to <a href="https://github.com/lingvano/react-native-eas-maestro">https://github.com/lingvano/react-native-eas-maestro</a> for inspiration.</p><p><strong>Expo Dev:</strong></p><p><a href="https://expo.dev/">Expo</a></p><p><strong>Maestro Cloud:</strong></p><p><a href="https://cloud.mobile.dev/">Welcome</a></p><p><strong>Maestro Cloud Console:</strong></p><p><a href="https://console.mobile.dev/">Console | mobile.dev</a></p><p><strong>Part 1 of Pokedex UI Testing Series with Local Setup:</strong></p><p><a href="https://blog.mobile.dev/pokedex-ui-testing-series-getting-started-with-maestro-in-expo-react-native-part-1-73c6dfaa072">Pokedex UI Testing Series: Getting Started with Maestro in Expo &amp; React Native — Part 1</a></p><p><strong>GitHub Source Code:</strong></p><p><a href="https://github.com/thekharche/maestro-expo-pokedex">GitHub - thekharche/maestro-expo-pokedex</a></p><p><strong>EAS Build Lifecyle npm hooks:</strong></p><p><a href="https://docs.expo.dev/build-reference/npm-hooks/">Build lifecycle hooks</a></p><p>🎹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff6257ddd173" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s New in Maestro: 1.32.0]]></title>
            <link>https://medium.com/@thekharche/whats-new-in-maestro-1-32-0-c032a546ad78?source=rss-84a554db6f22------2</link>
            <guid isPermaLink="false">https://medium.com/p/c032a546ad78</guid>
            <category><![CDATA[ui-testing]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[maestros]]></category>
            <dc:creator><![CDATA[Ashish Kharche]]></dc:creator>
            <pubDate>Thu, 07 Sep 2023 01:38:22 GMT</pubDate>
            <atom:updated>2025-01-09T19:39:28.619Z</atom:updated>
            <content:encoded><![CDATA[<h4>AI-powered Flows, New Start Device Command, Browser Control, Polished Maestro Studio and More!</h4><p><em>Looking for the easiest way to test iOS, Android, and Web with a single platform? Check out </em><a href="https://www.robintest.com/"><strong><em>Robin — The new standard in Mobile and Web end-to-end testing</em></strong></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Mm1v5PrB__TyiJ9H3--oQ.png" /><figcaption>Maestro New Release 1.32.0</figcaption></figure><p>We’re excited to present version <strong>1.32.0 </strong>with innovative features and improvements!</p><p><strong>Upgrade to 1.32.0:</strong></p><pre>curl -Ls &quot;https://get.maestro.mobile.dev&quot; | bash</pre><h3>AI-powered Flows in Maestro Studio✨</h3><p>Maestro Studio can now <strong>generate commands with AI </strong>based on user input, screen hierarchy, and the OpenAI token.</p><p>Stay tuned for an in-depth blog on AI-powered flows!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FYSrtidGSdoI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYSrtidGSdoI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FYSrtidGSdoI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8cbdd1de15fba002822e8ce923cde6e4/href">https://medium.com/media/8cbdd1de15fba002822e8ce923cde6e4/href</a></iframe><h3>New Maestro Start Device Command</h3><p>The maestro start-device command allows users to initiate or create an iOS Simulator or Android Emulator that <strong>matches the specifications available on Maestro Cloud</strong>.</p><p><strong>Command Syntax:</strong></p><pre>maestro start-device [--force-create] [--os-version=&lt;osVersion&gt;] --platform=&lt;platform&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bN0etneIzZK6Whbh0hofeg@2x.png" /><figcaption>maestro start-device command</figcaption></figure><p><strong>Example Usage:</strong></p><pre>maestro start-device --platform ios</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8mbC7ceHzUEuhMIoPrp9XQ.png" /><figcaption>This local iOS simulator&#39;s specs match the one on Maestro Cloud</figcaption></figure><p><strong>For iOS</strong>, If you get a message saying:</p><p>Required runtime to create the simulator is not installed: iOS-15-5</p><p>Download the runtime as required. Open Xcode &gt; Settings &gt; Platforms to install the simulator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SLuN1y-u6ryY3dnogixT6Q.png" /><figcaption>Install simulator</figcaption></figure><p>Follow equivalent steps for <strong>Android</strong>, if the informative message pops up on running the command.</p><p>By using the start-device command, users can ensure that their local testing environment aligns with the configurations available on Maestro Cloud, leading to consistent testing results.</p><h3>Device Specs Display for Maestro Cloud Command</h3><p>You can now get detailed specs of the device your app is being tested on in Maestro Cloud, right from the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6vZDjvXOm1dFigp0kD3wzg.png" /><figcaption>Terminal showcasing info regarding device on Maestro Cloud</figcaption></figure><h3>Browser Control with — no-window</h3><p>When you launch Maestro Studio, it automatically opens in your browser for immediate access. However, if you prefer to control this behavior, Maestro offers a straightforward option, thanks to the <a href="https://github.com/mobile-dev-inc/maestro/pull/1358">community contribution by markexin</a></p><pre>maestro studio --no-window</pre><p>--no-window: Use this flag to prevent Maestro Studio from automatically opening in the browser.</p><h3>Copy Text and ID in Maestro Studio</h3><p>The process of accessing element details is streamlined. Now, with a simple selection, users can effortlessly copy both the text and the associated ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eIE56ehm0uR2C6npoGKqQg.png" /><figcaption>Showcasing ID and Text values in Maestro Studio</figcaption></figure><h3>Noteworthy Mentions</h3><ul><li><strong>Community Contributions</strong>: Maestro continues to benefit from the active contributions of its community, especially in areas like <a href="https://github.com/mobile-dev-inc/maestro/pull/1267"><strong>react-native-web integration by adamhari</strong></a><strong> </strong>and <a href="https://github.com/mobile-dev-inc/maestro/pull/1358"><strong>browser control feature by markexin</strong></a>.</li><li><strong>Continuous Integration (CI)</strong>: Enhanced messaging and recovery options have been added for Maestro Cloud uploads, proving particularly beneficial for CI processes.</li><li><strong>Enhanced Feedback</strong>: The CLI now displays cancellation reasons (when available) from Maestro Cloud and showcases the device type during cloud operations.</li><li><strong>Improved Messaging</strong>: Better error messages have been incorporated for missing workspaces, YAML validation errors, and more. Additionally, YAML parsing error messages now include the file name and line number for easier debugging.</li><li><strong>iOS Stability</strong>: Improvements have been made for text input and erase functions on iOS, along with better error handling for the iOS Driver.</li><li><strong>Maestro Cloud &amp; Debugging</strong>: Various fixes related to Maestro Cloud exit codes, debug command parsing, and debug log cleanup have been implemented.</li><li><strong>Polished Maestro Studio</strong>: Unnecessary scrollbars have been removed for a neater appearance, and action buttons remain hidden until a command is hovered, reducing visual clutter and multi-tab functionality in the Studio!</li></ul><h3>Conclusion</h3><p><strong>Version 1.32.0</strong> of Maestro marks a significant stride forward, enhancing the Studio, CLI, and Cloud components. With these quality improvements, the process of creating UI tests becomes more robust and user-friendly.</p><p>Stay Tuned!</p><h3>References</h3><p><strong>Changelog:</strong></p><p><a href="https://github.com/mobile-dev-inc/maestro/blob/main/CHANGELOG.md">https://github.com/mobile-dev-inc/maestro/blob/main/CHANGELOG.md</a></p><p>🎹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c032a546ad78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pokedex UI Testing Series: A Guide to End-to-End React Native Testing with Maestro — Part 2]]></title>
            <link>https://medium.com/@thekharche/pokedex-ui-testing-series-a-guide-to-end-to-end-react-native-testing-with-maestro-part-2-fe3c4d67c994?source=rss-84a554db6f22------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe3c4d67c994</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[maestros]]></category>
            <category><![CDATA[ui-testing]]></category>
            <dc:creator><![CDATA[Ashish Kharche]]></dc:creator>
            <pubDate>Sun, 03 Sep 2023 01:11:13 GMT</pubDate>
            <atom:updated>2025-01-09T19:39:35.962Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pokedex UI Testing Series: A Guide to End-to-End React Native Testing with Maestro — Part 2</h3><h4>Write UI tests for your React Native / Expo Apps</h4><p><em>Looking for the easiest way to test iOS, Android, and Web with a single platform? Check out </em><a href="https://www.robintest.com/"><strong><em>Robin — The new standard in Mobile and Web end-to-end testing</em></strong></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y6P2UwvyGfuANsAd_wDncw.png" /><figcaption>React Native /. Expo Pokedex App UI testing with Maestro</figcaption></figure><p>In the world of application development, testing is crucial to ensure the functionality and usability of the application. Maestro is a tool for UI testing, that supports <strong>testing React Native</strong> (Expo) screens and apps on both Android and iOS platforms. This guide will walk you through the process of performing end-to-end tests for a Pokedex app using Maestro.</p><h3>Prerequisites</h3><p>Before diving into the setup and test writing, make sure you have gone through the first part of this series.</p><p><strong>Read blog</strong>: <a href="https://blog.mobile.dev/pokedex-ui-testing-series-getting-started-with-maestro-in-expo-react-native-part-1-73c6dfaa072">Pokedex UI Testing Series: Getting Started with Maestro in Expo &amp; React Native — Part 1</a></p><p>It covers setting up Expo and running Pokedex locally to follow along.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mHUU4jm3pqmHlvoznHpalQ.png" /><figcaption>Prerequisite</figcaption></figure><h3>Setting Up Your Workspace</h3><p>Before writing a UI test using Maestro, it’s a good idea to configure your workspace. Create a config.yaml file in the .maestro directory with the following contents:</p><pre># config.yaml<br>flows:<br>  - journey/*</pre><p>This configuration instructs Maestro to look for flows in the journey directory. The journey directory will contain the Flow files.</p><h4>Source Code</h4><p>Find the GitHub repo with source code and Maestro UI testing Flow files:</p><p><a href="https://github.com/thekharche/maestro-expo-pokedex">GitHub - thekharche/maestro-expo-pokedex</a></p><h3>Structuring Your Tests</h3><p><strong>Maestro tests are opinionated in structure</strong>, meaning you have the <strong>flexibility</strong> to organize your tests in a way that makes sense for your app. For a detailed guide on structuring your test suite, refer to this <a href="https://blog.mobile.dev/maestro-best-practices-structuring-your-test-suite-54ec390c5c82">Maestro Best Practices</a> blog post.</p><p>In this guide, we will structure our tests by <strong>journey</strong> and <strong>subflow</strong>. Create a journey directory in the .maestro directory. This is where we will write our tests, which will refer to subflows. Subflows can be self-contained meaning they could be run as a Flow individually using maestro testor they could be simply separated into reusable parts of a bigger Flow.</p><h4>Why this structure?</h4><p>Structuring tests by journey and subflow helps in breaking down the tests into smaller, more manageable pieces. Each journey represents a user journey through the application, and each subflow represents a part of that journey. This structure makes it easier to understand, write, and maintain the tests.</p><p>The naming for the files is not enforced. In this blog, we have chosen to use the kebab-case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*oKqeI9OLHTVx3CjljguMbw@2x.png" /><figcaption>Organizing files</figcaption></figure><h3>Open Maestro Studio</h3><p>Maestro Studio is a feature of Maestro, that serves as a personal assistant to help write your Maestro Flows. It is built right into the Maestro CLI and can be launched in your browser by running the maestro studio command. Maestro Studio provides several functionalities:</p><ul><li>Visually Select a UI Element</li><li>Automatically Generated Examples</li><li>Executing Commands in the REPL</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SHdhuhhZdCcB4Yeh-vfOzA@2x.png" /><figcaption>Maestro Studio</figcaption></figure><p>The tests for Pokedex were written using Maestro Studio.</p><p><strong>To open, run on your terminal</strong>:</p><pre>maestro studio</pre><h3>Crafting Your First Test</h3><p>The first step in crafting your test is to outline the entire user journey that you want to test. This journey will include several subflows, each representing a specific part of the user’s interaction with the app.</p><p>Our Pokedex app is relatively simple, so for the purpose of this blog, we will focus on just one journey. However, in a more complex app, there could be multiple journeys, each with its own set of subflows and actions.</p><p>Create a file named pokemon-lookup.yaml in the journey directory. This file will serve as the blueprint for the entire user journey you want to test.</p><pre># pokemon-lookup.yaml<br>appId: ${APP_ID}<br>onFlowStart:<br>  - runFlow: ../common/setup.yaml<br>  - startRecording: recording-pokemon-lookup-journey<br>onFlowComplete:<br>  - stopRecording<br>---<br># Check Region List<br>- runFlow: ../subflow/region-list.yaml<br><br># Check Pokemons in a Region<br>- runFlow: ../subflow/pokemons-in-region.yaml<br><br># Search for a Pokemon<br>- runFlow: ../subflow/search-pokemon.yaml<br><br># Check Pokemon Details<br>- runFlow: ../subflow/pokemon-details.yaml</pre><p><strong>In this test, we have defined several actions and subflows. Let’s break down each section</strong>:</p><ul><li>appId:This is the app id of the app you want to test, which can be found in the app.json file of your app.</li><li>onFlowStart: This is a list of actions to perform before the test starts. In this case, we are running a setup flow and <strong>starting a recording</strong>.</li><li>onFlowComplete: This is a list of actions to perform after the test completes. In this case, we are stopping the recording.</li><li>runFlow: This is a list of subflows to run. In this case, we are running subflows to check the region list, Pokemon in a region, search for a Pokemon, and check Pokemon details.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*JkGfttWlfXC5k5EbLRHjCg@2x.png" /><figcaption>Output on the terminal after running the above journey</figcaption></figure><p>Now that we have defined our test, it’s time to write the subflows.</p><h4>Setup before Test</h4><p>The setup.yaml file is handy for the initial setup of your test. It contains a series of actions and commands that need to be executed before the actual test starts. This file is typically referenced in the onFlowStart section of your journey file, ensuring it is the first thing that runs when your test starts. init.js script initializes the output object that will be used throughout the test, which we will look deeper into further in the blog.</p><pre>appId: ${APP_ID}<br>---<br>- launchApp:<br>    clearState: true<br>- runScript: init.js<br># Expo Development Build Specific<br>- runFlow:<br>    when:<br>      visible: &quot;http://localhost:8081&quot;<br>    commands:<br>      - tapOn: &quot;http://localhost:8081&quot;<br>- runFlow:<br>    when:<br>      visible: &quot;Got It&quot;<br>    commands:<br>      - tapOn: &quot;Got It&quot;<br>- runFlow:<br>    when:<br>      visible: &quot;Toggle performance monitor&quot;<br>    commands:<br>      - swipe:<br>          from:<br>            text: &quot;Toggle performance monitor&quot;<br>          direction: DOWN</pre><p>The setup.yaml file is important for several reasons:</p><ol><li><strong>Initializes the Test Environment</strong>: It ensures that the app is launched and that the test environment is correctly initialized before the actual test starts. This includes running any necessary scripts, tapping on buttons to get past introductory screens (Expo Dev), etc.</li><li><strong>Ensures Consistency</strong>: It ensures that every test starts from the same initial state. This is crucial for the consistency and reliability of your tests.</li><li><strong>Improves Test Maintainability</strong>: Separating the setup actions into a separate file, makes the test easier to understand and maintain. If the setup actions need to be changed, they can be changed in one place without affecting the rest of the test.</li></ol><h4>Why Start a Recording and Take Screenshots?</h4><p>Starting a recording at the beginning of the test and stopping it at the end helps in <strong>capturing the entire test execution</strong>. This is crucial for reviewing the test run and identifying any issues that may occur during the test. It provides a visual record of the actions performed and the responses of the app, making it easier to spot any discrepancies or unexpected behaviors.</p><p>Taking screenshots at specific points in the test helps in <strong>capturing the state of the app</strong> at that moment. It provides a snapshot of the app’s UI, which is useful for verifying that the app is displaying the expected elements and layouts. Screenshots can also serve as a reference for <strong>how the app should look</strong> at different stages of the test.</p><p>Both <strong>recordings and screenshots </strong>are essential for documenting the test results and providing evidence that the test was executed correctly. They are also valuable assets for debugging and resolving any issues that may arise during the test.</p><h3>Creating Your Subflows</h3><p>Subflows are smaller, reusable pieces of a test. Create a subflow directory in the .maestro directory. This is where we will write our subflows.</p><h3>Subflow 1: Checking the Region List</h3><p>This subflow verifies that the user can view the list of regions and interact with them.</p><p>Create a file called region-list.yaml in the subflow directory with the following content:</p><pre># region-list.yaml<br>appId: ${APP_ID}<br>---<br>- assertVisible: &quot;.*Regions.*&quot;<br>- takeScreenshot: &quot;regions&quot;<br>- assertVisible:<br>    id: &quot;name-kanto&quot;<br>- assertVisible:<br>    id: &quot;gen-1&quot;<br>- tapOn:<br>    id: &quot;name-kanto&quot;</pre><p><strong>Actions</strong>:</p><ul><li>Assert that the text “Regions” is visible (we are using regular expressions with .<strong>*</strong>)</li><li>Take a screenshot and save it as “regions.png”.</li><li>Assert that the ID name-kanto is visible.</li><li>Assert that the ID gen-1 is visible.</li><li>Tap on the ID name-kanto region.</li></ul><p><strong>Let’s pause.</strong> You will notice that we are using ID selectors to find elements on the screen. IDs are preferable to text selectors as they help to remove flakiness in your tests if the text changes.</p><h4>Adding IDs to Your React Native App</h4><p>To interact with the elements on the screen accurately, you can add IDs to your React Native app. You can use the testID prop for this purpose. For example:</p><pre>&lt;Text testID=&quot;id-value&quot; className=&quot;font-600 text-lg text-white capitalize&quot;&gt;</pre><p><strong>However</strong> for iOS, if your Text component is nested in a TouchableOpacity component (outer component), you will need to add the accessible={false} prop to the TouchableOpacity component. For example:</p><pre>  return (<br>    &lt;TouchableOpacity<br>      activeOpacity={0.8}<br>      className=&quot;w-full&quot;<br>      onPress={() =&gt; navigate(&quot;list&quot;, { name, gen })}<br>      accessible={false} // ADD accessible={false}<br>    &gt;<br>      &lt;ImageBackground source={imageSource} imageStyle={{ borderRadius: 16 }}&gt;<br>        &lt;LinearGradient&gt;<br>          &lt;View&gt;<br>            &lt;Text testID={`name-${name}`} className=&quot;font-600 text-lg text-white capitalize&quot;&gt;<br>              {name} // ADD testID<br>            &lt;/Text&gt;<br>            &lt;Text testID={`gen-${gen}`} className=&quot;font-500 text-xs text-gray-200 uppercase&quot;&gt;<br>              {gen}ª Generation // ADD testID<br>            &lt;/Text&gt;<br>          &lt;/View&gt;<br>        &lt;/LinearGradient&gt;<br>      &lt;/ImageBackground&gt;<br>    &lt;/TouchableOpacity&gt;<br>  );</pre><p>For more details on interacting with nested components on iOS, refer to the <a href="https://maestro.mobile.dev/platform-support/react-native#interacting-with-nested-components-on-ios">Maestro Platform Support for React Native</a>.</p><h4>ID addition being detected by Maestro</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XzL7jgxkFYS6DsS78Bh10w@2x.png" /><figcaption>testID has been detected by Maestro</figcaption></figure><p>This subflow is the first step in the user journey of looking up a Pokemon. It verifies that the user can see the list of regions and can tap on a specific region. By asserting the visibility of specific elements and interacting with them, we ensure that the app is functioning as expected up to this point.</p><h3>Subflow 2: Checking Pokemons in a Region</h3><p>This subflow verifies that the user can view the list of Pokemons in a selected region and interact with the list by swiping.</p><pre># pokemons-in-region.yaml<br>appId: ${APP_ID}<br>---<br>- assertVisible: &quot;.*Kanto.*&quot;<br>- takeScreenshot: &quot;kanto-region-pokemon-list-1&quot;<br>- assertVisible: &quot;.*Bulbasaur.*&quot;<br>- swipe:<br>    direction: UP<br>    duration: 4000<br>- takeScreenshot: &quot;kanto-region-pokemon-list-2&quot;</pre><p><strong>Actions</strong>:</p><ul><li>Assert that the text “Kanto” is visible.</li><li>Take a screenshot and save it as “kanto-region-pokemon-list-1.png”.</li><li>Assert that the text “Bulbasaur” is visible.</li><li>Swipe up on the screen for 4000 milliseconds.</li><li>Take a screenshot and save it as “kanto-region-pokemon-list-2.png”.</li></ul><h4>Screenshots generated</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uIqzmpZ0qMa1zPML7kQCAA@2x.png" /><figcaption>Two screenshots, before and after swipe</figcaption></figure><h3>Subflow 3: Searching for a Pokemon</h3><p>This subflow verifies that the user can search for a specific Pokemon by inputting text into the search field.</p><pre># search-pokemon.yaml<br>appId: ${APP_ID}<br>---<br>- tapOn:<br>    id: &quot;search-icon&quot;<br>- takeScreenshot: &quot;search-pokemon-blank&quot;<br>- inputText: ${output.pokemon.input}<br>- takeScreenshot: &quot;search-pokemon-${output.pokemon.input}&quot;<br>- runFlow:<br>    when:<br>      platform: Android<br>    commands:<br>      - back<br>- runFlow:<br>    when:<br>      platform: iOS<br>    commands:<br>      - tapOn: &quot;return&quot;<br>- tapOn:<br>    id: &quot;name-${output.pokemon.name}&quot;</pre><p><strong>Actions</strong>:</p><ul><li>Tap on the search icon.</li><li>Take a screenshot and save it as search-pokemon-blank.png.</li><li>Input the text from the output of the previous subflow into the search field.</li><li>Take a screenshot and save it as search-pokemon-${output.pokemon.input}.png.</li><li>Tap on the back button on Android or the return button on iOS.</li><li>Tap on the Pokemon name.</li></ul><p><strong>Let’s pause.</strong> You will notice that we are using output.pokemon.input to get the input text.</p><p>Where does this output come from?</p><h4>Creating a Script File</h4><p>To store output objects that can be <strong>reused</strong> across subflows, you need to create a script file. In the common directory, create a file called init.js.</p><p>Here is the script:</p><pre>// init.js<br>output.pokemon = {<br>    name: &#39;mewtwo&#39;,<br>    input: &#39;mewtw&#39;,<br>}</pre><p><em>This script was executed at the start of Flow in </em><em>setup.yaml if you remember!</em></p><p>In this script, we are creating an output object with a pokemon object that has a name and input property.</p><ul><li>name: &#39;mewtwo&#39;: This is the name of the Pokemon we want to search for.</li><li>input: &#39;mewtw&#39;: This is the input text we want to input into the search field.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*G0V0qWnQW4lxEmgng55gJg@2x.png" /><figcaption>Pokemon name, input being used in the UI testing</figcaption></figure><p>This is one of the good usages of scripts as it allows you to change Pokemon names globally from one place!</p><h3>Subflow 4: Checking Pokemon Details</h3><p>This subflow verifies that the user can view the details of a selected Pokemon.</p><pre># pokemon-details.yaml<br>appId: ${APP_ID}<br>---<br>- assertVisible: &quot;.*${output.pokemon.name}.*&quot;<br>- takeScreenshot: &quot;${output.pokemon.name}-pokemon-details&quot;<br>- assertVisible: &quot;.*Genetic.*&quot;<br>- assertVisible: &quot;.*Psychic.*&quot;<br>- assertVisible: &quot;.*This pokemon does not evolve.*&quot;</pre><p><strong>Actions</strong>:</p><ul><li>Assert that the text of the Pokemon name is visible.</li><li>Take a screenshot and save it as ${output.pokemon.name}-pokemon-details.png.</li><li>Assert that the text “Genetic” is visible.</li><li>Assert that the text “Psychic” is visible.</li><li>Assert that the text “This pokemon does not evolve” is visible.</li></ul><h3>Running Your Test</h3><p>After crafting all the subflows, you can run your test. To do so, run the following command:</p><pre>maestro test -e APP_ID=com.thekharche.maestroexpopokedex .maestro/journey/pokemon-lookup.yaml</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZyug-aDJh3A%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZyug-aDJh3A&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZyug-aDJh3A%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/da8752c4a4e51d3c6111801f24df416c/href">https://medium.com/media/da8752c4a4e51d3c6111801f24df416c/href</a></iframe><h3>Running on CI</h3><p>In the upcoming part, we will look into how to get React Native / Expo UI tests with Maestro running on CI!</p><p>Stay Tuned!</p><h3><strong>Conclusion</strong></h3><p>In this opinionated guide, we walked you through the process of setting up your workspace, structuring your tests, crafting your first test, and creating subflows for a Pokedex app. We also discussed the importance of starting a recording and taking screenshots during the test and how to add IDs to your React Native app to interact with the elements on the screen accurately.</p><p>Adapt the guide to your app testing requirements and happy testing!</p><h3>References</h3><p>Maestro for React Native:</p><p><a href="https://maestro.mobile.dev/platform-support/react-native">React Native</a></p><p>Maestro Best Practices:</p><p><a href="https://blog.mobile.dev/maestro-best-practices-structuring-your-test-suite-54ec390c5c82">Maestro Best Practices: Structuring your Test Suite</a></p><p>Maestro Best Practices for Cross-platform:</p><p><a href="https://blog.mobile.dev/best-practices-for-cross-platform-maestro-ui-testing-for-android-and-ios-98d1c471a838">Best Practices for Cross-platform Maestro UI Testing for Android and iOS</a></p><p>Source Code of App with Maestro Flow files:</p><p><a href="https://github.com/thekharche/maestro-expo-pokedex">GitHub - thekharche/maestro-expo-pokedex</a></p><p>Prerequisite:</p><p><a href="https://blog.mobile.dev/pokedex-ui-testing-series-getting-started-with-maestro-in-expo-react-native-part-1-73c6dfaa072">Pokedex UI Testing Series: Getting Started with Maestro in Expo &amp; React Native — Part 1</a></p><p>🎹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe3c4d67c994" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pokedex UI Testing Series: Getting Started with Maestro in Expo & React Native — Part 1]]></title>
            <link>https://medium.com/@thekharche/pokedex-ui-testing-series-getting-started-with-maestro-in-expo-react-native-part-1-73c6dfaa072?source=rss-84a554db6f22------2</link>
            <guid isPermaLink="false">https://medium.com/p/73c6dfaa072</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ui-testing]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[maestros]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Ashish Kharche]]></dc:creator>
            <pubDate>Sat, 19 Aug 2023 00:46:16 GMT</pubDate>
            <atom:updated>2025-01-09T19:39:47.046Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pokedex UI Testing Series: Getting Started with Maestro in Expo &amp; React Native — Part 1</h3><h4>Setup Expo Development builds for Android &amp; iOS</h4><p><em>Looking for the easiest way to test iOS, Android, and Web with a single platform? Check out </em><a href="https://www.robintest.com/"><strong><em>Robin — The new standard in Mobile and Web end-to-end testing</em></strong></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tpsLvcl3BNn2UJN-26mzJA.png" /><figcaption>Setup Maestro for Expo React Native</figcaption></figure><p><strong>Maestro</strong> is a powerful UI testing framework designed for both Android and iOS applications. In this guide, we’ll walk you through the process of UI testing an <strong>Expo app locally</strong> using Maestro, using the <strong>Pokedex</strong> as our example.</p><p>This is a multi-part series. Upcoming parts revolve around UI testing the real-world Pokedex Expo App.</p><h3>Getting Started</h3><p>1.<strong> Clone the Repository</strong></p><p>Start by cloning the <strong>Maestro Expo Pokedex</strong> repository:</p><pre>git clone https://github.com/thekharche/maestro-expo-pokedex</pre><p>2. <strong>Switch to the “</strong>initial<strong>” Branch</strong></p><p>The “initial” branch contains the initial setup, while the “main” branch has the final code:</p><pre>git checkout initial</pre><p>3. <strong>Installation and Initial Run</strong></p><p>Install the required packages:</p><pre>npm install</pre><p>Start the Expo app:</p><pre>npm start</pre><p>This command runs the expo start script. To select the Android platform, press a and for iOS, press i. If you want to choose a specific device, use shift + a or shift + i.</p><p>At this point, you should see the app compiling. Once compiled, it will install Expo Go and run the app inside it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*kSeQzWQywKHeO1DZb-D2Aw.png" /><figcaption>iOS App in Expo Go</figcaption></figure><h3>EAS &amp; Expo Setup</h3><p>1. <strong>Install and Configure EAS CLI</strong></p><p>EAS (Expo Application Services) CLI is a tool that helps in <strong>building</strong> and submitting apps to stores. Install it globally:</p><pre>npm install --global eas-cli</pre><p>2. <strong>Login to EAS:</strong></p><pre>eas login</pre><p>3. <strong>Configure the build:</strong></p><pre>eas build:configure</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xiD4l1I8w0RzUx8uSNVrtQ.png" /><figcaption>Configure eas build</figcaption></figure><p>When prompted, choose All platforms. This will generate a eas.json file and add the EAS settings to app.json.</p><p>4. <strong>Install the Expo Dev Client</strong></p><pre>npx expo install expo-dev-client</pre><h3>Android Setup</h3><p>1. <strong>Modify the </strong><strong>eas.json for Android</strong></p><p>Add the Android-specific configurations:</p><pre>&quot;development-apk&quot;: {<br>    &quot;developmentClient&quot;: true,<br>    &quot;distribution&quot;: &quot;internal&quot;,<br>    &quot;android&quot;: {<br>        &quot;buildType&quot;: &quot;apk&quot;<br>    }<br>}</pre><p>2. <strong>Build for Android</strong></p><pre>eas build --platform android --profile development-apk --local</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HizWIQdUl2aLakqBCLlOlA.png" /><figcaption>Build locally for Android</figcaption></figure><p>Once the build is successful, an <strong>APK</strong> will be generated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VBdQnam6P2s058UJOGdAqQ.png" /><figcaption>APK file generated</figcaption></figure><p>3. <strong>Install on Android Emulator</strong></p><p>Install this APK onto your emulator:</p><pre>adb install build-*.apk</pre><p>Alternatively, you can drag and drop the APK onto the emulator.</p><h3>iOS Setup</h3><p>1. <strong>Modify the </strong><strong>eas.json for iOS</strong></p><p>Add the iOS-specific configurations:</p><pre>&quot;development-simulator&quot;: {<br>    &quot;developmentClient&quot;: true,<br>    &quot;distribution&quot;: &quot;internal&quot;,<br>    &quot;ios&quot;: {<br>        &quot;simulator&quot;: true<br>    }<br>}</pre><p>2. <strong>Build for iOS</strong></p><pre>eas build --platform ios --profile development-simulator --local</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qaGpLO7CFw7szcXJj7GHdQ.png" /><figcaption>Build locally for iOS</figcaption></figure><p>Provide your bundle identifier when prompted. After the build, a tar file containing the .app will be generated.</p><p>3. <strong>Install on iOS Simulator</strong></p><p>Extract the tar file:</p><pre>tar -xvzf build-*.tar.gz</pre><p>Install the app on the simulator:</p><pre>xcrun simctl install booted maestroexpopokedex.app/</pre><h3>Start Local Development Server</h3><p>After the successful installation of apps for Android and iOS, start the server:</p><pre>npx expo start --dev-client</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lt25KmLK5_8dHJzrzLgIcQ.png" /><figcaption>Running Expo Development Build Locally</figcaption></figure><h3>Sample Maestro UI Test</h3><p>Just as a check, let’s create a simple Maestro Flow. This is to verify our setup worked as expected.</p><p>1. <strong>Setting up the Test</strong></p><p>Create a flow.yaml file in the .maestro directory at the root of your project. Add the following content:</p><pre>appId: ${APP_ID}<br>---<br>- launchApp</pre><p>2. <strong>Run the Test</strong></p><p><strong>For Android:</strong></p><p>Get the device ID using:</p><pre>adb devices</pre><p>Execute the Test:</p><pre>maestro --device emulator-5554 test -e APP_ID=com.thekharche.maestroexpopokedex .maestro/flow.yaml</pre><p>You should see the app launching.</p><p><strong>For iOS:</strong></p><p>Get the device ID using:</p><pre>xcrun simctl list devices booted</pre><p>Execute the Test:</p><pre>maestro --device 68D1CA28-* test -e APP_ID=com.thekharche.maestroexpopokedex .maestro/flow.yaml</pre><h3>Why UI Test Outside of Expo Go?</h3><p>When it comes to UI testing, especially in a <strong>local development environment</strong>, there are several reasons why you might want to run your app outside of Expo Go, even while leveraging the benefits of Expo:</p><p><strong>Full Control Over the App:</strong></p><p>Running your app outside of Expo Go gives you more granular control over its behavior, configurations, and interactions. This is crucial for UI testing, where you might want to <strong>simulate specific scenarios and manipulate app states</strong>.</p><p><strong>Isolation:</strong></p><p>Testing outside of Expo Go ensures that your app is isolated from any potential quirks or behaviors specific to Expo Go. This means your tests are <strong>solely focused</strong> on your app’s code and not influenced by any external factors.</p><p><strong>Leveraging Expo Benefits:</strong></p><p>Even while running outside of Expo Go, you still <strong>maintain all the benefits</strong> of Expo, such as its development environment, libraries, and tools. This means you get the best of both worlds: the flexibility and control of a standalone app and the ease and functionality of Expo.</p><h3>Stay Tuned</h3><p>The next part of the series will delve into UI testing a real-world Expo React Native app.</p><h3>References</h3><p><strong>Maestro Expo:</strong></p><p><a href="https://blog.mobile.dev/running-maestro-ui-tests-in-an-expo-development-builds-1ca443ab2a30">Running Maestro UI Tests in an Expo Development Build for iOS</a></p><p><strong>Source Code GitHub repo:</strong></p><p><a href="https://github.com/thekharche/maestro-expo-pokedex">GitHub - thekharche/maestro-expo-pokedex</a></p><p><strong>Maestro:</strong></p><p><a href="https://maestro.mobile.dev/">What is Maestro? | Maestro by mobile.dev</a></p><p><strong>EAS (Expo):</strong></p><p><a href="https://expo.dev/eas">Expo Application Services (EAS)</a></p><p>🎹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73c6dfaa072" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s New in Maestro: 1.31.0]]></title>
            <link>https://medium.com/@thekharche/whats-new-in-maestro-1-31-0-6715d2f5397e?source=rss-84a554db6f22------2</link>
            <guid isPermaLink="false">https://medium.com/p/6715d2f5397e</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ui-testing]]></category>
            <category><![CDATA[maestros]]></category>
            <category><![CDATA[e2e-testing]]></category>
            <dc:creator><![CDATA[Ashish Kharche]]></dc:creator>
            <pubDate>Thu, 10 Aug 2023 22:56:07 GMT</pubDate>
            <atom:updated>2025-01-09T19:39:54.383Z</atom:updated>
            <content:encoded><![CDATA[<h4>HTTP Headers, Debug Paths, Keyboard Accessibility, Essential Fixes and More!</h4><p><em>Looking for the easiest way to test iOS, Android, and Web with a single platform? Check out </em><a href="https://www.robintest.com/"><strong><em>Robin — The new standard in Mobile and Web end-to-end testing</em></strong></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oG55KPdunNm9O0LVSUZCjg.png" /><figcaption>Maestro New Release 1.31.0</figcaption></figure><p>We’re thrilled to announce a series of updates, improvements, and fixes that we’ve recently implemented in Maestro CLI, Studio and Cloud!</p><p>Maestro aims to simplify UI testing for mobile apps, making it faster and more efficient. With the<strong> release of version 1.31.0</strong>, Maestro continues to evolve!</p><p><strong>Upgrade to 1.31.0:</strong></p><pre>curl -Ls &quot;https://get.maestro.mobile.dev&quot; | bash</pre><h3>New in Maestro</h3><h4>HTTP Response Headers in API Calls</h4><p>An open-source contribution from Jesse Willoughby allows users to access headers from HTTP responses made with Maestro. This feature was introduced to cater to use cases where the headers returned on response are useful. The underlying <strong>OkHttpClient</strong> makes this addition seamless, enabling scripts to retrieve headers effortlessly.</p><p><strong>For instance, a script can now execute:</strong></p><pre>const response = http.get(&quot;https://api.tvmaze.com/singlesearch/shows?q=girls&quot;);<br>console.log(JSON.stringify(response.headers, null, 2));</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*I0HBAU8s_LoCnI7A-tccog@2x.png" /><figcaption>Console log response headers</figcaption></figure><p>In the above <strong>script.js</strong>, if you want to log the entire headers object, you can use JSON.stringify() to convert the <strong>headers</strong> object into a string. The null and 2 parameters in JSON.stringify() are used to format the output with two spaces of indentation for better readability.</p><p>So now the response returns ok, status, body and headers. With <strong>headers</strong> being the newest addition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*mk__MniCiQ3yycUHl7klsg@2x.png" /><figcaption>Console log all response</figcaption></figure><h4>Configurable Debug Output Path</h4><p>Users can now specify a path for debugging information using the --debug-output option. By default, Maestro dumps this information in the user directory.</p><pre> maestro test --debug-output path/to/custom/debug-output-directory .maestro/flow.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*YeB7bSnoKG9UNbZPSLeM5Q@2x.png" /><figcaption>Set custom debug output directory</figcaption></figure><h4>Enhanced Keyboard Accessibility &amp; Previews in Maestro Studio</h4><p>Maestro Studio now supports <strong>keyboard</strong> <strong>navigation</strong>, making it easier for users to copy, run, and edit commands using their keyboards.</p><p>When selecting elements in Maestro Studio, users will now see <strong>screenshots</strong> of those elements alongside their corresponding commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VBgDoE13pgwcTRHEjOjQ_g@2x.png" /><figcaption>Keyboard shortcuts + Preview in Maestro Studio</figcaption></figure><h3>Changes in Maestro</h3><ul><li><strong>Hooks Behavior:</strong> If any of the onFlowStart or onFlowComplete hooks fail, the test will now be marked as failed.</li><li><strong>Removal of IDB on iOS:</strong> This change might affect the performance of certain Maestro commands, especially on iOS screens with large view hierarchies. However, both the Studio and CLI will provide insights and warnings if the hierarchy becomes too extensive.</li><li><strong>Command Execution with Double-Click in Maestro Studio:</strong> Users can now execute commands in Maestro Studio by double-clicking on them.</li></ul><h3>Fixes in Maestro</h3><p>While the focus of this update is primarily on the new features and changes, it’s worth noting that several fixes have been implemented to improve stability and performance. These include:</p><ul><li>Addressing issues with <strong>OkHttp</strong> warnings related to leaking response bodies.</li><li>Improvements for <strong>scrolling</strong> in React Native apps on iOS.</li><li>Fixes related to <strong>input text</strong> characters on iOS.</li><li>Addressing crashes in debug output generation with Maestro flow contains “/”</li><li>Enhancements for <strong>accurate device interaction</strong> in Maestro Studio.</li><li>Resolving <strong>window resizing issues</strong> in Maestro Studio.</li></ul><p><strong>For more details:</strong> <a href="https://github.com/mobile-dev-inc/maestro/blob/main/CHANGELOG.md">https://github.com/mobile-dev-inc/maestro/blob/main/CHANGELOG.md</a></p><h3>Conclusion</h3><p><strong>Version 1.31.0</strong> of Maestro brings a mix of exciting features, essential changes, and crucial fixes. And … paving the path to iOS physical device support. Stay tuned!</p><h3>References</h3><p><strong>Changelog:</strong></p><p><a href="https://github.com/mobile-dev-inc/maestro/blob/main/CHANGELOG.md">https://github.com/mobile-dev-inc/maestro/blob/main/CHANGELOG.md</a></p><p>🎹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6715d2f5397e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UI Testing Firefox Focus iOS App with Maestro: A Real-World Example]]></title>
            <link>https://medium.com/@thekharche/ui-testing-firefox-focus-ios-app-with-maestro-a-real-world-example-5fc54cf34185?source=rss-84a554db6f22------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fc54cf34185</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[firefox]]></category>
            <category><![CDATA[maestros]]></category>
            <category><![CDATA[ui-testing]]></category>
            <dc:creator><![CDATA[Ashish Kharche]]></dc:creator>
            <pubDate>Wed, 26 Jul 2023 02:08:40 GMT</pubDate>
            <atom:updated>2025-01-09T19:40:00.635Z</atom:updated>
            <content:encoded><![CDATA[<h4>UI Testing Firefox with Maestro</h4><p><em>Looking for the easiest way to test iOS, Android, and Web with a single platform? Check out </em><a href="https://www.robintest.com/"><strong><em>Robin — The new standard in Mobile and Web end-to-end testing</em></strong></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zfWjphGWjRR157NKjkR_WA.png" /><figcaption>UI Testing a Firefox Focus iOS App with Maestro</figcaption></figure><p><strong>Firefox Focus</strong> is a privacy-centric browser app for iOS that offers ad-blocking and tracker-blocking features. In this blog post, we will explore how to perform UI testing on Firefox Focus using <strong>Maestro</strong>, a powerful mobile UI testing framework.</p><p>The guide presents <strong>ideas</strong> to UI test a Firefox Focus iOS app.</p><h3>Introduction to Maestro</h3><p>Maestro is a mobile UI testing framework that stands out for its simplicity and effectiveness. It allows you to easily define and test your Flows.</p><p><strong>Maestro is also designed for fast iteration.</strong></p><p>You can find more about Maestro and its capabilities on its <a href="https://maestro.mobile.dev/">official website</a>.</p><h3>Installing Firefox Focus for iOS</h3><p>To install Firefox Focus, clone the GitHub repository and pull in the project dependencies:</p><pre>git clone https://github.com/mozilla-mobile/focus-ios<br>cd focus-ios<br>./checkout.sh</pre><p>Then, open Blockzilla.xcodeproj in Xcode and build the <strong>Focus</strong> scheme.</p><h3>The Aim of this Tutorial</h3><p>Before proceeding, the goal of this tutorial is to provide a solid starting point for testing your app with Maestro using a real-world app as an example. We’ll explore how to reuse flows, run flows before and after the main flow, take screenshots, record interactions, and use commands like scrollUntilVisible and repeat and more!</p><p><strong>Some key features to look out for in this tutorial:</strong></p><ul><li>Simple YAML-based syntax to define Flows</li><li>Powerful built-in commands like tapOn, inputText, assertVisible etc</li><li>Reusable flows and subflows</li><li>Ability to setup and teardown flows</li><li>Screenshots, videos and reporting.</li></ul><h3>Setting Up Maestro</h3><p>To install Maestro, follow the instructions provided in the <a href="https://maestro.mobile.dev/getting-started/installing-maestro">official guide</a>. The installation can be done with a simple command:</p><pre>curl -Ls &quot;https://get.maestro.mobile.dev&quot; | bash</pre><p>Once Maestro is installed, create a .maestro directory in the root of your project:</p><pre>mkdir .maestro</pre><p>Next, create a config.yaml file in the .maestro directory. This file will contain the configuration for your tests. You can learn more about the <strong>Workspace configuration</strong> in the <a href="https://maestro.mobile.dev/api-reference/configuration">official documentation</a>.</p><h3>Running the App</h3><p>Switch the scheme to <strong>Focus</strong> and run the app in the simulator. Firefox Focus should open in the simulator. For this tutorial, we will focus on testing the <strong>search</strong> functionality and <strong>privacy protection</strong> features of the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zbXk5HDv3rg28MifjL5Vyw@2x.png" /><figcaption>Running the Firefox Focus app in iOS Simulator — Xcode</figcaption></figure><h3>Maestro Studio</h3><p><strong>Maestro Studio</strong> is the preferred way to identify elements, filter through, interact with them using commands and rapidly write UI tests.</p><p>The YAML flows presented below were constructed using Maestro Studio.</p><p>Open up Maestro Studio using:</p><pre>maestro studio</pre><p>Learn more about Maestro Studio in the <a href="https://maestro.mobile.dev/getting-started/maestro-studio">official documentation</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BcHn90uigRvfv27Zcg69Fg@2x.png" /><figcaption>Maestro Studio for Firefox Focus</figcaption></figure><h3>Writing Your First Flow with Maestro</h3><p>A <strong>Flow</strong> in Maestro is a sequence of user actions and assertions that you want to test. It is defined in a YAML file. Let’s create our first Flow to test the search feature in a scenario where the user has just downloaded the app and performed their first search.</p><p>The Maestro Flow Files along with cloned Firefox Focus code: <a href="https://github.com/thekharche/maestro-ios-firefox-focus">https://github.com/thekharche/maestro-ios-firefox-focus</a></p><p>Create a new folder called searchin the .maestro directory and inside it create a file called FirstSearch.yaml.</p><p>Update the config.yaml file to include the <strong>search</strong> Flows:</p><pre># config.yaml<br>flows:<br>  - search/*</pre><p>This will ensure only the Flows in search directory will be included. More on inclusion patterns in the <a href="https://maestro.mobile.dev/api-reference/configuration/workspace-configuration">official documentation</a>.</p><h3>Testing the Search Feature — First Search</h3><p>The <strong>search feature</strong> is a crucial part of any browser app. Here is an example of a test Flow for the search feature:</p><pre># FirstSearch.yaml<br>appId: org.mozilla.ios.Focus<br>name: First Search<br>---<br>- launchApp:<br>    clearState: true<br>- runFlow: ../common/Onboarding.yaml<br>- inputText: &quot;Maestro Studio by Mobile.dev&quot;<br>- assertVisible: &quot;.*Show Search Suggestions.*&quot;<br>- tapOn: &quot;Yes&quot;<br>- pressKey: enter<br>- runFlow: ../common/GoogleConsent.yaml<br>- assertVisible: &quot;.*Maestro.*&quot;</pre><p>In this FirstSearch.yaml Flow, we simulate how a user will search for something for the first time. The Flow includes launching the app, running the onboarding Flow, inputting text, asserting visibility of elements, tapping on elements, pressing keys, and running other Flows.</p><p>You will notice we have used the subflows stored in the common directory. Let’s have a look.</p><h3>Common Flows</h3><p>Common Flows, in our code, are reusable Flows that can be used in multiple tests. They are typically placed in a common directory. In our case, we have two common Flows: Onboarding.yaml and GoogleConsent.yaml.</p><p>This Flow handles the <strong>onboarding</strong> process of the app.</p><pre># Onboarding.yaml<br>appId: org.mozilla.ios.Focus<br>---<br>- runFlow:<br>    when:<br>      visible: &quot;.*Welcome.*&quot;<br>    commands:<br>      - tapOn: &quot;.*Get Started.*&quot;<br>- tapOn: &quot;Skip&quot;<br>- assertVisible: &quot;.*Start your private browsing session.*&quot;<br>- tapOn: &quot;icon close&quot;</pre><p>This Flow handles the <strong>Google consent</strong> process for googling.</p><pre># GoogleConsent.yaml<br>appId: org.mozilla.ios.Focus<br>---<br>- takeScreenshot: GoogleConsent<br>- repeat:<br>    while:<br>      visible: &quot;icon close&quot;<br>    commands:<br>      - tapOn: &quot;icon close&quot;<br>- assertVisible: &quot;.*Before you continue to Google.*&quot;<br>- repeat:<br>    times: 2<br>    commands:<br>      - tapOn: &quot;.*Read more.*&quot;<br>- tapOn: &quot;Reject all&quot;<br>- assertVisible: &quot;Google&quot;</pre><p>The <strong>repeat</strong> command is a powerful command that allows you to repeat a set of commands until a condition is met.</p><p>For example, in the GoogleConsent.yaml Flow, we repeat the tapOn command until the “icon close” is no longer visible.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FmMW5skvAxCc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DmMW5skvAxCc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FmMW5skvAxCc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f0f01a4c4fa3a42c97c396a9d548f51/href">https://medium.com/media/0f0f01a4c4fa3a42c97c396a9d548f51/href</a></iframe><h3>Testing the Search Feature — Changing Search Engine</h3><p>In this test, we will change the search engine to <strong>DuckDuckGo</strong> and perform a search.</p><pre># ChangeSearchEngine.yaml<br>appId: org.mozilla.ios.Focus<br>name: Change Search Engine<br>---<br>- launchApp:<br>    clearState: true<br>- runFlow: ../common/Onboarding.yaml<br>- tapOn:<br>    id: &quot;HomeView.settingsButton&quot;<br>- tapOn: &quot;Settings&quot;<br>- scrollUntilVisible:<br>    element: &quot;Search Engine&quot; <br>    direction: DOWN<br>- tapOn: &quot;Search Engine&quot;<br>- tapOn: &quot;DuckDuckGo&quot;<br>- tapOn:<br>    id: &quot;SettingsViewController.doneButton&quot;<br>- inputText: &quot;Maestro Studio&quot;<br>- pressKey: enter<br>- assertVisible: &quot;duckduckgo.com&quot;<br>- assertVisible: &quot;.*mobile.dev.*&quot;</pre><p>Most of the Flow should be self-explanatory. The only new command is the <strong>scrollUntilVisible</strong> command.</p><p>This command allows you to scroll until an element is visible.</p><p>If you are unsure of how id is assigned in iOS for a UI element in Flows, have a read about it in the <a href="https://maestro.mobile.dev/platform-support/ios-swiftui">official documentation</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FExKRY4N2aVY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DExKRY4N2aVY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FExKRY4N2aVY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/392c518d7aca92fa68a51461b3bde8e0/href">https://medium.com/media/392c518d7aca92fa68a51461b3bde8e0/href</a></iframe><h3>Testing the Search Feature — Deleting Search History</h3><p>In this test, we will delete the search history.</p><pre># DeleteSearchHistory.yaml<br>appId: org.mozilla.ios.Focus<br>name: Delete Search History<br>---<br>- runFlow: ../search/FirstSearch.yaml<br>- tapOn:<br>    id: &quot;URLBar.deleteButton&quot;<br>- assertVisible: &quot;.*Browsing history cleared.*&quot;</pre><p>In this Flow, we reuse the FirstSearch.yaml Flow and then delete the search history and assert that the history was cleared.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FO37cYO2KjuQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DO37cYO2KjuQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FO37cYO2KjuQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/02262679c36e97f804cbbd15400a2342/href">https://medium.com/media/02262679c36e97f804cbbd15400a2342/href</a></iframe><h3>Running the Search Test Suite</h3><p>To run all the search tests, run the following command:</p><pre>maestro test .maestro/search</pre><h3>Testing the Privacy Protection Feature</h3><p>Create a new folder called “protection” in the .maestro directory and inside it create a file called DisableTrackingProtection.yaml to test the toggle for disabling tracking protection.</p><pre># DisableTrackingProtection.yaml<br>appId: org.mozilla.ios.Focus<br>name: Disable Tracking Protection<br>onFlowStart:<br>    - runFlow: <br>        file: ../common/Setup.yaml<br>        env:<br>            NAME: &quot;disable-tracking-protection&quot;<br>onFlowComplete:<br>    - runFlow: <br>        file: ../common/Teardown.yaml<br>        env:<br>            NAME: &quot;disable-tracking-protection&quot;<br>---<br>- runFlow: ../common/Onboarding.yaml<br>- tapOn: &quot;icon cancel&quot;<br>- tapOn: &quot;tracking protection&quot;<br>- assertVisible: &quot;TRACKERS AND SCRIPTS TO BLOCK&quot;<br>- tapOn:<br>    id: &quot;BlockerToggle.TrackingProtection&quot;<br>- assertVisible: &quot;Protections are OFF for this session&quot;<br>- assertNotVisible: &quot;TRACKERS AND SCRIPTS TO BLOCK&quot;<br>- tapOn:<br>    id: &quot;BlockerToggle.TrackingProtection&quot;<br>- assertVisible: &quot;Protections are ON for this session&quot;</pre><p>Update the config.yaml file to include the protection Flows:</p><pre># config.yaml<br>flows:<br>  - search/*<br>  - protection/*</pre><p>The onFlowStart and onFlowComplete commands are special hooks that allow us to run a flow before and after the main flow. This is particularly useful for setting up and tearing down stuff. In this case, we run the Setup.yaml flow before the main flow and the Teardown.yaml flow after the main flow. The NAME the environment variable is passed to these flows to customize their behavior based on the current test. Learn more about environment variables in the <a href="https://maestro.mobile.dev/api-reference/commands/runflow#arguments">official documentation</a>.</p><pre># Setup.yaml<br>appId: org.mozilla.ios.Focus<br>---<br>- launchApp:<br>    clearState: true<br>- waitForAnimationToEnd<br>- takeScreenshot: screenshot-setup-${NAME}<br>- startRecording: recording-setup-${NAME}</pre><p>Suppose, the requirement is to <strong>take screenshots</strong> before and after the test as well as the <strong>recordings</strong>. Let’s do that:</p><p>The Setup.yaml flow is responsible for launching the app, waiting for the animation to end, taking a screenshot, and starting a recording. This sets up a clean state for each test and <strong>allows us to visually inspect the state of the app at the start of the test</strong>.</p><p>Why waitForAnimationToEnd?</p><blockquote>Waits until an ongoing animation/video is fully finished and screen becomes static.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8GB9Oa3jty_8CVjkhlHHvA.png" /><figcaption>waitForAnimationToEnd - usage scenario</figcaption></figure><pre># Teardown.yaml<br>appId: org.mozilla.ios.Focus<br>---<br>- takeScreenshot: screenshot-teardown-${NAME}<br>- stopRecording</pre><p>The Teardown.yaml flow takes a screenshot and stops the recording. This allows us to visually inspect the state of the app at the end of the test and to review the actions performed during the test.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FMk5OvRO2re4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DMk5OvRO2re4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FMk5OvRO2re4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8f77cc265fe0dc49d8d33c240a5ad25/href">https://medium.com/media/e8f77cc265fe0dc49d8d33c240a5ad25/href</a></iframe><h3>Running the Protection Test Suite</h3><p>To run all the protection tests, run the following command:</p><pre>maestro test .maestro/protection</pre><h3>Running the Entire Test Suite</h3><p>To run all the tests, run the following command:</p><pre>maestro test .maestro</pre><h3>Running Individual Tests</h3><p>To run an individual test, run the following command:</p><pre>maestro test .maestro/path/to/flow.yaml</pre><h3>Conclusion</h3><p>In this tutorial, we’ve seen how to use Maestro to conduct UI testing on the Firefox Focus app. We’ve learned how to set up Maestro, define and run Flows, and test various features of the app.</p><p>There are quite a number of ways you could improve the above basic UI testing setup. Please explore the various features <a href="https://maestro.mobile.dev/">Maestro</a>, <a href="https://maestro.mobile.dev/getting-started/maestro-studio">Maestro Studio</a> and <a href="https://cloud.mobile.dev/">Maestro Cloud</a> offers.</p><p><strong>Some Best Practices:</strong></p><ul><li><a href="https://blog.mobile.dev/maestro-best-practices-structuring-your-test-suite-54ec390c5c82">Maestro Best Practices: Structuring your Test Suite</a></li><li><a href="https://blog.mobile.dev/best-practices-for-cross-platform-maestro-ui-testing-for-android-and-ios-98d1c471a838">Best Practices for Cross-platform Maestro UI Testing for Android and iOS</a></li></ul><p>Use some of the ideas presented above for your own app, bend them to your needs and be flexible!</p><h3>References</h3><p>Firefox Focus iOS App:</p><p><a href="https://github.com/mozilla-mobile/focus-ios">GitHub - mozilla-mobile/focus-ios: Firefox Focus for iOS</a></p><p>Maestro:</p><p><a href="https://maestro.mobile.dev/">What is Maestro? | Maestro by mobile.dev</a></p><p>Maestro Flow Files with Source Code:</p><p><a href="https://github.com/thekharche/maestro-ios-firefox-focus">GitHub - thekharche/maestro-ios-firefox-focus: UI Testing a Firefox Focus iOS App with Maestro</a></p><p>🎹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fc54cf34185" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide to Maestro UI Testing with API Mocking Using WireMock]]></title>
            <link>https://medium.com/@thekharche/guide-to-maestro-ui-testing-with-api-mocking-using-wiremock-53eb333da700?source=rss-84a554db6f22------2</link>
            <guid isPermaLink="false">https://medium.com/p/53eb333da700</guid>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[ui-testing]]></category>
            <category><![CDATA[wiremock]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[maestros]]></category>
            <dc:creator><![CDATA[Ashish Kharche]]></dc:creator>
            <pubDate>Mon, 19 Jun 2023 02:40:52 GMT</pubDate>
            <atom:updated>2025-01-09T19:40:07.940Z</atom:updated>
            <content:encoded><![CDATA[<h4>Mock with WireMock, UI test with Maestro</h4><p><em>Looking for the easiest way to test iOS, Android, and Web with a single platform? Check out </em><a href="https://www.robintest.com/"><strong><em>Robin — The new standard in Mobile and Web end-to-end testing</em></strong></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yab6tGwTrY04LmDeHLb1nA.png" /></figure><p>Developing and testing applications that interact with your APIs can present a unique set of challenges. These can include inconsistent responses from the backend, dependencies between teams, and the unavailability of APIs during testing phases. These obstacles can slow down the development process and make testing less efficient. One solution to these issues is <strong>API mocking</strong>, a technique that can expedite development and enhance the flexibility of testing.</p><p>In this article, we will delve into the optimization of <strong>Maestro UI testing through the use of mock APIs with </strong><a href="https://wiremock.org/"><strong>WireMock</strong></a>. We will provide a comprehensive, step-by-step guide to this process.</p><p><strong>WireMock seamlessly integrates with both Maestro CLI and Cloud.</strong> In this blog, we show the setup of WireMock locally as well as WireMock Cloud!</p><h3>A Brief Overview of WireMock</h3><p><strong>WireMock</strong> is used for stubbing and mocking web services. It works by creating an actual HTTP server that your code under test can connect to as it would a real web service. It supports HTTP response stubbing, request verification, proxy/intercept, record/playback of stubs and fault injection.</p><p><strong>WireMock offers several key advantages</strong>:</p><ol><li><strong>Faster Development:</strong> WireMock makes it easier to create, modify, and manipulate API responses during the development process, drastically reducing the time spent handling real API interactions.</li><li><strong>Isolated Testing:</strong> By simulating various API responses and error scenarios, developers can effectively test the app’s behavior without affecting the live API. This isolation allows for more comprehensive testing, ensuring that the app behaves correctly under different conditions.</li><li><strong>Selective Mocking:</strong> WireMock’s Proxy mode enables developers to mock specific endpoints while keeping the rest of the app’s interactions with the live API unchanged. This flexibility permits fine-grained control over the testing process, allowing developers to focus on specific app components.</li><li><strong>WireMock Cloud:</strong> WireMock Cloud offers a secure HTTPS URL, making it easy to use the mock API from anywhere.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*Fy5h5bXQrdn0xwn70g4RNw@2x.png" /><figcaption>WireMock Home Page</figcaption></figure><p>In this guide, we’ll look at two ways to create mocks:</p><ol><li><strong>Locally</strong></li><li><strong>Web UI with WireMock Cloud</strong></li></ol><p>We suggest using <strong>Web UI with WireMock Cloud</strong> because it’s easy and efficient. But, it’s also good to know how the fundamental JSON code works and how to use Wiremock locally. So we dive into how to use WireMock Locally first and then move on to using WireMock Cloud Web UI!</p><p><strong><em>Let’s get started!</em></strong></p><h3>Setting Up WireMock Locally</h3><p>Install the <a href="https://wiremock.org/docs/standalone/java-jar/"><strong>WireMock standalone server</strong></a>. Place the downloaded jar in your workspace.</p><p>For this demonstration, we will use an Android app that connects to The Movie Database (TMDB) API. Note that the principles explained in this post apply to any frontend, including Android, iOS, and the web.</p><p>You can optionally set up an Android app to try out! Or just follow the instructions and implement them for your own app!</p><p><strong>App Source Code: </strong><a href="https://github.com/thekharche/maestro-wiremock-tmdb">https://github.com/thekharche/maestro-wiremock-tmdb</a></p><p>App with different states <strong>(data, error, loading)</strong> made possible with Mock APIs:</p><figure><img alt="1*hUIRyVRJQ-mwEAzlyNcUHw.png (828×1788)" src="https://cdn-images-1.medium.com/proxy/1*hUIRyVRJQ-mwEAzlyNcUHw.png" /><figcaption>TMDB Android App running on Mock APIs</figcaption></figure><h3>Creating Your First Mock Endpoint</h3><p>To get started with WireMock, follow these steps:</p><p>1.<strong> Start the WireMock server</strong> by running the following command in your terminal:</p><pre>java -jar wiremock.jar</pre><p>This will create __files and mappings in your workspace.</p><p>2. <strong>Create a new mapping</strong> in WireMock by creating a new JSON file in the mappings directory. Name it root.json and add the following content:</p><pre>{<br>  &quot;request&quot;: {<br>    &quot;method&quot;: &quot;GET&quot;,<br>    &quot;url&quot;: &quot;/&quot;<br>  },<br>  &quot;response&quot;: {<br>    &quot;status&quot;: 200,<br>    &quot;body&quot;: &quot;Welcome to Maestro Blog!&quot;<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*dKN5JIQvP8nHky9WSnTRZQ@2x.png" /><figcaption>mappings in WireMock</figcaption></figure><p>3. Visit <a href="http://localhost:8080/"><strong>http://localhost:8080/</strong></a><strong> </strong>in your browser to see the response: “Welcome to Maestro Blog!”</p><p><strong>You have just mocked your first endpoint!</strong></p><p>Restart your server (ctrl + c) and java -jar wiremock.jar for changing to take into effect.</p><h3>Enhancing the Mocked Endpoint</h3><p><strong>1.</strong> Update the JSON body in the “root.json” file to <strong>replicate</strong> the actual response when visiting <a href="https://api.themoviedb.org/3/"><strong>https://api.themoviedb.org/3/</strong>.</a></p><p><a href="https://github.com/thekharche/maestro-wiremock-tmdb/blob/main/wiremock/mappings/root.json"><strong>root.json</strong></a></p><pre>{<br>  &quot;request&quot;: {<br>    &quot;method&quot;: &quot;GET&quot;,<br>    &quot;url&quot;: &quot;/&quot;<br>  },<br>  &quot;response&quot;: {<br>    &quot;status&quot;: 200,<br>    &quot;jsonBody&quot;: {<br>      &quot;status_code&quot;: 7,<br>      &quot;status_message&quot;: &quot;Invalid API key: You must be granted a valid key.&quot;,<br>      &quot;success&quot;: false<br>    }<br>  }<br>}</pre><p><strong>2.</strong> Check the updated response in your browser by visiting <a href="http://localhost:8080/">http://localhost:8080/.</a></p><h3>Mocking Other TMDB Endpoints</h3><p><strong>We will now mock three other endpoints used by our app</strong>:</p><ol><li><a href="https://developer.themoviedb.org/reference/movie-now-playing-list">Now Playing</a> (Locally using WireMock jar)</li><li><a href="https://developer.themoviedb.org/reference/movie-popular-list">Popular</a> (Proxy Mode)</li><li><a href="https://developer.themoviedb.org/reference/movie-top-rated-list">Top Rated</a> (Web UI using WireMock Cloud)</li></ol><h3>Mocking the Now Playing Endpoint</h3><p><strong>1.</strong> Create a new mapping in WireMock by creating a new JSON file in the <strong>mappings</strong> directory. Name it now-playing-200.json and add the following content:</p><p><a href="https://github.com/thekharche/maestro-wiremock-tmdb/blob/main/wiremock/mappings/now-playing-200.json"><strong>now-playing-200.json</strong></a></p><pre>{<br>    &quot;request&quot;: {<br>      &quot;method&quot;: &quot;GET&quot;,<br>      &quot;urlPathPattern&quot;: &quot;/movie/now_playing.*&quot;<br>    },<br>    &quot;response&quot;: {<br>      &quot;status&quot;: 200,<br>      &quot;fixedDelayMilliseconds&quot;: 1000,<br>      &quot;headers&quot;: {<br>        &quot;Content-Type&quot;: &quot;application/json&quot;<br>      },<br>      &quot;jsonBody&quot;: {<br>        &quot;dates&quot;: {<br>          &quot;maximum&quot;: &quot;2023-06-03&quot;,<br>          &quot;minimum&quot;: &quot;2023-04-16&quot;<br>        },<br>        &quot;page&quot;: 1,<br>        &quot;results&quot;: [<br>          // JSON body results, hidden for brevity<br>        ],<br>        &quot;total_pages&quot;: 2,<br>        &quot;total_results&quot;: 9<br>      }<br>    }<br>  }</pre><p><strong>2.</strong> Copy the JSON response from the actual TMDB endpoint for Now Playing by using tools like <a href="https://www.postman.com/">Postman</a>. Paste it into the jsonBody section of your new mapping in WireMock.</p><p><strong>3.</strong> Confirm that your newly created mock endpoint is working by visiting <a href="http://localhost:8080/movie/now_playing">http://localhost:8080/movie/now_playing</a> in your browser.</p><p>Note, the fixedDelayMilliseconds is set to 1000 that means your request will be delayed by 1 second!</p><p>Read the <a href="https://wiremock.org/docs/simulating-faults/">WireMock Documentation</a> for more configurations or use <a href="https://app.wiremock.cloud/">WireMock Cloud</a> to configure much easily and intuitively via Web UI!</p><h3>Request Matching</h3><p>For endpoints that require different responses based on query parameters, you can use request matching. To create a request matcher:</p><p><strong>1.</strong> In your mapping file, add a <strong>queryParameters</strong> section to the <strong>request</strong> section.</p><p><strong>2.</strong> Create a condition for each query parameter you want to match, such as:</p><pre>&quot;queryParameters&quot;: {<br>  &quot;page&quot;: {<br>    &quot;equalTo&quot;: &quot;2&quot;<br>  }<br>}</pre><p><strong>3.</strong> Adjust the response settings accordingly, such as updating the jsonBody. For example, let’s say our TMDB API returns different responses for page=1 and page=2. We can create a matcher within the Now Playing mapping to return different jsonBody based on the page query parameter.</p><p><a href="https://github.com/thekharche/maestro-wiremock-tmdb/blob/main/wiremock/mappings/now-playing-200-page-2.json"><strong>now-playing-200-page-2.json</strong></a></p><pre>{<br>  &quot;request&quot;: {<br>    &quot;method&quot;: &quot;GET&quot;,<br>    &quot;urlPathPattern&quot;: &quot;/movie/now_playing.*&quot;,<br>    &quot;queryParameters&quot;: {<br>      &quot;page&quot;: {<br>        &quot;equalTo&quot;: &quot;2&quot;<br>      }<br>    }<br>  },<br>  &quot;response&quot;: {<br>    &quot;status&quot;: 200,<br>    &quot;fixedDelayMilliseconds&quot;: 1000,<br>    &quot;headers&quot;: {<br>      &quot;Content-Type&quot;: &quot;application/json&quot;<br>    },<br>    &quot;jsonBody&quot;: {<br>      &quot;dates&quot;: {<br>        &quot;maximum&quot;: &quot;2023-06-03&quot;,<br>        &quot;minimum&quot;: &quot;2023-04-16&quot;<br>      },<br>      &quot;page&quot;: 2,<br>      &quot;results&quot;: [<br>        // JSON Body Results, hidden for brevity<br>      ],<br>      &quot;total_pages&quot;: 2,<br>      &quot;total_results&quot;: 9<br>    }<br>  }<br>}</pre><h3>Using Proxy Mode Locally</h3><p>WireMock allows you to mock specific endpoints while leaving the rest of the app’s interactions with the live API unaffected.</p><p><strong>To enable proxy mode:</strong></p><p><strong>1.</strong> Start the WireMock server with the -proxy-all option followed by the target URL (e.g., <a href="https://api.themoviedb.org/3/):">https://api.themoviedb.org/3/):</a></p><pre>java -jar wiremock.jar --proxy-all=&quot;https://api.themoviedb.org/3/&quot;</pre><p>Now, endpoints that you have not explicitly mocked will continue to interact with the live API, allowing for seamless and selective mocking!</p><p><strong>Let’s move on to creating Mocks using WireMock Cloud!</strong></p><p>The principles remain the same as using WireMock locally, but now we have a Web UI to simplify our tasks. Additionally, WireMock Cloud offers the advantage of an “https” base URL, enabling you to use your Mock APIs anywhere whether be Maestro CLI or Cloud!</p><h3>Using WireMock Cloud</h3><p>WireMock Cloud allows you to <strong>create</strong>, and <strong>import</strong> the mocks you’ve prepared for easy access and management.</p><p>In this guide, we’ve focused on how to migrate your Local Mocks to WireMock Cloud.</p><p><strong>But remember,</strong> you can also start creating new mock APIs directly in WireMock Cloud. Just hit the “<strong>Create new mock API</strong>” button and you’re good to go.</p><p><strong>WireMock Cloud is the preferred way to use Mock APIs with Maestro!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ny6UJClIiSOUmhTdMrQjlw@2x.png" /><figcaption>WireMock Cloud Home Page</figcaption></figure><p><strong>Here’s how to use it</strong>:</p><p>1.<strong> Create a WireMock Cloud Account:</strong> Start by setting up your account on WireMock Cloud: <a href="https://app.wiremock.cloud/">https://app.wiremock.cloud/</a></p><p>2.<strong> Start the WireMock Server Locally:</strong> Open your local terminal and initiate the WireMock server using the command:</p><pre>java -jar wiremock.jar</pre><p>3. <strong>Export Your Local Mappings:</strong> In a separate terminal, run the following curl command to export your local mappings:</p><pre>curl --output tmdb-stubs.json http://localhost:8080/__admin/mapping</pre><p>4. <strong>Create a New Mock API on WireMock Cloud:</strong> Navigate to WireMock Cloud and create a new mock API. Select ‘Blank’, provide an API name, and choose your preferred hostname: <a href="https://app.wiremock.cloud/mock-apis/create">https://app.wiremock.cloud/mock-apis/create</a></p><p>5. <strong>Import Your Local Mappings:</strong> Click on ‘Import’, then ‘File’, and upload the tmdb-stubs.json file you created earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W3ox40o9hdjBY211taRpXg@2x.png" /><figcaption>WireMock Cloud Import File</figcaption></figure><p>6. <strong>Note your base URL: </strong>Take a note of your base URL in WireMock Cloud, you can switch to this URL in your app code when you want to use Mock APIs when UI testing with Maestro!</p><p><em>Additionally</em>, there’s a method to identify Maestro within your app. This can be helpful if you need to change how your app works depending on whether it’s being used with Maestro. So, in our case if we are under Maestro environment we switch the base URL to the WireMock Cloud provided one otherwise we continue to use the original base URL!</p><p>Learn More on <a href="https://maestro.mobile.dev/advanced/detect-maestro-in-your-app">Maestro Docs</a> for Android, iOS and also checkout <a href="https://github.com/jpudysz/react-native-is-maestro">React Native library</a>.</p><blockquote><strong><em>Alternatively, you can also skip the import step and directly create new endpoints on WireMock Cloud!</em></strong></blockquote><h3>Simulating Error Statuses</h3><p>Simulating error statuses is a great way to ensure your application handles errors properly.</p><p><strong>Here’s how to simulate an error status using WireMock Cloud:</strong></p><p><strong>1.</strong> Click on ‘New’ to create a new endpoint, and set the endpoint as <strong>/movie/top_rated</strong>.</p><p><strong>2.</strong> Provide a name for the endpoint, for example, “Top Rated — 404”.</p><p><strong>3.</strong> Change the ‘Response Status’ to 404.</p><p><strong>4.</strong> Set the ‘Body Type’ to JSON.</p><p><strong>5.</strong> Add the following JSON to simulate an error message:</p><pre>{&quot;status_code&quot;:34,&quot;status_message&quot;:&quot;The resource you requested could not be found.&quot;,&quot;success&quot;:false}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ytk7lY3emCTiN2xgkopzyw@2x.png" /><figcaption>WireMock Cloud — Adding 404 Response Status</figcaption></figure><h3>Using Proxy Mode on Web UI</h3><p>WireMock’s proxy mode is a powerful feature that allows you to direct certain requests to another service. This can be particularly useful when you want to mock some endpoints while allowing other requests to interact with a live API.</p><p><strong>To set up proxy mode in WireMock Web UI, follow these steps:</strong></p><ol><li><strong>Create a New Endpoint:</strong> Navigate to the endpoint creation section and use /.* as the endpoint. This is a regular expression that matches any path, allowing this rule to act as a catch-all for requests that don&#39;t match any of the more specific stubs.</li><li><strong>Set URL Type:</strong> Choose ‘Path and query regex’ as the URL type. This ensures that the rule matches based on both the path and the query parameters of the request.</li><li><strong>Set Priority:</strong> Assign the lowest priority to this rule (e.g., 10). WireMock uses the priority to determine which stub to use when a request matches multiple stubs. By giving this rule the lowest priority, we ensure that it only gets used when no other stub matches the request.</li><li><strong>Set Base URL:</strong> Enter <a href="https://api.themoviedb.org/3">https://api.themoviedb.org/3</a> as the base URL.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tg3d5ScZLBkTuhkdKm59tA@2x.png" /><figcaption>TMDB Proxy URL</figcaption></figure><p>By following these steps, you can set up a proxy mode in WireMock Web UI, allowing you to <strong>seamlessly blend mocked and real API interactions</strong> in your testing.</p><h3>UI Testing with Maestro</h3><p>Whether you use Maestro locally or use Maestro Cloud, the WireMock setup requires no changes to your UI Testing! Just run your tests like you would normally!</p><h3>Conclusion</h3><p>WireMock is a powerful tool that allows for the creation of mock APIs, speeding up development, isolating testing, providing control over test scenarios and seamlessly integrates with Maestro!</p><h3>References</h3><p><strong>WireMock:</strong></p><p><a href="https://wiremock.org/">WireMock - flexible, open source API mocking</a></p><p><strong>Maestro:</strong></p><p><a href="https://maestro.mobile.dev/">What is Maestro? | Maestro by mobile.dev</a></p><p><strong>App Source Code:</strong></p><p><a href="https://github.com/thekharche/maestro-wiremock-tmdb">GitHub - thekharche/maestro-wiremock-tmdb</a></p><p>🎹</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53eb333da700" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>