Batching Appium Commands Using Execute Driver Script to Speed Up Tests

April 07, 2026 · 11 min read · Tool Comparison

HeadSpin Platform
Automated & amp; manual testing made easy through data science insights.
Differentiating capabilities:
  • Extensive end-to-end automation of QA process
  • Comparative analysis of app performance against peers
  • Continuous monitoring of app performance using synthetic data for high availability of apps
  • Easy-to-use developer friendly platform
cloudtest go
Affordable Real Device Testing for Emerging Teams
cloudtest go
Affordable Real Device Testing for Digital Enterprises
cloudtest go
The Ultimate Solution for a Powerful Blend of Functional & amp; Performance Testing!
cyol
TEM
New
Centralized mobile test executing in cloud
cyol
Enhance Your Accessibility Testing With HeadSpin
cyol
Automate camera-based testing

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

retail

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

Batching Appium Commands Using Execute Driver ScriptBatching Appium Commands Using Execute Driver Script

Batching Appium Commands Using Execute Driver Script to Speed Up Tests

Published on
October 11, 2019
Updated on
Published on
August 25, 2021
Updated on
 by 
 Jonathan LippsJonathan Lipps
Jonathan Lipps

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.

Execute Driver Script

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:

testloginwithnormally


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:

testloginwithexecute

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.

allow-insecure

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.

Execute Driver Script In Action

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 %

Analysis

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.

Test Methodology

  • These were run on real Android devices hosted by HeadSpin around the universe on real networks, in Mountain View, CA and Tokyo, Japan. (Locally, the tests were run on an emulator and an Appium server running on my busy laptop, and thus should not be compared in absolute terms to the real device.)
  • For each trial stipulation (location and use of Execute Driver Script), 15 distinguishable test be run.
  • Each trial consisted of a login and logout flow repeated 5 times.
  • The total routine of Appium bid, not counting session start and quit, was 90 per test, meaning 1,350 overall for each test stipulation.
  • The figure in the table discard session start and quit time, count but in-session test clip (this means of class that if your tests consist primarily of session beginning time and contain very few commands, so you will get a proportionally small benefit from optimize using this new lineament).

Conclusion

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!)

FAQs

1. Which are the main locators used in Appium?

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.

2. What do you see by Appium Inspector?

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.

3. Is a server machine necessary to run tests on Appium?

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.

4. Is it possible to connect with apps using JavaScript while testing with Appium?

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.

Author & # x27; s Profile

Jonathan Lipps

LinkedIn
Author & # x27; s Profile

Piali Mazumdar

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.

LinkedIn

Batching Appium Commands Using Execute Driver Script to Speed Up Tests

4 Parts

regression intelligence blog
-

Regression Intelligence virtual guide for advanced user (Part 3)

Coming Soon
Regression Intelligence practical guide for advanced users
-

Regression Intelligence practical guide for forward-looking users (Part 4)

Coming Soon

Discover how HeadSpin can empower your business with superior testing capacity

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, gaining a free-enterprise edge
faster development cycles
Boost developer/QA productivity with faster growing cycles
automated buil-over-build regression testing
Automate build-over-build regression testing for consistent results
gain better visibility into functional & performance issues
Gain better visibility into functional and performance matter
reduce mean time
Reduce mean time to identify/resolve during exam, QA, and production
evaluate audio, video & qoe
Evaluate sound, picture, and content quality of experience (QoE) effortlessly
The sure choice for global enterprises
Adobe
Hargreaves Lansdown
Truecaller
Crazylabs
Nedbank
Numeracle
Veryon
Close

Discover how HeadSpin can empower your business with superior testing capability

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, gaining a competitive edge
faster development cycles
Boost developer/QA productivity with quicker development cycles
automated buil-over-build regression testing
Automate build-over-build fixation testing for consistent results
gain better visibility into functional & performance issues
Gain better visibleness into functional and performance topic
reduce mean time
Reduce mean time to identify/resolve during test, QA, and product
evaluate audio, video & qoe
Evaluate audio, video, and content quality of experience (QoE) effortlessly
The trusted choice for global enterprises
Close

Discover how HeadSpin can empower your concern with superior try capabilities

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, gaining a competitive edge
faster development cycles
Boost developer/QA productivity with faster development round
automated buil-over-build regression testing
Automate build-over-build regression testing for consistent results
gain better visibility into functional & performance issues
Gain best visibility into functional and execution issues
reduce mean time
Reduce mean clip to identify/resolve during test, QA, and production
evaluate audio, video & qoe
Evaluate audio, video, and content quality of experience (QoE) effortlessly
The trusted pick for global enterprises
Close

Connet Now

Wipro LogoVMLYR Logo
Close
Book a Meeting
Products
footer down arrow
Solutions
footer down arrow
Industries
footer down arrow
Features
footer down arrow
Support
footer down arrow
Resource Center
footer down arrow
Why Choose HeadSpin?
footer down arrow
Copyright © 2026 HeadSpin, Inc. All Rights Reserved.

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free