buttons

[appium-device-farm-12] — Complete Details on Enable/Disable “Video Recording” option for the Session

 

[appium-device-farm-12] — Complete Details on Enable/Disable “Video Recording” option for the Session

Get a step-by-step walkthrough in the video below!

Appium Device Farm offers a powerful feature set to enhance debugging and monitoring of your test runs. One such feature is Video Recording — it allows you to record the screen of the device throughout the session, which is extremely useful for playback and debugging.

This article provides complete details on how to enable or disable the video recording feature in Appium Device Farm sessions.

What is Video Recording in Appium Device Farm?

The video recording feature captures a full video of the test session on the connected device. This can be helpful for:

  • Test debugging
  • Visual validation
  • Reviewing failed test cases

By default, video recording may be disabled, but Appium Device Farm gives you full control over this through session configuration.

How to Enable/Disable Video Recording

You can control this feature via capabilities or configuration settings.

Enable/Disable Live Streaming Per Session (via Desired Capabilities)

Appium Device Farm accepts a custom capability:

// To enable & disable video recording under appium-device-farm

//cap.setCapability("df:recordVideo", false); //To disable video recording ///Default is disabled i.e false

cap.setCapability("df:recordVideo", true); //To enable video recording

// To set video recording time limit

cap.setCapability("df:videoTimeLimit", "2400"); //To specify the video time limit to 4 minutes //Default Video Time Limit is 1800 seconds (3 Mins)

Default Value for Video Recording: Is Always False

//Default is disabled i.e false

To enable for a specific session:

// To enable & disable video recording under appium-device-farm

cap.setCapability("df:recordVideo", true); //To enable video recording

Example:

Press enter or click to view image in full size

To disable for a specific session:

//To Disable Video Recording in Device Farm

cap.setCapability("df:recordVideo", false);

Example:

Observe that “Video recording not available” message will be displayed under the Builds Tab.

Press enter or click to view image in full size

Java Example:

 @BeforeClass
public void setup() throws MalformedURLException {
UiAutomator2Options cap=new UiAutomator2Options();
cap.setPlatformName("android");
cap.setAutomationName("uiautomator2");
cap.setDeviceName("Pixel9");

// To enable & disable video recording under appium-device-farm

//cap.setCapability("df:recordVideo", false); //To disable video recording ///Default is disabled i.e false

cap.setCapability("df:recordVideo", true); //To enable video recording

// To set video recording time limit

cap.setCapability("df:videoTimeLimit", "2400"); //To specify the video time limit to 4 minutes //Default Video Time Limit is 1800 seconds (3 Mins)


driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
}

JSON (Static Config)

For server config (appium.config.json or programmatic):

{
"server": {
"port": 4723,
"plugin": {
"device-farm": {
"df:recordVideo": true // or false
"df:videoTimeLimit": 2400 //Default Video Time Limit is 1800 seconds (3 Mins)
}
}
}
}

Where to View the Record Videos?

When enabled, the Video Record is accessible through the Device Farm Dashboard UI in the session window.

Device-Farm Dashboard →Builds

Example:

Press enter or click to view image in full size

Click Maximize: To view Recorded Video in full scream

Press enter or click to view image in full size

It provides options , when user clicks on the 3 dots.

Press enter or click to view image in full size

Troubleshooting Tips

  1. Stream not showing up?
  • Check FFmpeg path and installation.
  • Ensure the device screen is active (not locked).

2. Stream is blank or lagging?

  • Device resolution or encoding issues — try reducing resolution.
  • Use wired connections for physical devices (not Wi-Fi only

3. Can’t find video stream URL?

  • Make sure the Appium session is initialized and streaming is enabled at either global or session level.

“Complete Code: Optimized and Ready to Use”:

package com.appiumguide.devicefarm;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebElement;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import io.appium.java_client.AppiumBy;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.options.UiAutomator2Options;
import java.net.*;
import java.time.Duration;

/**
* Script Details - "appium-device-farm”- Complete Details on Enable/Disable “live video Streaming” for the Session Under “Appium Device Farm”
*
* appium-java-client version: 9.5.0
*
* @author 'Ramesh Kodumuru' for AppiumGuide [appiumguide@gmail.com]
*/


public class devicefarm_VideoRecordingDemo {

private AndroidDriver driver;

WebElement dragelement,dropelement;

@BeforeClass
public void setup() throws MalformedURLException {
UiAutomator2Options cap=new UiAutomator2Options();
cap.setPlatformName("android");
cap.setAutomationName("uiautomator2");
cap.setDeviceName("Pixel9");

// To enable & disable video recording under appium-device-farm

//cap.setCapability("df:recordVideo", false); //To disable video recording ///Default is disabled i.e false

cap.setCapability("df:recordVideo", true); //To enable video recording

// To set video recording time limit

cap.setCapability("df:videoTimeLimit", "2400"); //To specify the video time limit to 4 minutes //Default Video Time Limit is 1800 seconds (3 Mins)


driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
}

@Test
public void test1() throws InterruptedException {

driver.activateApp("com.wdiodemoapp");

Thread.sleep(5000);

driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().text(\"Drag\")")).click();



dragelement=driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().className(\"android.widget.ImageView\").instance(4)"));

dropelement=driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().className(\"android.view.ViewGroup\").instance(10)"));

int eX=(int)(dropelement.getRect().getX());
int eY=(int)(dropelement.getRect().getY());

//Perform Drag gesture based on element id, endX & endY co-ordinates
System.out.println("Perform Drag gesture based on element id, endX & endY co-ordinates");
((JavascriptExecutor) driver).executeScript("mobile: dragGesture",ImmutableMap.of("elementId",((RemoteWebElement) dragelement).getId(),
"endX",eX,
"endY",eY));

Thread.sleep(3000);
dragelement=driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().className(\"android.widget.ImageView\").instance(7)"));

int sX=(int)(dragelement.getRect().getX());
int sY=(int)(dragelement.getRect().getY());

dropelement=driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().className(\"android.view.ViewGroup\").instance(8)"));

int eX1=(int)(dropelement.getRect().getX());
int eY1=(int)(dropelement.getRect().getY());

//Perform Drag gesture based on element id, startX,startY,endX & endY co-ordinates
System.out.println("Perform Drag gesture based on element id, startX,startY,endX & endY co-ordinates");

((JavascriptExecutor) driver).executeScript("mobile: dragGesture",ImmutableMap.of(
"startX",sX,
"startY",sY,
"endX",eX1,
"endY",eY1));

Thread.sleep(3000);

////Perform Drag gesture based on element id,endX,endY co-ordinates and Speed

dragelement=driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().className(\"android.widget.ImageView\").instance(1)"));

dropelement=driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().className(\"android.view.ViewGroup\").instance(10)"));

int eX2=(int)(dropelement.getRect().getX());
int eY2=(int)(dropelement.getRect().getY());

int speedvalue=(int)(100*2.625);
System.out.println("Perform Drag gesture based on element id,endX,endY co-ordinates and Speed");

((JavascriptExecutor) driver).executeScript("mobile: dragGesture",ImmutableMap.of("elementId",((RemoteWebElement) dragelement).getId(),
"endX",eX2,
"endY",eY2,
"speed",speedvalue));

Thread.sleep(3000);

}

@AfterClass
public void teardown() {

if(driver!=null) {
driver.quit();
System.out.println("Test Execution Completed");

}

}

}

No comments:

Post a Comment