我是比利时的一个计算机科学学生,从事一个项目,涉及simultaneously 控制来自Avry script的多安装置。 在测试期间,我在执行有效的多管齐下演播室宣传器方面遇到挑战,我早就利用这些宣传器,然后再与实际装置连接。 我曾探讨过像 App和 Sel服务器等解决办法,但找到与我的需求相匹配的明确信息和直截了当的工作流程证明是困难的。
I attempted using ADB and Appium, but could only control one phone at a time. My experiments with Appium and Selenium server have been challenging, and I’m struggling to find clear information or simple workflows for this task.
这种情况阻止了我的进展,我欢迎任何建议或建议,这些建议或建议可以简化同时通过沙尔控制安乐团的进程。 每一执行者不应履行同样的任务;他们应当遵循由斯图尔特概述的程序途径。 我愿意彻底改变我努力执行的工作流程。
Below is my attempt to retrieve connected devices using ADB and an initial try to launch Appium servers for each device:
# Function to get connected devices
def get_connected_devices():
devices_configs = []
try:
output = subprocess.check_output([adb_path, devices ]).decode( utf-8 )
devices = output.strip().split(
)[1:]
for device in devices:
ud_id = device.split( )[0]
os_version = (
subprocess.check_output(
[
adb_path,
-s ,
ud_id,
shell ,
getprop ,
ro.build.version.release ,
]
)
.decode( utf-8 )
.strip()
)
platform = "Android"
system_port = str(8200 + len(devices_configs))
chrome_driver_port = str(8100 + len(devices_configs))
device_details = {
"device": ud_id,
"os_version": os_version,
"ud_id": ud_id,
"platform": platform,
"systemPort": system_port,
}
devices_configs.append(device_details)
return devices_configs
except subprocess.CalledProcessError as e:
print(f"Error executing ADB command: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
# Retrieve connected devices
connected_devices = get_connected_devices()
# Start Appium servers for each device
processes = []
for i in range(len(connected_devices)):
port = 4724 + i
cmd = ["start", "appium", "-p", str(port)]
process = subprocess.Popen(cmd, shell=True)
processes.append(process)
尽管如此,我还是遇到了强迫使用特定装置港口的问题,因为它把同一港口用于所有装置:
# Pair each connected device with a server
device_server_pairs = list(zip(connected_devices, servers))
# Start Appium sessions using threads
with concurrent.futures.ThreadPoolExecutor() as executor:
executor.map(start_appium_session, device_server_pairs)
# Function to start Appium session for each device
def start_appium_session(device_config_server_tuple):
device_config, server = device_config_server_tuple
capabilities = {
platformName : device_config[ platform ],
platformVersion : device_config[ os_version ],
deviceName : device_config[ ud_id ],
systemPort : device_config[ systemPort ],
app : APP_PATH,
}
driver = webdriver.Remote(server, options=UiAutomator2Options().load_capabilities(capabilities))
I appreciate any insights or improvements you could provide.