forked from yanchunhuo/AutomationTest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57c40bf
commit 8768f7c
Showing
14 changed files
with
298 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# 作者 yanchunhuo | ||
# 创建时间 2019/12/26 11:15 | ||
# github https://github.com/yanchunhuo | ||
from pojo.app_ui_devices_info import APP_UI_Devices_Info | ||
import configparser as ConfigParser | ||
import os | ||
|
||
class Read_APP_UI_Devices_Info(object): | ||
__instance=None | ||
__inited=None | ||
|
||
def __new__(cls, *args, **kwargs): | ||
if cls.__instance is None: | ||
cls.__instance=object.__new__(cls) | ||
return cls.__instance | ||
|
||
def __init__(self,filepath): | ||
if self.__inited is None: | ||
self.devices_info=self._read_devices_info(filepath) | ||
self.__inited=True | ||
|
||
def _read_devices_info(self, filepath): | ||
config = ConfigParser.ConfigParser() | ||
config.read(filepath,encoding='utf-8') | ||
devices_info = APP_UI_Devices_Info() | ||
get_lambda=lambda info:list(filter(None,info.split('||'))) if info else [] | ||
devices_info.devices_desc=get_lambda(config.get('devices_info','devices_desc',fallback='')) | ||
devices_info.server_ports=get_lambda(config.get('devices_info','server_ports',fallback='')) | ||
devices_info.server_ips = get_lambda(config.get('devices_info', 'server_ips', fallback='')) | ||
devices_info.udids=get_lambda(config.get('devices_info','udids',fallback='')) | ||
devices_info.platformNames = get_lambda(config.get('devices_info', 'platformNames',fallback='')) | ||
devices_info.automationNames = get_lambda(config.get('devices_info', 'automationNames', fallback='')) | ||
devices_info.platformVersions = get_lambda(config.get('devices_info', 'platformVersions', fallback='')) | ||
devices_info.deviceNames = get_lambda(config.get('devices_info', 'deviceNames', fallback='')) | ||
devices_info.chromeDriverPorts = get_lambda(config.get('devices_info', 'chromeDriverPorts', fallback='')) | ||
devices_info.chromeDriverPorts = get_lambda(config.get('devices_info', 'chromeDriverPorts', fallback='')) | ||
devices_info.systemports=get_lambda(config.get('devices_info','systemports', fallback='')) | ||
devices_info.wdaLocalPorts = get_lambda(config.get('devices_info', 'wdaLocalPorts', fallback='')) | ||
devices_info.wdaLocalPorts = get_lambda(config.get('devices_info', 'wdaLocalPorts', fallback='')) | ||
devices_info.appActivity = config.get('devices_info','appActivity') | ||
devices_info.appPackage = config.get('devices_info','appPackage') | ||
devices_info.app = config.get('devices_info','app') | ||
# 将安装包所在位置转为绝对路径 | ||
if devices_info.app: | ||
devices_info.app = os.path.abspath(devices_info.app) | ||
return devices_info.get_devices_info() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[appium_server] | ||
appium_hub = http://172.16.52.203:4723/wd/hub | ||
|
||
[test] | ||
# 最大设备池,当实际测试设备数大于此配置,会等待池中有空闲设备才进行测试 | ||
max_device_pool = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[devices_info] | ||
### 本配置支持多设备并行,请使用||分割每一项 | ||
|
||
# 使用文件创建允许的字符,确保每个设备唯一 | ||
devices_desc = xiaomi || | ||
|
||
# 设备id | ||
udids = 127.0.0.1:7555 || | ||
|
||
# 平台名称 | ||
platformNames = Android || | ||
|
||
# andorid4.2及以上使用的是UiAutomator和UiAutomator2 | ||
# android5.0及以上才能使用UiAutomator2 | ||
# 如果要使用UiAutomator2,则设置automationName=UIAutomator2,不使用则放空 | ||
automationNames = UiAutomator2 || | ||
|
||
# 系统版本 | ||
platformVersions = 6.0.1 || | ||
|
||
# Android此参数会被忽略 | ||
deviceNames = Android Emulator || | ||
|
||
# appium 的server ip | ||
server_ips = 172.16.52.203 || | ||
|
||
# appium 的server port,并行设备都在同一个appium server上时确保每个设备唯一 | ||
server_ports = 4723 || | ||
|
||
# chromeDriver端口,端口建议从6200开始,并行设备都在同一个appium server上时确保每个设备唯一 | ||
chromeDriverPorts = 5200 || | ||
|
||
# systemport,如果使用UiAutomator2;端口范围为8200~8299,使用espresso,端口范围为8300~8399;并行设备都在同一个appium server上时确保每个设备唯一 | ||
systemports = 8200 || | ||
|
||
# ios并行测试使用,端口建议从5400开始,不用可注释,并行设备都在同一个appium server上时确保每个设备唯一 | ||
# wdaLocalPorts = 5400|| | ||
|
||
# appActivity、appPackage和app(安装包路径)两者选一,不选的放空,多设备仅需填写一个 | ||
# 查看当前应用的的appActivity、appPackage | ||
appPackage = com.moji.mjweather | ||
appActivity = com.moji.mjweather.MainActivity | ||
app = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[devices_info] | ||
### 本配置支持多设备并行,请使用||分割每一项 | ||
|
||
# 使用文件创建允许的字符,确保每个设备唯一 | ||
devices_desc = xiaomi || | ||
|
||
# 设备id | ||
udids = 127.0.0.1:7555 || | ||
|
||
# 平台名称 | ||
platformNames = Android || | ||
|
||
# andorid4.2及以上使用的是UiAutomator和UiAutomator2 | ||
# android5.0及以上才能使用UiAutomator2 | ||
# 如果要使用UiAutomator2,则设置automationName=UIAutomator2,不使用则放空 | ||
automationNames = UiAutomator2 || | ||
|
||
# 系统版本 | ||
platformVersions = 6.0.1 || | ||
|
||
# Android此参数会被忽略 | ||
deviceNames = Android Emulator || | ||
|
||
# appium 的server ip | ||
server_ips = 172.16.52.203 || | ||
|
||
# appium 的server port,并行设备都在同一个appium server上时确保每个设备唯一 | ||
server_ports = 4723 || | ||
|
||
# chromeDriver端口,端口建议从6200开始,并行设备都在同一个appium server上时确保每个设备唯一 | ||
chromeDriverPorts = 5200 || | ||
|
||
# systemport,如果使用UiAutomator2;端口范围为8200~8299,使用espresso,端口范围为8300~8399;并行设备都在同一个appium server上时确保每个设备唯一 | ||
systemports = 8200 || | ||
|
||
# ios并行测试使用,端口建议从5400开始,不用可注释,并行设备都在同一个appium server上时确保每个设备唯一 | ||
# wdaLocalPorts = 5400|| | ||
|
||
# appActivity、appPackage和app(安装包路径)两者选一,不选的放空,多设备仅需填写一个 | ||
# 查看当前应用的的appActivity、appPackage | ||
appPackage = com.moji.mjweather | ||
appActivity = com.moji.mjweather.MainActivity | ||
app = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 作者 yanchunhuo | ||
# 创建时间 2019/12/26 9:17 | ||
# github https://github.com/yanchunhuo | ||
|
||
class APP_UI_Devices_Info: | ||
def __init__(self): | ||
self.devices_desc = [] | ||
self.server_ports = [] | ||
self.server_ips = [] | ||
self.udids = [] | ||
self.platformNames = [] | ||
self.automationNames = [] | ||
self.platformVersions = [] | ||
self.deviceNames = [] | ||
self.chromeDriverPorts = [] | ||
self.systemports = [] | ||
self.wdaLocalPorts = [] | ||
self.appPackage = None | ||
self.appActivity = None | ||
self.app = None | ||
|
||
def get_devices_info(self): | ||
devices_info = [] | ||
for i in range(len(self.devices_desc)): | ||
device_info={} | ||
device_info.update({'device_desc':self.devices_desc[i].strip()}) | ||
device_info.update({'server_port':self.server_ports[i].strip()}) | ||
device_info.update({'server_ip':self.server_ips[i].strip()}) | ||
# 构建desired_capabilities | ||
desired_capabilities={} | ||
desired_capabilities.update({'udid':self.udids[i].strip()}) | ||
desired_capabilities.update({'platformName': self.platformNames[i].strip()}) | ||
if len(self.automationNames): | ||
desired_capabilities.update({'automationName': self.automationNames[i].strip()}) | ||
desired_capabilities.update({'platformVersion': self.platformVersions[i].strip()}) | ||
if len(self.deviceNames): | ||
desired_capabilities.update({'deviceName': self.deviceNames[i].strip()}) | ||
desired_capabilities.update({'chromeDriverPort':self.chromeDriverPorts[i].strip()}) | ||
desired_capabilities.update({'systemport': self.systemports[i].strip()}) | ||
if len(self.wdaLocalPorts): | ||
desired_capabilities.update({'wdaLocalPort': self.wdaLocalPorts[i].strip()}) | ||
if self.appActivity and self.appPackage: | ||
desired_capabilities.update({'appActivity': self.appActivity.strip()}) | ||
desired_capabilities.update({'appPackage': self.appPackage.strip()}) | ||
if self.app: | ||
desired_capabilities.update({'app': self.app.strip()}) | ||
device_info.update({'capabilities':desired_capabilities}) | ||
# 完成一台设备构建 | ||
devices_info.append(device_info) | ||
return devices_info |
Oops, something went wrong.