Thursday 20 May 2021

Python Appium - Procedure for Video/Screen Recording

 Why Screen/Video recording is required?

When there are complex test scenarios and if there is any failure it becomes easy to identify where exactly is the failure. As a tester point of view, it is always necessary to provide logs, video recording and screenshots (This may vary project to project). 

So let us start how to accommodate video recording in your appium framework.

Basically you would need three steps here,

1. start video recording

2. stop video recording

3. convert the captured video to mp3or mp4 format

So to record video you would need

driver.start_recording_screen()

To Stop video you would need to call

driver.start_recording_screen()

So here I will explain you with calculator example,

from appium import webdriver
from login import Login
import time
import os
import base64


def __init__(self, driver):
self.driver = driver

def test_calculator_click_number():
desired_caps = {
'platformName': 'android',
'udid': 'emulator-5556',
'deviceName': 'Pixel 2 API 28',
'platformVersion': '9.0',
'appPackage': 'com.android.calculator2',
'appActivity': 'com.android.calculator2.Calculator'
}
driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
driver.start_recording_screen()
login = Login(driver)
login.login_in_to_app()
video_rawdata = driver.stop_recording_screen()
video_name = driver.current_activity + time.strftime("%Y_%m_%d_%H%M%S")
filepath = os.path.join("C:/Data/2021/May/Sample/", video_name+".mp4")


with open(filepath,"wb+") as vd:
vd.write(base64.b64decode(video_rawdata))


Here whatever video has been recorded is stored in video_rawdata variable. Later at this point

with open(filepath,"wb+") as vd:
vd.write(base64.b64decode(video_rawdata))

It is been converted. In below code, video_name is the variable with current activity name and current time of video recording

video_name = driver.current_activity + time.strftime("%Y_%m_%d_%H%M%S")

In below code snippet we have stored the video at specified location

filepath = os.path.join("C:/Data/2021/May/Sample/", video_name+".mp4")


4 comments:

  1. It seems that the Java VM is getting more and more competition from other virtual machine applications such as .NET Core and LLVM. This makes me wonder if Java can continue to compete as a corporate product in a World where alternatives are community-controlled. There are a variety of intriguing Java innovations, however. But any development that is made specifically for Java can be modified for different platforms. Therefore, it's impossible to determine exactly how the Java platform will develop.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. McAfee products safeguard the computers against viruses and other malicious programs. All McAfee products must be activated using a unique key in order to prevent illegal distribution of its software. You can download updates or reinstall your McAfee product from the McAfee website after you've activated it. You can now activate your McAfee in three easy steps by entering the product key at
    www.mcafee.com/activate_my_account

    ReplyDelete


  4. Venmo is a mobile digital payment service and social app that is owned by PayPal. The Venmo app makes it simple to communicate with friends and transfer and receive money. What started as a text-messaging network has evolved into a digital wallet software with over 60 million users, including the Venmo Visa credit card and Venmo Mastercard debit card.
    Read more at: activate venmo card

    ReplyDelete

Feature Posts

Python Appium - Step by step procedure for capturing screenshot

 Why To capture screenshot? It is as important as your logs. If there is any failure for any test scenario, we can provide screenshot for th...