Skip to content

Instantly share code, notes, and snippets.

@lilinor
Created January 9, 2025 16:28
Show Gist options
  • Select an option

  • Save lilinor/b1d7f4c97fe38081084232efd3655557 to your computer and use it in GitHub Desktop.

Select an option

Save lilinor/b1d7f4c97fe38081084232efd3655557 to your computer and use it in GitHub Desktop.
# -*- 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment