Пример #1
0
    def android_driver(self, i):
        # devicename
        # port
        print("this is android_driver", i)
        write_file = WriteUserCommand()
        device = write_file.get_value('user_info_' + str(i), 'deviceName')
        port = write_file.get_value('user_info_' + str(i), 'port')

        capabilities = {
            "platformName": "Android",
            # "automationName": "UiAutomator2",
            # 'platformVersion': deviceVersion,
            "deviceName": device,
            "app": "D:\\appsfortest\\mukewang.apk",
            # "dontStopAppOnReset": "True",  # 不关闭应用???没试过
            # "autoGrantPermissions": "True",  # 自动获取权限???没试过
            # "udid": "70643e56c1b0f3c3132c44c87e433a48b5531ee6",
            # "appPackage": "cn.com.open.mooc",   # 很奇怪,模擬器不行
            # "appWaitActivity": "cn.com.open.mooc.user.login.MCLoginActivity",
            # 'appActivity': appPackage + ".PageSplash",
            # "recreateChromeDriverSessions": "true",
            "noReset": "True"  # 不用每次重置
        }

        driver = webdriver.Remote("http://127.0.0.1:" + str(port) + "/wd/hub", capabilities)
        time.sleep(10)
        return driver
Пример #2
0
    def android_driver(self, i):

        # print("this is android_driver:",i)
        write_file = WriteUserCommand()
        devices = write_file.get_value('user_info_' + str(i), 'deviceName')
        port = write_file.get_value('user_info_' + str(i), 'port')
        # platformVersion = self.cmd.excute_cmd_result('adb shell getprop ro.build.version.release')[0].strip() #获取Android版本
        # pack = self.cmd.excute_cmd_result('aapt dump badging ' + APP_PATH) #获取apppackage
        # appPackage = re.findall(r'\'com\w*.*?\'', pack[0])[0]

        dic = {
            'platformName': 'Android',
            'platformVersion': '5.0',
            'deviceName': '192.168.218.101:5555',
            'appPackage': 'com.aetos',
            'appActivity': 'com.aetos.ui.module.core.LoadingActivity',
            'app': APP_PATH,
            'noReset': 'true',
            # 'noSign': 'true',
            #'automationName': 'selendroid'        #'uiautomator2'
        }
        driver = webdriver.Remote('http://127.0.0.1:' + '4723' + '/wd/hub',
                                  dic)
        driver.implicitly_wait(20)

        return driver
def get_suite(i):
    print("get_suite里的", i)
    suite = unittest.TestSuite()
    suite.addTest(CaseTest("test_01", param=i))
    suite.addTest(CaseTest("test_02", param=i))
    suite.addTest(CaseTest("test_03", param=i))
    # unittest.TextTestRunner().run(suite)

    write_file = WriteUserCommand()
    device = write_file.get_value('user_info_' + str(i), 'deviceName')
    html_file = "../report/testReport" + str(i) + ".html"
    with open(html_file, "wb") as fp:
        HTMLTestRunner.HTMLTestRunner(stream=fp,
                                      title="自动化测试",
                                      description=device +
                                      "的自动化测试结果").run(suite)
Пример #4
0
def get_suite(i):
    # test_dir = '../Case/'  # ./ 表示当前目录
    # test_report = '../report/'  # ../表示上一目录
    # suite = unittest.defaultTestLoader.discover(test_dir, pattern='test_*.py', top_level_dir=None)

    suite = unittest.TestSuite()

    suite.addTest(ParametrizedTestCase.parametrize(test_case.CaseTest,
                                                   param=i))
    suite.addTest(
        ParametrizedTestCase.parametrize(test_case2.CaseTest, param=i))
    print("this is suite", suite)
    now = time.strftime('%Y-%m-%d %H_%M_%S')
    write_file = WriteUserCommand()
    device = write_file.get_value('user_info_' + str(i), 'deviceName')
    html_file = "../report/testReport" + str(i) + now + ".html"
    with open(html_file, "wb") as fp:
        HTMLTestRunner.HTMLTestRunner(stream=fp,
                                      title="自动化测试",
                                      description=device +
                                      "的自动化测试结果").run(suite)
Пример #5
0
def get_suite(i):
    # test_dir = '../Case/'  # ./ 表示当前目录
    # test_report = '../report/'  # ../表示上一目录
    # suite = unittest.defaultTestLoader.discover(test_dir, pattern='test_*.py', top_level_dir=None)

    suite = unittest.TestSuite()
    # myLists = [eval("test_case.CaseTest"), eval("test_case1.CaseTest")]
    # # suite.addTest(ParametrizedTestCase.parametrize(test_case.CaseTest, param=i))
    # for myList in myLists:
    #     suite.addTest(ParametrizedTestCase.parametrize(myList, param=i))
    myLists = GetSuiteList().get_list()
    for myList in myLists:
        suite.addTest(ParametrizedTestCase.parametrize(eval(myList), param=i))
    now = time.strftime('%Y-%m-%d %H_%M_%S')
    write_file = WriteUserCommand()
    device = write_file.get_value('user_info_' + str(i), 'deviceName')
    html_file = "./report/testReport" + '_deviceNum-' + str(
        i) + "-" + now + ".html"
    with open(html_file, "wb") as fp:
        HTMLTestRunner.HTMLTestRunner(stream=fp,
                                      title="自动化测试",
                                      description=device +
                                      "的自动化测试结果").run(suite)