Appium Concepts : How to Pull Folder Using Appium Built-In method during runtime(Complete Details)
.pullFolder(base64Data)

Get a step-by-step walkthrough in the video below!
Appium Built-In Method : — .pullFolder()
pullFolder()
is a method in the Appium client libraries (such as Java, Python, JavaScript) that allows you to retrieve an entire folder from an Android device or emulator and save it locally as a .zip
archive.
It is commonly used in automated testing to:
- Collect logs
- Retrieve screenshots or reports
- Verify files generated by the app
Basic Syntax:
.pullFolder(String remotePath)
remotePath: Destination path on the device (e.g., /sdcard/Download/file.txt)
Example: Java (Appium Java Client)
//.pullFolder(String remotepath)
//Pull sample.zip folder from test device & Saved as "downloaded_sample.zip" in our local machine
System.out.println("Pull sample.zip folder from test device & Saved as \"downloaded_sample.zip\" in our local machine");
byte[] pulledZipFolder=driver.pullFolder("/sdcard/download/sample.zip");
Files.write(Paths.get("downloaded_sample.zip"), pulledZipFolder);
System.out.println("Folder pulled from the device & Saved as downloaded_sample.zip ");
✅ Key Use Cases
- Download app-generated files for validation
- Collect test artifacts (e.g., screenshots, crash logs)
- Pull media folders, configs, or internal state files for inspection
- Debug app behavior during CI testing
“Complete Code: Optimized and Ready to Use”:
package com.appiumguide.appiumconcepts;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.options.UiAutomator2Options;
import java.io.IOException;
import java.net.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.Duration;
public class PullFolderDemo {
private AndroidDriver driver;
@BeforeTest
public void setup() throws MalformedURLException {
UiAutomator2Options cap=new UiAutomator2Options();
cap.setPlatformName("android");
cap.setAutomationName("uiautomator2");
cap.setDeviceName("Pixel8");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723"), cap);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(100));
}
@Test
public void test() throws InterruptedException, IOException {
//.pullFolder(String remotepath)
//Pull sample.zip folder from test device & Saved as "downloaded_sample.zip" in our local machine
System.out.println("Pull sample.zip folder from test device & Saved as \"downloaded_sample.zip\" in our local machine");
byte[] pulledZipFolder=driver.pullFolder("/sdcard/download/sample.zip");
Files.write(Paths.get("downloaded_sample.zip"), pulledZipFolder);
System.out.println("Folder pulled from the device & Saved as downloaded_sample.zip ");
}
@AfterTest
public void teardown() {
if(driver!=null) {
driver.quit();
System.out.println("Test Completed");
}
}
}
GitHub Link:
No comments:
Post a Comment