Repository navigation
Expand file tree
/
Copy pathBaseRunner.py
More file actions
74 lines (63 loc) · 2.52 KB
/
Copy pathBaseRunner.py
File metadata and controls
74 lines (63 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
from Base.BaseLog import myLog
from Base.BaseIosLog import myIosLog
import unittest
from appium import webdriver
import os
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
def appium_testcase(devices):
desired_caps = {}
if str(devices["platformName"]).lower() == "android":
desired_caps["systemPort"] = devices["systemPort"]
desired_caps["unicodeKeyboard"] = "True"
desired_caps["resetKeyboard"] = "True"
elif str(devices["platformName"]) == "iOS":
desired_caps['bundleId'] = devices["bundleId"]
desired_caps['xcodeOrgId'] = "BMP99N9345"
desired_caps['xcodeSigningId'] = "iPhone Developer"
desired_caps['autoLaunch'] = True
desired_caps['udid'] = devices["udid"]
desired_caps['app'] = devices["app"]
desired_caps['deviceName'] = devices["deviceName"]
desired_caps['platformVersion'] = devices["platformVersion"]
desired_caps['platformName'] = devices["platformName"]
desired_caps["automationName"] = devices['automationName']
desired_caps["noReset"] = "True"
desired_caps['noSign'] = "True"
remote = "http://127.0.0.1:" + str(devices["port"]) + "/wd/hub"
driver = webdriver.Remote(remote, desired_caps)
return driver
class ParametrizedTestCase(unittest.TestCase):
""" TestCase classes that want to be parametrized should
inherit from this class.
"""
def __init__(self, methodName='runTest', param=None):
super(ParametrizedTestCase, self).__init__(methodName)
global devicess
devicess = param
@classmethod
def setUpClass(cls):
pass
cls.driver = appium_testcase(devicess)
cls.platformName = devicess["platformName"]
cls.udid = devicess["udid"]
if cls.platformName == 'android':
cls.platformName = 'android'
cls.logTest = myLog().getLog(cls.udid) # 每个设备实例化一个日志记录器
elif cls.platformName == 'iOS':
cls.platformName = 'iOS'
cls.logTest = myIosLog().getLog(cls.udid) # 每个设备实例化一个日志记录器
@classmethod
def tearDownClass(cls):
pass
cls.driver.close_app()
@staticmethod
def parametrize(testcase_klass, param=None):
testloader = unittest.TestLoader()
testnames = testloader.getTestCaseNames(testcase_klass)
suite = unittest.TestSuite()
for name in testnames:
suite.addTest(testcase_klass(name, param=param))
return suite