<?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 Evgeny Ivanov on Medium]]></title>
        <description><![CDATA[Stories by Evgeny Ivanov on Medium]]></description>
        <link>https://medium.com/@evgeny.ivanov2611?source=rss-57eafa9748e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_Xp3s4gfO2ZCpqL4.jpg</url>
            <title>Stories by Evgeny Ivanov on Medium</title>
            <link>https://medium.com/@evgeny.ivanov2611?source=rss-57eafa9748e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:09:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@evgeny.ivanov2611/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[Accessibility technology and UI tests for iOS apps — practical guide (iOS Automation Trip 2)]]></title>
            <link>https://medium.com/@evgeny.ivanov2611/accessibility-technology-and-ui-tests-for-ios-apps-practical-guide-ios-automation-trip-2-19bd93f93515?source=rss-57eafa9748e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/19bd93f93515</guid>
            <dc:creator><![CDATA[Evgeny Ivanov]]></dc:creator>
            <pubDate>Mon, 30 Nov 2020 17:46:46 GMT</pubDate>
            <atom:updated>2020-11-30T17:46:46.454Z</atom:updated>
            <content:encoded><![CDATA[<h3>Accessibility technology and UI tests for iOS apps — practical guide (iOS Automation Trip 2)</h3><p>Hi everyone.<br>Let’s continue our trip to the automation and today you will learn some important things about UI tests and technologies which are used for these tests.</p><p>I hope you’ve become pro with <strong>tests</strong> <strong>recorder</strong> from previous article.</p><p>Now imagine that your employer is completely satisfied with your automation from previous tutorial. And he asks you to do the same for updated version of the app with new cool button.</p><p>So you are confident professional and you’ve agreed to do that.<br>Let’s do this job like last time using <strong>recorder</strong>.</p><p>You can download demo project here: <a href="https://github.com/EvgenyIv96/iOS-Automation-trip/tree/main/Projects/iOS-Automation-Trip-2/Demo">https://github.com/EvgenyIv96/iOS-Automation-trip/tree/main/Projects/iOS-Automation-Trip-2/Demo</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*xIJ7jMI2ZGReJdT4GyHYkw.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*58JPPtWyxNaNMKDzsasc_Q.png" /><figcaption>Recorder Error</figcaption></figure><p>Wow. It was surprisingly. Something went wrong and <strong>recorder</strong> doesn’t work.</p><p>To figure out the reason of this behavior it would be good to understand how it works.</p><h3><strong>Theory</strong></h3><p>You should understand 2 important things about UI tests in iOS:</p><ul><li>UI tests work with accessibility elements, not with UI elements</li><li>UI tests are black box tests and they are executed in separated app</li></ul><h4>Accessibility</h4><p>So what is it?<br>When we are talking about UI tests it is the one of the core technologies (the second is <strong>XCTest</strong> framework).</p><p>What about profit for the iOS devices users? <br>It allows developers to deliver a superior mobile experience to every customer, including those with special needs.<br>For example <strong>VoiceOver</strong> uses data provided by <strong>Accessibility</strong> technology.</p><p>So let me try to give you definition of that :)</p><p><strong>Accessibility</strong> is the technology which provides semantic data about user interface.</p><h4>Black box</h4><p>You may find definition like that</p><blockquote>It’s a technique of software testing that examines the functionality of an application without using its internal workings.</blockquote><p>In the case of the UI tests it means that tests interact with app like user and you won’t be able to execute some code in application like in unit tests.</p><h3>Practice</h3><p>I’ve added the code to launch demo app and added two breakpoints: before launching app and after that. I will need these breakpoints to show you separate app and debug techniques :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*8SqtMXWWbP7L_p0UdAG1yg.png" /></figure><p>Now I will run this test and show you things from previous section in the action.</p><p><strong>Separate app</strong><br>You may notice what there is not only app installed when running UI tests.<br>Also there is “Runner” app without UI where is tests are executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*b3m1Fxi6wyEnzjwIoDgzVQ.png" /><figcaption>Test runner app on the home screen</figcaption></figure><p>If you try to launch it manually when tests aren’t executed you will see the black screen and it will be closed in a moment. (The runner app won’t be closed if you have active breakpoints in the test when trying to launch runner app)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*eBBSYVSm573Ad-4at_S5Pw.gif" /></figure><p><strong>Accessibility hierarchy</strong></p><p>Now I go to the second breakpoint after launching demo app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uo7aciQnHIOihfiZkdHquQ.png" /></figure><p>It’s very important to have launched demo app to debug it and stop on the breakpoint in the executed test to do some debugging.</p><p>Now to see the accessibility elements you should execute this code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0901809772f383152d1a81f492ea407/href">https://medium.com/media/f0901809772f383152d1a81f492ea407/href</a></iframe><p>Just type it in the console in <strong>Xcode</strong> and press the “<strong>Enter</strong>” when staying on the breakpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*OEU2n6Qc2SRhYkMUs6DtPg.png" /></figure><p>It will send query to the launched demo app, demo app will make snapshot of the accessibility elements and execute this query, after that you will get the results.<br>Don’t worry if it’s very hard to understand it for you now. It will become obvious after enough practice.</p><p>Let’s look at the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*YwCDGz4EDtipJIk4Pxb1eA.png" /><figcaption>Debug output</figcaption></figure><p>I’ve highlighted the accessibility hierarchy. Element subtree on this screenshot is the accessibility hierarchy of the demo app.</p><p>So, we have here only “Enter email” <strong>TextField</strong> and no buttons. That’s why recorder doesn’t work when trying to record tap on the button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*Bw_A9JLWPSQC7EtclbPYAg.png" /><figcaption>Head to head: UIView hierarchy (left; from view debugger) &amp; Accessibility hierarchy (right; from lldb output)</figcaption></figure><p>Let’s continue debug session :)<br>Don’t continue execution in the test. Just switch to the simulator, enter invalid email and tap on the “Verify” button. Yeah, it may sound strange but you can do it, cause as I mentioned below tests are executed in the separated app and breakpoints in the test code don’t stop execution of the tested app. <br>After that back to <strong>Xcode</strong> and print the hierarchy again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*4QKCfcR3UkK5Ut7QbStmZQ.gif" /></figure><p>Ok. I believe that it will be enough to learn how to debug.</p><p>What else interesting you can do with knowledge gained from this article?</p><p>You can debug accessibility hierarchy and interact with system and third party apps.</p><p>To do that you need to know a bundle identifier of the app. Use XCUIApplication(bundleIdentifier:) initializer to get an instance to make queries for the specific app:<br>1. create instance<br>2. launch the app<br>3. add breakpoint to the next line after launch call<br>4. run test<br>5. execute queries using lldb as shown in this article</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f0448b2914165199786d700375e7751/href">https://medium.com/media/8f0448b2914165199786d700375e7751/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*1xgekEwPe_ErX3R_JRblkw.gif" /><figcaption>Interaction with iOS system preferences app</figcaption></figure><p>Ok. That’s all.</p><p>In the next article I’ll show you how to fix demo app for <strong>recorder</strong> and how to control accessibility hierarchy.</p><h3>Homework</h3><p>There’s no special app for this article. You can use UI tests target in demo project from the article or create empty project with UI tests by yourself.</p><ul><li>Find bundle ids for iOS system app (use google)</li><li>Research system setting app and safari app by printing accessibility hierarchy of this apps and interacting with user interface (use appropriate initializer of XCUIApplication with bundle id to run system apps)</li><li>Try to tap on the cells in the settings app using lldb</li><li>Try to type any url in the safari using lldb</li><li>Try to get status bar height from Springboard application using lldb</li></ul><h3>Conclusions</h3><ul><li>UI tests works with accessibility hierarchy and not with view hierarchy</li><li>By default controls from UIKit provides data which allows to achieve accessibility hierarchy as close to view hierarchy</li><li>UI tests can interact with system and third-party apps</li><li>UI tests are black box tests and it doesn’t allow you to execute something in test app process</li></ul><h3>Links</h3><ul><li><a href="https://developer.apple.com/videos/play/wwdc2015/406/">https://developer.apple.com/videos/play/wwdc2015/406/</a></li><li><a href="https://support.apple.com/guide/mdm/bundle-ids-for-native-ios-and-ipados-apps-mdm90f60c1ce/1/web/1">https://support.apple.com/guide/mdm/bundle-ids-for-native-ios-and-ipados-apps-mdm90f60c1ce/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19bd93f93515" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to start with UI tests for iOS apps — practical guide (iOS Automation Trip 1)]]></title>
            <link>https://medium.com/@evgeny.ivanov2611/how-to-start-with-ui-tests-for-ios-apps-practical-guide-ios-automation-trip-1-dbf45c0224e6?source=rss-57eafa9748e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbf45c0224e6</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[xcuitest]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Evgeny Ivanov]]></dc:creator>
            <pubDate>Mon, 23 Nov 2020 18:51:31 GMT</pubDate>
            <atom:updated>2020-11-23T18:51:31.587Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to start with UI tests for iOS apps — practical guide (iOS Automation Trip 1)</h3><p>Hi everyone! In this series of articles I’ll give you step by step journey on how to create automated tests for iOS apps. At the end of that article you will know how to add UI tests to existing project and you will make your first ui tests.</p><p>Before we start, I want you to have minimal representation about this kind of tests, at least how does look.</p><figure><img alt="UI tests for my application" src="https://cdn-images-1.medium.com/max/1024/1*aut3GyTwJRU65xdm8zCdWw.gif" /><figcaption>UI tests for my application</figcaption></figure><p>Some numbers:</p><ul><li>62 tests to test everything in application</li><li>it took 4 days of work to code all 62 tests from scratch</li><li>~6.5 min for regression on the 2 iPhone simulators</li><li>about 6 months to learn to do such automation (with maintainable code)</li></ul><h4>First steps</h4><p>So you decided to start with this topic today. Let’s get started. <br>I will show you first steps on the one screen application and your todo will be to reproduce it in the study project.</p><p>You can follow this article with this demo project:<br><a href="https://github.com/EvgenyIv96/iOS-Automation-trip/tree/main/Projects/iOS-Automation-Trip-1/Demo/email-checker">https://github.com/EvgenyIv96/iOS-Automation-trip/tree/main/Projects/iOS-Automation-Trip-1/Demo/email-checker</a></p><p>Let’s look at the demo.</p><p>The Demo project is simple one screen app with text field and button. It validates entered email.</p><figure><img alt="Demo app" src="https://cdn-images-1.medium.com/max/1024/1*5IAvWV4wOuQEKZdJk2K1MA.gif" /><figcaption>Demo Project</figcaption></figure><p>Ok, so first we have to add test target to a project.</p><ul><li>click <strong>File → New → Target</strong></li><li>then type in <strong>Filter field</strong> «<strong>test</strong>»</li><li>select «<strong>UI Testing Bundle</strong>»</li><li>click <strong>Next → Finish</strong></li><li>here we go</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l3vBfkg_p4ouXRMtTaayYg.gif" /><figcaption>Creating test target</figcaption></figure><p>Now let’s go to the code.<br>I’m gonna to remove all boilerplate code and declare a test method to test invalid email verification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wUiUK2igSKl3ipNaWJrYUA.png" /></figure><pre><strong>func</strong> testVerifyInvalidEmail() {</pre><pre>}</pre><p>At this point you may know no nothing about Apple’s API and technologies. But for now you don’t need it cause there is great tool to start — <strong>recorder</strong></p><p>Place the cursor to the test method body and check red circle button, it should be active.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*2lLSx_mPmz9y4MvTSGdzGA.png" /><figcaption>Record UI Test button</figcaption></figure><p>If the button is inactive you need to rebuild, just press combination:<br><strong>Cmd + Shift + U<br></strong>And wait until it will be ready.</p><p>Now click on the red circle button.<br>It will launch the app and activate record mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1QNDjrxag4P3g20sxsbXEg.gif" /><figcaption>Launch record mode</figcaption></figure><p><strong>Offtop:</strong> While I was writing this article and recording example video my Xcode has been updated and the next part of this article will be showed in the new XCode. I really apologize for it :)</p><p>Now I can just interact with app and it’ll write the code automatically.<br>So let’s walk through invalid email scenario:</p><ul><li>tap on the email field</li><li>enter «111»</li><li>tap on the «Verify» button</li><li>tap on the «Invalid email» message</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JmlKYh-jIrfRVr6VURk6gw.gif" /><figcaption>Record interactions</figcaption></figure><p>Now I got some code in the method:</p><pre><strong>let</strong> app = XCUIApplication()</pre><pre>app.windows.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.tap()</pre><pre><strong>let</strong> enterEmailTextField = app.textFields[&quot;Enter email&quot;]</pre><pre>enterEmailTextField.tap()</pre><pre>enterEmailTextField.tap()</pre><pre>app.staticTexts[&quot;Verify&quot;].tap()</pre><pre>app.staticTexts[&quot;Invalid email&quot;].tap()</pre><p>It doesn’t type anything in the email field and it doesn’t check anything. <br>And if I run test with this code I’ll get error, cause app won’t be launched.</p><p>But it has queries to the all interface elements and it’s good base to write this test.</p><p>Now I’m gonna to fix it and add missing interactions and checks.</p><ul><li>launch the app by calling launch() method on the app object</li></ul><pre>...<br>app.launch()<br>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3VvRO988_s4s6xYBgC088Q.gif" /><figcaption>Launch app using `launch()` method</figcaption></figure><ul><li>remove unnecessary code (you may haven’t it)</li></ul><pre>app.windows.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.tap()</pre><ul><li>type some invalid email text after tap on text field by calling typeText() method on the enterEmailTextField</li></ul><pre><strong>...<br>let</strong> enterEmailTextField = app.textFields[&quot;Enter email&quot;]</pre><pre>enterEmailTextField.tap()</pre><pre>enterEmailTextField.typeText(&quot;111&quot;)<br>...</pre><ul><li>then tap «Verify» button</li></ul><pre>...<br>app.staticTexts[&quot;Verify&quot;].tap()<br>...</pre><ul><li>and check an existence of the «Invalid email» message using exist property and XCTAssertTrue</li></ul><pre>...<br>XCTAssertTrue(app.staticTexts[&quot;Invalid email&quot;].exists)<br>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*NWqJ58Xv2HQ4jWX6o3IQbQ.gif" /><figcaption>test verify invalid email</figcaption></figure><p>full test code</p><pre><strong>let</strong> app = XCUIApplication()</pre><pre>app.launch()</pre><pre><strong>let</strong> enterEmailTextField = app.textFields[&quot;Enter email&quot;]</pre><pre>enterEmailTextField.tap()</pre><pre>enterEmailTextField.typeText(&quot;111&quot;)</pre><pre>app.staticTexts[&quot;Verify&quot;].tap()</pre><pre>XCTAssertTrue(app.staticTexts[&quot;Invalid email&quot;].exists)</pre><p><strong>Congratulations</strong>: If you followed the article and repeated all steps and you’re here now — you just have created your first UI test.</p><h3>Practice</h3><p>Now you really need practice. You should try it by yourself and resolve problems on your way.</p><ul><li>get the demo project: <a href="https://github.com/EvgenyIv96/iOS-Automation-trip/tree/main/Projects/iOS-Automation-Trip-1/Demo/email-checker">github</a></li><li>create UI tests target</li><li>replicate test for invalid email check using recorder</li><li>create func testVerifyValidEmail() and write test for valid email scenario</li></ul><p>Hope you enjoyed it.</p><p>In the next article I’ll tell you about technology which used for this tests.</p><p>Feel free to contact with me, give your feedback or ask questions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbf45c0224e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>