如何连接使用AndroidViewClient多个设备 [英] how to connect multiple devices using AndroidViewClient

查看:1092
本文介绍了如何连接使用AndroidViewClient多个设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要连接到使用AndroidViewclient自动化测试用例,在这里我不得不作出从设备1通话和接收设备2的呼叫的两个多台设备(设备1,设备2)。请帮助如何同时连接到两个设备。

i want to connect to two multiple devices (device1,device2) using AndroidViewclient for automating a test case , where i have to make a call from device1 and receive the call on device2 . Please help how to connect to two devices simultaneously .

推荐答案

库莱布拉现在支持的多设备的模式,所以在这个答案中描述的步骤是没有存在的必要。说明,例如视频显示了同样的测试在3个不同的设备同时​​运行可以的的android:库莱布拉多设备功能

Update

culebra now supports multi-device mode so the steps described in this answer are no longer necessary. Description, example and video showing the same test running concurrently on 3 different devices can be found at android: culebra multi-device capabilities.

一如往常。我的建议是让 库莱布拉 创建脚本,然后你能适应它。
库莱布拉会生成一个脚本,一台设备,那么你可以复制线为别的,或者如果有需要,你可以遍历设备列表。

As always. my recommendation is to let culebra create your script and then you can adapt it. culebra will generate a script for one device, then you can replicate the lines for the other, or you can iterate over a list of devices if the need arises.

下面是生成的修改后的脚本(替代的 serialno1 的和的 serialno2 的你的设备的实际序列号):

Here is a modified script generated by (replace serialno1 and serialno2 by actual serial numbers of your devices):

$ culebra -VC -d on -t on -o myscript.py serialno1

myscript.py 是这样的修改后:

#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013  Diego Torres Milano
Created on 2013-11-28 by Culebra v4.5.2

                      __    __    __    __
                     /  \  /  \  /  \  /  \ 
____________________/  __\/  __\/  __\/  __\_____________________________
___________________/  /__/  /__/  /__/  /________________________________
                   | / \   / \   / \   / \   \___
                   |/   \_/   \_/   \_/   \    o \ 
                                           \_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''


import re
import sys
import os


try:
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.viewclient import ViewClient


kwargs1 = {'verbose': True, 'ignoresecuredevice': False}
device1, serialno1 = ViewClient.connectToDeviceOrExit(serialno='serialno1', **kwargs1)
device2, serialno2 = ViewClient.connectToDeviceOrExit(serialno='serialno2', **kwargs1)
kwargs2 = {'startviewserver': True, 'forceviewserveruse': False, 'autodump': False, 'ignoreuiautomatorkilled': True}
vc1 = ViewClient(device1, serialno1, **kwargs2)
vc2 = ViewClient(device2, serialno2, **kwargs2)
vc1.dump(window='-1')
vc2.dump(window='-1')

no_id1_1 = vc1.findViewById("id/no_id/1")
print no_id1_1
no_id1_2 = vc2.findViewById("id/no_id/1")
print no_id1_2

这将连接到两个设备同时,获得转储,并找到ID为视图 ID / no_id两个/ 1 和打印结果。

This will connect to both devices concurrently, obtain the dumps, and find a View with id id/no_id/1 on both and print the result.

这篇关于如何连接使用AndroidViewClient多个设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