Batching Appium Commands Using Execute Driver Script to Speed Up Tests
Both Appium and Selenium are based on a client/server architecture, where the test commands are triggered by a client that could be very far away from the server which actually do the commands. The advantage of this client/server architecture are real important, allow to be indite in any language, and making it possible to build large private or public Appium device clouds. There is one significant downside to this architecture, however, that can dramatically decrease trial execution. Because every examination dictation has to travel over the network between the client and server, every command is subject to the latency of that network, as well as any former “ atmospheric ” conditions. Networks are not perfectly authentic in general, and unanticipated slowness or request failure can occur at any point. This means that Appium scripts developed topically might behave significantly differently when run on an Appium cloud somewhere across the world, guide to rise flakiness or tryout failures. On top of this, tests are not ofttimes written by directly implementing Appium bid, but more often by using framework-level functionality, which might encapsulate the use (and overuse) of many Appium commands, all of which add to prove execution clip. In some cases, I get witness test frameworks that make 5-10 requests to the server for every found element, in order to find element metadata exactly in case it is useful after on. Apart from being a bad idea in general, this form of approaching can lead to dramatic differences of execution time when run in cloud surround. More than general ineptitude, latency is also a killer for real-time automation. If you need to be certain that command B happens a real little time after bid A, then sending bidding B across the global Internet is not going to deliver that guarantee. This is one understanding the W3C WebDriver spec team settle to build the new Actions API in a form where the entire actionchainis encoded as a single API call, even though the chain might take seconds or minutes to actually execute once the action begins. The Appium squad has now perform the same thing, not precisely for activeness, but forany Appium commands at all. Essentially, we have created a single Appium bidding that allows you to bundle as many other Appium require inside it as you want. All these commands will be executedon the Appium server itself, so will not be subject to network latency. How do this work? It ’ s conjuration, obviously! Imagine we have this examination script write in the Java client: What on earth is going on here? It looks like we ’ ve got some kind of Appium client codification wrapped up in a twine, someway? That ’ s right! The Appium team consider many way of implementing this “ raft dictation ” feature, but at the end of the day decided that giving users consummate flexibility in terms of what to run within the batch was of farthermost importance. So we implemented thisExecute Driver Scriptcommand, where the command controversy is a draw symbolize JavaScript code to be executed in the circumstance of the currently-running Appium session. Whatever you put in that string will be attempted to be action by the Appium server. Uh oh! Isn ’ t that the definition of a remote code execution vulnerability? Yes! So we need to say a twosome words about security. First, because there is no way to know what kind of junk a user might direct in with this command, the server must be started in a peculiar mode that allow this feature explicitly: Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script. Secondly, all code is run within a NodeJSVM, which means it does not percentage an executing context with the main Appium process. In fact, we can tightly control what methods the executing code has access to, and we give access to basically nothing except a driver objective. What is this driver object? It ’ s an instance of aWebdriverIOsession object. So you can use the entire WebdriverIO API, and all the JavaScript syntax your bosom trust! This explains the interesting bits of the code above, like the driver. $ method (which is WebdriverIO ’ s equivalent of findElement), or the fact that accessibility ID locators are delimit by putting ~ at the battlefront. You can alsoreturntext, datum, or yet elements inside your code twine, and the result will be fully usable from within the parent script. I wanted to get a full idea of the wallop of the Execute Driver Script on test executing multiplication, so I ran a caboodle of experiments on the solitary Appium cloud supplier which presently supports this feature: HeadSpin. My test methodology is detailed below, but here are the results (in all cases, the client location is Vancouver, Canada): ServerUsing Execute Driver? Avg Test TimeAvg Command TimeAvg SpeedupLocalhostNo49.12s0.55s LocalhostYes48.71s0.54s0.8 % Mountain View, CANo72.53s0.81s Mountain View, CAYes43.15s0.48s40.5 % Tokyo, JapanNo102.03s1.13s Tokyo, JapanYes42.10s0.47s58.74 % In the causa of local performance, use of Execute Driver Script does not render much of an betterment, and this is expected. When customer and server are already located on the same network interface, there is basically no clip lose to latency. What we see in the examples where the Appium waiter is located someplace else in the world is lots more drastic. Mountain View, CA is lots closer to my office in Vancouver than Tokyo is, and that is reflected in the ~30 % difference in the control lawsuit for each locating. This difference is essentially entirely due to latency, and highlights exactly the trouble with the client/server model when deployed in this case–about 30 seconds per test, when the bid count is high (in this case, 90 commands per test). When I adjust my book to use Execute Driver Script entirely, so that all 90 commands are contained within one batch, what we see is that test clip is basically a low constant routine across all environments. Since I ’ m just making one network outcry, latency due to geographical distribution becomes a paltry factor, reducing test behavior time by a factor of 40-60 %! Of trend, your results with this feature will vary greatly due to any routine of divisor, including the act of commands you put into the batch yell, etc… I am also not recommending that every command be thrust into one of these Execute Driver Script calls, merely demonstrating the performance improvements which might be relevant for a use case you encounter. Execute Driver Script is a new Appium feature that is especially useful when running your trial in a distributed circumstance. If a cloud waiter or device is located across the world from you, each command will take longer than it would if the server were near. The further away the gimmick, the longer your command will take. The administrator of such a distributed cloud can opt to turn on the Execute Driver Script feature in Appium, to allow their users to batch commands as a way of avoiding tons of unneeded, latency-filled back-and-forth with the server. This gives users the advantage of a geographically distributed cloud (whether the user wants geographic dispersion for its own interest or because that is but where the device and host happen to be located), without the typical latency cost associated with it. Of course, this is an modern lineament that you should only use to solve specific problems! If you want to see that Java code in the context of the full projection, you canassure it out on GitHub. Former Appium clients too indorse this new command, include WebdriverIO (so you can hold WebdriverIO-ception!) Ans: The main locater that support Appium are ID, Class Name, XPath, Accessibility ID, Android UI Automator, iOS UI Automation, and Android View Tag habituate Appium Espresso. Ans: Appium Inspector is a lineament offered by the Appium framework to name a wandering app & # x27; s UI elements while developing Appium automation book. It is likewise used in record and playback tasks. Ans: No. You don ’ t require a server machine to run tests on Appium. The Appium framework provides a 2-tier architecture, where a test machine connects to a trial server bunk Appium and automatise the entire procedure. Ans: Yes. Testers can connect with apps habituate JavaScript while test with Appium. When quizzer run the commands on Appium, the waiter sends the script to the app wrapped into an anonymous function to be executed. Lead, Content Marketing, HeadSpin Inc. Piali is a active and results-driven Content Marketing Specialist with 8+ years of experience in crafting engaging narratives and marketing collateral across divers industries. She surpass in collaborating with cross-functional squad to develop innovative content strategies and present compelling, authentic, and impactful content that resonate with prey audiences and enhances marque authenticity. 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)



Batching Appium Commands Using Execute Driver Script to Speed Up Tests
AI-Powered Key Takeaways
Execute Driver Script

As you can believably state, it ’ s a really straightforward login/logout set of commands. If necessary, we could run all these bid in one go, as a batch, using the new executeDriverScript bid:

Execute Driver Script In Action
Analysis
Test Methodology
Conclusion
FAQs
1. Which are the main locators used in Appium?
2. What do you see by Appium Inspector?
3. Is a server machine necessary to run tests on Appium?
4. Is it possible to connect with apps using JavaScript while testing with Appium?
Piali Mazumdar
Batching Appium Commands Using Execute Driver Script to Speed Up Tests
4 Parts
-1280X720-Final-2.jpg)
Regression Intelligence virtual guide for advanced user (Part 3)
-1280X720-Final-2.jpg)
Regression Intelligence practical guide for forward-looking users (Part 4)
Discover how HeadSpin can empower your business with superior testing capacity







Discover how HeadSpin can empower your business with superior testing capability
Discover how HeadSpin can empower your concern with superior try capabilities
Connet Now


Automate This With SUSA
Test Your App Autonomously







.png)












