These Appium interview questions for freshers and juniors (0–18 months) come with detailed answers and code: Appium 2 and its architecture, Android and iOS setup, capabilities, locators and Appium Inspector, gestures, permissions and native elements, hybrid apps and TestNG integration. For experienced-level questions, see Appium interview questions for experienced.
Introduction to Appium
What is Appium? How is it different from Selenium?
Appium is an open-source, cross-platform mobile test automation framework used to automate native, hybrid, and mobile web applications on Android and iOS devices.
- Created by Dan Cuellar in 2012, later donated to JS Foundation (now OpenJS Foundation)
- Extends the Selenium WebDriver protocol to support mobile automation
- Does NOT require app source code modification or SDK embedding — works as a black box
- Supports Java, Python, JavaScript, Ruby, C# — same as Selenium
- Uses platform-specific automation engines: UIAutomator2 (Android), XCUITest (iOS)
| Feature | Appium | Selenium WebDriver |
|---|---|---|
| Target Platform | Mobile apps (Android, iOS) | Web browsers (desktop/mobile) |
| App Types | Native, Hybrid, Mobile Web | Web apps only |
| Protocol | W3C WebDriver + mobile extensions | W3C WebDriver |
| Automation Engine | UIAutomator2 / XCUITest | ChromeDriver / GeckoDriver |
| Device Support | Real devices + Emulators/Simulators | Browser on any OS |
| Setup Complexity | Higher — SDK, drivers, Xcode needed | Simpler — just browser drivers |
| Code Reuse | Shared code with Selenium possible | Web-only code |
What are the three types of mobile apps? How does Appium handle each?
Understanding app types is fundamental — it determines which locator strategies and contexts to use.
| App Type | Description | Appium Handling | Examples |
|---|---|---|---|
| Native App | Built with platform-specific SDK (Java/Kotlin for Android, Swift/ObjC for iOS) | Uses UIAutomator2 or XCUITest directly. All mobile locators available. | Gmail, YouTube, WhatsApp |
| Hybrid App | Native shell wrapping a WebView (web content inside mobile app) | Switch between NATIVE_APP and WEBVIEW context. Use mobile locators for native, Selenium locators for WebView. | Flipkart, older Ionic apps |
| Mobile Web | Website opened in mobile browser (Chrome/Safari) | Similar to Selenium but on mobile browser. Use web locators (CSS, XPath). | Any website on Chrome Android / Safari iOS |
What is Appium 2.0? What are the key differences from Appium 1.x?
Appium 2.0 (released 2022) is a major architectural overhaul that makes Appium more modular and extensible.
| Aspect | Appium 1.x | Appium 2.0 |
|---|---|---|
| Driver packaging | Drivers bundled with Appium | Drivers installed separately via CLI |
| Install drivers | Automatic | appium driver install uiautomator2 |
| Plugin system | None | Rich plugin ecosystem (gestures, images, etc.) |
| Capabilities format | desiredCapabilities{} | UiAutomator2Options / XCUITestOptions class |
| Default base path | /wd/hub | / (root) — breaking change! |
| Security | Basic | Fine-grained server security flags |
| Extensibility | Limited | Fully extensible via plugins and drivers |
Explain the Appium architecture end-to-end.
Appium uses a client-server architecture built on top of the W3C WebDriver protocol.
- 1. TEST SCRIPT (Client): Your Java/Python test code using Appium Client Library sends HTTP requests
2. APPIUM SERVER: Node.js HTTP server receives requests on port 4723. Routes to appropriate driver.
- 3. AUTOMATION DRIVER: UIAutomator2 (Android) or XCUITest (iOS) — translates commands to native calls
- 4. DEVICE / EMULATOR: The actual Android device/emulator or iOS device/simulator executes actions
- 5. RESPONSE: Result travels back through the chain to your test script
- Android flow: Test Script → Appium Server → UIAutomator2 → ADB → Android Device
iOS flow: Test Script → Appium Server → XCUITest → WebDriverAgent → iOS Device
- WebDriverAgent (WDA): An iOS app that Appium installs on iOS device to receive XCUITest commands
- ADB (Android Debug Bridge): Command-line tool for communication with Android devices/emulators
Environment Setup
What are all the prerequisites to set up Appium for Android automation?
Android setup requires several tools. Install in this order:
- 1. Java JDK 11+: Install and set JAVA_HOME environment variable
- 2. Android Studio: Download from developer.android.com. Install Android SDK during setup.
- 3. Android SDK: Set ANDROID_HOME = C:/Users/user/AppData/Local/Android/Sdk (Windows) or ~/Library/Android/sdk (Mac)
- 4. Add to PATH: $ANDROID_HOME/platform-tools and $ANDROID_HOME/tools
- 5. Node.js: Download LTS from nodejs.org. Required for Appium server.
- 6. Appium Server: npm install -g appium
- 7. UIAutomator2 Driver: appium driver install uiautomator2
- 8. Appium Inspector: Download from GitHub releases (appium/appium-inspector)
- 9. Maven/Gradle: For Java project dependency management
- 10. Appium Java Client: Add to pom.xml — io.appium:java-client:8.x
- Verify: appium-doctor --android — checks all prerequisites and shows what's missing
How do you set up Appium for iOS automation? What extra requirements exist?
iOS setup requires a Mac machine — iOS automation cannot be done on Windows or Linux.
- 1. macOS: Required — iOS development tools only work on Mac
- 2. Xcode: Install from App Store (latest stable version). Accept license: sudo xcodebuild -license
- 3. Xcode Command Line Tools: xcode-select --install
- 4. Homebrew: /bin/bash -c '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)'
- 5. Node.js: brew install node
- 6. Appium Server: npm install -g appium
- 7. XCUITest Driver: appium driver install xcuitest
- 8. Additional tools: brew install carthage libimobiledevice ios-deploy
- 9. iOS Simulator: Open Xcode → Window → Devices and Simulators → Add simulator
- 10. Real Device extras: Apple Developer account, provisioning profile, code signing certificate
- Verify: appium-doctor --ios
- WebDriverAgent: Appium auto-installs WDA on device/simulator during first session
How do you connect a real Android device to Appium? What is ADB?
ADB (Android Debug Bridge) is the tool that enables communication between your computer and Android devices.
- Steps to connect real device:
- 1. Enable Developer Options: Settings → About Phone → tap Build Number 7 times
- 2. Enable USB Debugging: Developer Options → USB Debugging → ON
- 3. Connect via USB cable
- 4. Accept 'Allow USB debugging' dialog on device
- 5. Verify: adb devices — should show your device serial number
- Key ADB commands for Appium testers:
adb devices — list connected devices
adb shell — open device shell
adb install app.apk — install APK on device
adb uninstall com.package.name — uninstall app
adb logcat — view device logs
adb shell dumpsys window | grep mCurrentFocus — get current app package/activity
adb shell am start -n com.pkg/.Activity — launch app
adb shell input text 'hello' — type text
adb pull /sdcard/file.txt . — copy file from device
Desired Capabilities & Appium Options
What are Desired Capabilities in Appium? List all important ones for Android.
Desired Capabilities (or AppiumOptions in Appium 2) are key-value pairs that tell the Appium server which device, platform, and app to use for the session.
// Appium 2.x style (recommended):
UiAutomator2Options options = new UiAutomator2Options();
options.setPlatformName("Android");
options.setDeviceName("emulator-5554"); // adb devices output
options.setAppPackage("com.example.myapp");
options.setAppActivity("com.example.myapp.MainActivity");
options.setAutomationName("UIAutomator2");
options.setApp("/path/to/app.apk"); // Use if app not installed
options.setNoReset(true); // Don't reset app state between sessions
options.setAutoGrantPermissions(true); // Auto-accept all permissions
options.setNewCommandTimeout(300); // Wait 5 min for next command before timeout
options.setUdid("R5CX2019GJL"); // Use for specific real device
options.setChromedriverExecutableDir("/path/chromedriver"); // For WebView testing
options.setAppWaitActivity("com.example.myapp.SplashActivity"); // Wait for this activity
options.setFullReset(false); // Full reset: uninstall and reinstall app
What are the key capabilities for iOS in Appium?
iOS capabilities use XCUITestOptions in Appium 2:
XCUITestOptions iosOptions = new XCUITestOptions();
- iosOptions.setPlatformName('iOS');
- iosOptions.setPlatformVersion('17.0');
- iosOptions.setDeviceName('iPhone 15 Pro');
- iosOptions.setAutomationName('XCUITest');
- iosOptions.setBundleId('com.example.myapp'); // For pre-installed apps
- iosOptions.setApp('/path/to/MyApp.app'); // Or .ipa for real device
- iosOptions.setUdid('auto'); // 'auto' picks available simulator
- iosOptions.setWdaLocalPort(8100); // Custom WDA port (for parallel)
- iosOptions.setUseNewWda(false); // Reuse existing WDA (faster)
- iosOptions.setWdaLaunchTimeout(120000); // WDA startup timeout ms
- iosOptions.setSimulatorStartupTimeout(180000); // Simulator boot timeout
- iosOptions.setAutoAcceptAlerts(true); // Auto-dismiss iOS alerts
- iosOptions.setAutoDismissAlerts(false);
- iosOptions.setShowXcodeLog(false); // Suppress verbose Xcode logs
What is the difference between noReset, fullReset, and fastReset?
| Capability | noReset=true | noReset=false (default) | fullReset=true |
|---|---|---|---|
| App Install | Don't reinstall app | Reinstall if needed | Always uninstall + reinstall |
| App Data | Preserved between sessions | May be cleared | Always cleared |
| Speed | Fastest — no install | Moderate | Slowest |
| Use When | Tests that need existing login/data | Fresh start each test | Complete clean slate needed |
| Risk | Dirty state from previous test | Slower | Slowest, highest data loss |
How do you find the appPackage and appActivity of an Android app?
You need appPackage and appActivity to launch an already-installed Android app without providing an APK path.
METHOD 1 — ADB command (device must be running the app):
adb shell dumpsys window | grep -E 'mCurrentFocus|mFocusedApp'
Output: mCurrentFocus=Window{...com.amazon.mShop.android.shopping/com.amazon.mShop.android.activity.SplashActivity}
METHOD 2 — ADB for package list:
adb shell pm list packages | grep amazon
adb shell monkey -p com.amazon.mShop.android.shopping -c android.intent.category.LAUNCHER 1
METHOD 3 — Appium Inspector:
- Launch app manually → Open Inspector → Check 'App Package' and 'App Activity' fields
METHOD 4 — APK analyzer in Android Studio:
- Drag APK file into Android Studio → AndroidManifest.xml → find package and launcher activity
METHOD 5 — aapt tool:
- aapt dump badging app.apk | grep -E 'package|launchable-activity'
Mobile Locators
What are all the locator strategies available in Appium? Which is recommended?
Appium supports both standard Selenium locators and mobile-specific ones. Priority: accessibility id > id > -android uiautomator > xpath.
- 1. accessibility id (BEST): Maps to contentDescription on Android, accessibilityLabel on iOS
driver.findElement(AppiumBy.accessibilityId("Login Button"));
Works cross-platform! Same locator can work on both Android and iOS if labels match.
- 2. id (resource-id): Android resource ID in format 'com.package:id/elementId'
driver.findElement(AppiumBy.id("com.example.app:id/username"));
- 3. xpath: Slower but flexible. Use when no better option.
driver.findElement(AppiumBy.xpath("//android.widget.EditText[@text=\"Username\"]"));
- 4. className: Full Android/iOS class name
driver.findElement(AppiumBy.className("android.widget.EditText"));
- 5. -android uiautomator: Powerful Android-specific using UiSelector
driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().text(\"Login\")"));
- 6. -ios predicate string: iOS NSPredicate-based query
driver.findElement(AppiumBy.iOSNsPredicateString("name == \"Login\" AND type == \"XCUIElementTypeButton\""));
- 7. -ios class chain: Faster than predicate string for iOS
driver.findElement(AppiumBy.iOSClassChain("**/XCUIElementTypeButton[`name == \"Login\"`]"));
- 8. image: Locate by image file (requires Images plugin in Appium 2)
How do you use Appium Inspector to find element locators?
Appium Inspector is a GUI tool for inspecting mobile app elements and generating locators.
SETUP STEPS:
- 1. Start Appium Server: appium (in terminal)
- 2. Open Appium Inspector application
- 3. Enter Server URL: http://127.0.0.1:4723
- 4. Enter Desired Capabilities (JSON format with platformName, deviceName, appPackage, etc.)
- 5. Click 'Start Session'
USING INSPECTOR:
- Left panel: Live screenshot of device screen
- Center panel: Source XML tree — DOM of current screen
- Right panel: Element attributes (id, accessibility id, class, text, bounds)
FINDING LOCATORS:
- Click element in screenshot → Inspector highlights it in source tree
- Right panel shows: resource-id, content-desc, class, text, bounds
- Use resource-id as 'id' locator, content-desc as 'accessibility id'
- Inspector also shows suggested XPath — but prefer id/accessibility id
- RECORDING: Use the Record button to record interactions and generate code
- Supported actions: tap, swipe, type — generates Java/Python code automatically
How do you write UiAutomator selectors for complex Android element identification?
UiSelector (Android) provides the most powerful element identification for Android — faster than XPath.
Basic syntax: new UiSelector().<method>(<value>)
BY TEXT:
new UiSelector().text("Login") — exact text match
new UiSelector().textContains("Log") — partial text match
new UiSelector().textStartsWith("Log") — text starts with
new UiSelector().textMatches("Log.*") — regex match
BY RESOURCE ID:
new UiSelector().resourceId("com.example:id/loginBtn")
BY CLASS:
new UiSelector().className("android.widget.Button")
- BY DESCRIPTION (accessibility):
new UiSelector().description("Login Button")
- CHAINING (AND logic):
new UiSelector().className("android.widget.EditText").instance(0) — first EditText
new UiSelector().text("Submit").enabled(true) — enabled Submit button
SCROLLING TO ELEMENT:
new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().text("Item 50"))
- Usage in Appium:
driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().text(\"Login\")"));
Mobile Gestures
How do you perform tap, long press, swipe, and scroll in Appium 2?
Appium 2 recommends W3C Actions API and mobile: execute scripts over deprecated TouchAction.
// TAP using W3C Actions:
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence tap = new Sequence(finger, 1);
- tap.addAction(finger.createPointerMove(Duration.ZERO, PointerInput.Origin.viewport(), x, y));
- tap.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
- tap.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
driver.perform(Arrays.asList(tap));
// TAP on element (simpler):
driver.executeScript("mobile: clickGesture", ImmutableMap.of("elementId", element.getId()));
// LONG PRESS:
driver.executeScript("mobile: longClickGesture", ImmutableMap.of("elementId", el.getId(), "duration", 2000));
// SWIPE (right to left):
driver.executeScript("mobile: swipeGesture", ImmutableMap.of(
'left', 700, "top", 1000, "width", 600, "height", 100,
"direction", "left", "percent", 0.75));
// SCROLL to element:
driver.executeScript("mobile: scrollGesture", ImmutableMap.of(
'left', 100, "top", 100, "width", 900, "height", 1800,
"direction", "down", "percent", 1.0));
How do you swipe to find an element that is not on screen?
Scrolling to find elements is one of the most common mobile automation tasks.
METHOD 1 — Android UiScrollable (most reliable for Android):
String scrollQuery = "new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().text(\"Item Name\"))";
driver.findElement(AppiumBy.androidUIAutomator(scrollQuery));
METHOD 2 — mobile: scroll execute script (Appium 2, cross-platform):
driver.executeScript("mobile: scroll", ImmutableMap.of("direction", "down"));
// Repeat until element found
METHOD 3 — Swipe loop until element visible:
- while (!isElementVisible(locator)) {
swipeUp(); // custom swipe method
if (swipeCount++ > maxSwipes) throw new RuntimeException("Element not found after scrolling");
}
METHOD 4 — iOS: scroll to element:
driver.executeScript("mobile: scroll", ImmutableMap.of("element", elementId, "toVisible", true));
BEST PRACTICE: Use UiScrollable on Android when element text is known — fastest approach
- iOS: Use -ios predicate string with toVisible scroll — most reliable for iOS
How do you perform pinch and zoom gestures in Appium?
Pinch and zoom require multi-finger gestures using W3C Actions with two pointer inputs.
// PINCH OPEN (zoom in) using mobile: pinchOpenGesture:
driver.executeScript("mobile: pinchOpenGesture", ImmutableMap.of(
'left', 200, "top", 400, "width", 700, "height", 700,
"scale", 2.0, "velocity", 2.5));
// PINCH CLOSE (zoom out):
driver.executeScript("mobile: pinchCloseGesture", ImmutableMap.of(
'left', 200, "top", 400, "width", 700, "height", 700,
"scale", 0.5, "velocity", 2.5));
// W3C 2-finger approach:
PointerInput finger1 = new PointerInput(PointerInput.Kind.TOUCH, "finger1");
PointerInput finger2 = new PointerInput(PointerInput.Kind.TOUCH, "finger2");
// Move fingers apart for zoom, together for pinch
// Each finger is a separate Sequence — both performed simultaneously
- Parameters: scale > 1.0 = zoom in, scale < 1.0 = pinch/zoom out
- velocity: pixels per second for the gesture speed
- Coordinates refer to the area within which the gesture occurs
Handling Native App Elements
How do you handle Android permission dialogs in Appium?
Permission dialogs appear when app requests Camera, Location, Storage, etc. access.
METHOD 1 — Auto-grant (simplest, use in most tests):
options.setAutoGrantPermissions(true); // Capability — accepts all permissions automatically
METHOD 2 — Click Allow/Deny programmatically:
// Wait for permission dialog
- WebElement allowBtn = wait.until(ExpectedConditions.presenceOfElementLocated(
AppiumBy.id("com.android.permissioncontroller:id/permission_allow_button")));
- allowBtn.click();
METHOD 3 — ADB grant permission (no dialog shown):
driver.executeScript("mobile: shell", ImmutableMap.of(
"command", "pm grant com.example.app android.permission.CAMERA"));
METHOD 4 — UiAutomator selector for system dialog:
driver.findElement(AppiumBy.androidUIAutomator(
'new UiSelector().textContains("Allow"))).click();
iOS Permission dialogs:
options.setAutoAcceptAlerts(true); // Accept all iOS system alerts
Or handle manually: driver.switchTo().alert().accept();
Or use: driver.executeScript("mobile: alert", ImmutableMap.of("action", "accept"));
How do you handle Android Toast messages and Snackbars?
Toast messages are temporary popups that appear briefly. They are notoriously difficult to automate.
- TOAST MESSAGES (Android):
- Toasts appear for 2-3 seconds. Standard findElement() often misses them due to timing.
METHOD 1 — UiAutomator (most reliable):
WebElement toast = driver.findElement(AppiumBy.androidUIAutomator(
"new UiSelector().className(\"android.widget.Toast\")"));
- String toastText = toast.getText();
METHOD 2 — Accessibility ID or text match:
driver.findElement(AppiumBy.androidUIAutomator(
"new UiSelector().textContains(\"saved successfully\")"));
METHOD 3 — Logcat monitoring:
- Monitor device logs: adb logcat | grep Toast — capture toast text from logs
SNACKBARS:
- Snackbars have a longer display time (3-10 seconds) — easier to catch
driver.findElement(AppiumBy.id("com.google.android.material:id/snackbar_text"));
- Or by accessibility id if provided by developers
BEST PRACTICE: Ask developers to add testIds/accessibility labels to toasts for reliable testing
How do you handle device hardware keys and keyboard in Appium?
Appium provides methods to press hardware keys and manage the soft keyboard.
- HARDWARE KEYS (Android):
driver.pressKey(new KeyEvent(AndroidKey.BACK)); // Press Back button
driver.pressKey(new KeyEvent(AndroidKey.HOME)); // Press Home button
driver.pressKey(new KeyEvent(AndroidKey.APP_SWITCH)); // Recent apps
driver.pressKey(new KeyEvent(AndroidKey.ENTER));
driver.pressKey(new KeyEvent(AndroidKey.DELETE)); // Backspace
driver.pressKey(new KeyEvent(AndroidKey.VOLUME_UP));
KEYBOARD MANAGEMENT:
Show keyboard: driver.getKeyboard(); // Gets keyboard info if visible
Hide keyboard: driver.hideKeyboard();
Check if shown: driver.isKeyboardShown(); // Returns boolean
TYPE TEXT:
- element.sendKeys('Hello World'); // Types via Appium
driver.executeScript("mobile: type", ImmutableMap.of("text", "Hello")); // Faster
iOS Hardware simulation:
driver.executeScript("mobile: pressButton", ImmutableMap.of("name", "home"));
driver.executeScript("mobile: pressButton", ImmutableMap.of("name", "volumeup"));
Hybrid App Testing & Contexts
How do you automate hybrid apps in Appium? Explain context switching.
Hybrid apps have both native UI and WebView components. You must switch context to interact with each.
STEP 1 — Get available contexts:
Set<String> contexts = driver.getContextHandles();
// Output: [NATIVE_APP, WEBVIEW_com.example.app]
STEP 2 — Switch to WebView context:
driver.context("WEBVIEW_com.example.app");
// Now use Selenium-style locators for web content
driver.findElement(By.id("username")).sendKeys("admin");
driver.findElement(By.cssSelector(".login-btn")).click();
STEP 3 — Switch back to Native context:
driver.context("NATIVE_APP");
// Now use Appium mobile locators again
driver.findElement(AppiumBy.accessibilityId("Back")).click();
GET CURRENT CONTEXT:
String current = driver.getContext(); // Returns current context name
ANDROID REQUIREMENT for WebView debugging:
options.setChromedriverExecutableDir("/path/to/chromedriver/dir/");
- App must have: WebView.setWebContentsDebuggingEnabled(true); in source
iOS WebView: Uses Safari WebInspector — no special setup needed in Appium
How do you debug WebView content in hybrid apps?
Debugging WebView helps understand the DOM structure inside hybrid apps.
ANDROID — Chrome Remote Debugging:
- 1. Enable USB debugging on device
- 2. Open Chrome on desktop → chrome://inspect
- 3. Click 'inspect' next to your app's WebView
- 4. Full Chrome DevTools opens for WebView content
- 5. Use Elements tab to inspect DOM and test locators
- Requirement: WebView.setWebContentsDebuggingEnabled(true) in app source
iOS — Safari Web Inspector:
- 1. Enable Web Inspector: iOS Settings → Safari → Advanced → Web Inspector ON
- 2. Open Safari on Mac → Develop menu → [Device Name] → [WebView]
- 3. Full Web Inspector opens
TROUBLESHOOTING: If WEBVIEW context not visible:
- Check chromedriver version matches Chrome/WebView version on device
- Update chromedriver: appium driver update uiautomator2
- Add capability: chromedriverExecutableDir pointing to matching chromedriver folder
- Increase context switch wait time with setContext() retry loop
Test Framework Integration
How do you structure a TestNG + Appium project with proper setup and teardown?
Proper framework structure ensures clean test execution and reliable driver management.
// BaseTest.java
public class BaseTest {
protected AndroidDriver driver;
@BeforeClass
public void setUp() throws Exception {
UiAutomator2Options options = new UiAutomator2Options();
options.setDeviceName("emulator-5554");
options.setAppPackage("com.example.app");
options.setAppActivity("com.example.app.MainActivity");
options.setAutoGrantPermissions(true);
options.setNoReset(true);
driver = new AndroidDriver(new URL("http://127.0.0.1:4723"), options);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
}
@AfterClass
public void tearDown() {
if (driver != null) driver.quit();
}
}
// LoginTest.java
public class LoginTest extends BaseTest {
@Test
public void testValidLogin() {
driver.findElement(AppiumBy.id("com.example:id/username")).sendKeys("admin");
driver.findElement(AppiumBy.id("com.example:id/password")).sendKeys("pass");
driver.findElement(AppiumBy.id("com.example:id/loginBtn")).click();
Assert.assertTrue(driver.findElement(AppiumBy.accessibilityId("Dashboard")).isDisplayed());
}
}
How do you start and stop Appium server programmatically in Java?
Programmatic server management removes the need to manually start Appium before tests.
// AppiumServiceManager.java
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
AppiumDriverLocalService service = new AppiumServiceBuilder()
.withIPAddress("127.0.0.1")
.usingPort(4723)
.withArgument(GeneralServerFlag.SESSION_OVERRIDE) // Allow new session if one exists
.withArgument(GeneralServerFlag.LOG_LEVEL, "error") // Reduce log verbosity
.withLogFile(new File("appium-server.log"))
.build();
// Start in @BeforeSuite:
- service.start();
// Stop in @AfterSuite:
- if (service != null && service.isRunning()) service.stop();
// Use service URL for driver:
driver = new AndroidDriver(service.getUrl(), options);
BENEFIT: No manual Appium server needed. Server starts/stops with test suite automatically.
- Useful for CI/CD pipelines where no human starts the server.
FAQs
What should freshers prepare for an Appium interview?
Appium architecture and Appium 2 changes, capabilities, locator strategies and Appium Inspector, basic gestures with W3C actions, and how Appium fits with TestNG and Maven.