Making Your Appium Tests Fast and Reliable - Part 5: Setting Up App State
This article is the fifth in a multi-part series on test speed and reliability, inspired by a webinar I gave on the same subject (you canwatch the webinar here). You might also want to check out Part 1: , Part 2: , Part 3: , and Part 4: . One of the unfortunate realities of functional examination is the & quot; speed limit & quot;: we can only go as tight as the underlying technologies let us go. Taps take time. Sending keystrokes takes time. Waiting for an application to load data from the network, or finish life ... your app takes time too. And that & # x27; s sort of the point: we need functional testing to be & quot; high-fidelity & quot;, meaning as tight to real life as potential. That & # x27; s all well and good, except when we have multiple (or many) tests that rely on the same part point. It & # x27; s a existent hurting to wait for a test script to type into half a 12 boxes and tap half a dozen buttons before the essence of a test begins. Probably the most common scenario is logging in: a lot of what we is likely behind a user login substantiation, which typically means determination and entering text into a few schoolbook boxes and tip a button, not to mention look for the verification to take place over the meshing. It & # x27; s not crazy to imagine that lumber into an app could take as long as 20 or 25 seconds, depending on a variety of factors. Let & # x27; s imagine for a second that we have a suite of 50 tests which require logging in before they can start verifying their particular requirement. If math doesn & # x27; t lie, so: In this scenario, setting up the logged-in province in our coating is costing us 20 minutes of build time (which might be existent time if we & # x27; re running in a individual thread). Ouch. More than that, we & # x27; re open ourselves up to the voltage of flakiness in that particular set-up flow, by running it many more multiplication than we need to. Sadly, there might not be a way to speed up the login steps using Appium itself (once it & # x27; s demonstrate that the nearly effective locater strategies are already in use, etc ...). That doesn & # x27; t mean we can & # x27; t take a shortcut, though! What if we could begin our test with the app already in its logged-in state? With a little help from the app developers, we can! In this article, we & # x27; re move to take a look at 5 ways to set up app state so that you don & # x27; t have to use Appium to get to the point where you need to start your test. (Of trend, don & # x27; t bury to leave at leastone test that doesuse Appium to set up the province, so you & # x27; re actually covering it. You don & # x27; t require your login functionality to break because none of your test actually walk through the flow anymore!) Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script. If you & # x27; re developing an Android app, you might be cognizant of the concept of Activities. Android apps might have multiple activities, which correspond to different constituent of the coating which may need to be accessed straightaway (say from a link in an e-mail). It & # x27; s possible to design your app in such a way that starting a certain activity pose up the appropriate province in your app. Essentially, a given activity is simply a trigger for state set-up. Appium makes it possible to start arbitrary activities in your app using thestartActivitycommand, and legislate in the package of your app along with the coveted activity as parameters, for example: You can even use theappActivitydesired capability to dump your session immediately into the specified action upon start, so that from the real beginning your codification will be executing in the context of that activity. Just don & # x27; t forget to strip out any activities that are used for testing only in the production build of your app. A similar technique is possible with iOS, yet though iOS apps do not get & quot; action & quot;. Instead, iOS apps can be launched with what are essentially command-line flags telephone & quot; launch arguments & quot;. These flags can be say by the running coating. You could easily design your application to parse the flags for a variety of datum, include usernames and passwords to be used for an initial UI-less login. The way to access this feature habituate Appium is via theprocessArgumentscapability. For example, depending on how we & # x27; d set up our app, we could imagine a schema like this: Of course, the app developer would have to construct the app in such a way that it cognise what to do with these flag and be sure to get the product version of the app ignore them. A more straightforward approach that still involves UI automation habituate Appium is what I ring the & quot; Test Nexus & quot; proficiency. I saw a outstanding example of this fromWim Selles, who put the proficiency to good use at his company. What & # x27; s a Test Nexus? It & # x27; s essentially a & quot; kitchen sink & quot; vista in your app, only available in the test build, which contains links to a smorgasbord of former locations in your app, that come with attached state. So, you could have a link that says & quot; Logged-in Home & quot;, or one that reads & quot; Cart With 1 Item & quot;. Tapping either of those nexus would trigger the app to take you to the appropriate position, with the appropriate state. This does mean the app developer would need to hook the nexus up to any necessary logic. The advantage of this attack is that it is cross-platform, and leisurely enough for the Appium test author to simply notice the right button and click on it, save a lot of clip in the process. As an example of what this Test Nexus could look like, hither & # x27; s a screenshot of Wim & # x27; s app: Another cross-platform option is so-called & quot; Deep Linking & quot;. This is an OS-level feature whereby clicking on a URL with a custom scheme (i.e., a vendor-specific scheme which differs from & quot; http & quot; or & quot; https & quot;) actually takes you to your application. The URL is passed to the app, and thus the app can parse it for all kinds of information which so direct the exploiter experience. Used for testing, it & # x27; s a potent way to set up a very flexible URL construction that can be used to direct your test to anywhere you want in your app. It does require the app developer to have registered a custom-made scheme with the OS, and to have created some kind of URL & quot; controller & quot; that parse the URL and actually navigate the app to the correct view with the appropriate state. For example, you could have a URL that looks like: Which, when clicked, would open up your application in a province where the login verification has already been perform with the supplied username and password. What & # x27; s outstanding is that, utilize Appium, you don & # x27; t need to regain some way to snap a link to this URL: you can use Appium & # x27; sdriver.get ()command to trigger the URL to launch forthwith: I won & # x27; t say more about Deep Linking here, because I wrote a whole article on that theme already; for more information! I mention this last technique because it is interesting, still though there & # x27; s not actually an easy way to enable it within Appium today. The idea is basically that your application can break application-internal method to the outside world. These would be methods that are utilitarian for testing and setting up state in your app. Your test script would then accession these & quot; backdoors & quot; whenever it needed to set up province. At the moment this would feature to be some kind of custom RPC channel between your trial hand and app, though there is an interesting proof-of-concept proposal to do something like this available within Appium itself (for Android). The idea was brought forward to the Appium community by Rajdeep Varma in hisAppiumConf 2018 talk, and it & # x27; s surely a promising one! In the meantime, I recommend checking out one of the first 4 proficiency. Anything you can do to save tests having to cover the same ground over and over again precisely to set up state is worth it, still if it regard a awful back-and-forth with your development team. Even if you don & # x27; t experience control over the source code yourself, I cogitate it & # x27; s a relatively easy argument to make that a small up-front effort to create these state set-up mechanisms will pay off for everyone in the long run, in term of quicker and more reliable chassis. Lead, Content Marketing, HeadSpin Inc. Piali is a dynamical and results-driven Content Marketing Specialist with 8+ age of experience in craft engaging narratives and marketing collateral across various industries. She surpass in cooperate with cross-functional squad to develop innovative substance strategies and deliver compelling, authentic, and impactful content that resonates with prey audiences and enhances make genuineness. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts..png)



