Parallel tests with Appium and Genymotion Device Image

Date: 2024-04-23

Prerequisite

Start Appium server

Write your tests script in Python

# -*- coding: utf-8 -*-
import pytest
from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from appium.options.android import UiAutomator2Options
def create_android_driver(udid, systemPort):
# Setting capabilities directly on the options object
capabilities = {
"appium:deviceName": "Genymotion Cloud PaaS",
"platformName": "Android",
"automationName": "UiAutomator2",
"appium:udid": udid,
"appium:systemPort": systemPort,
"appium:appPackage": "com.android.settings",
"appium:appActivity": ".Settings"
}
url = "http://localhost:4723"
options = UiAutomator2Options()
options.load_capabilities(capabilities)
driver = webdriver.Remote(url, options=options)
# Return the driver
return driver
@pytest.mark.parametrize(
"udid, systemPort",
[
("[instance1_ip]:5555", "8201"),
("[instance2_ip]:5555", "8202"),
("[instance3_ip]:5555", "8203"),
],
)
def test_sum(udid, systemPort): # Accept udid and systemPort as parameters
driver = create_android_driver(udid, systemPort)
try:
driver.find_element(by=AppiumBy.XPATH, value='//*[@text="Battery"]')
finally:
# Ensure proper teardown
driver.quit()

How to run Python tests in parallel

How to run Java tests in parallel

[End of content]