Making Your Appium Tests Fast and Reliable - Part 5: Setting Up App State
AI-Powered Key Takeaways

Check:
Technique 1: Custom Android Activities (Android-only)
driver.startActivity (new Activity (`` com.example.app '', `` .ActivityName ''));Technique 2: Custom Launch Arguments (iOS-only)
Get instant access to existent iOS device from your browser with the best iOS testing platform.!
{`` processArguments '': `` -view login -viewparams 'my_username, my_password ' ''}Technique 3: The Test Nexus

Technique 4: Deep Linking
Read:
yourapp: //test/login/: username/: worddriver.get (`` yourapp: //test/login/my_username/my_password '');Technique 5: Application Backdoors
Piali Mazumdar
Making Your Appium Tests Fast and Reliable - Part 5: Setting Up App State
4 Parts
-1280X720-Final-2.jpg)
Regression Intelligence practical guide for forward-looking users (Part 3)
-1280X720-Final-2.jpg)
Regression Intelligence hard-nosed guide for modern users (Part 4)
Discover how HeadSpin can empower your concern with superior testing capabilities







Discover how HeadSpin can empower your business with superior screen capabilities
Discover how HeadSpin can empower your line with superior essay capabilities
Connet Now


Automate This With SUSA
Test Your App Autonomously







.png)












