Beispiel #1
0
    def test_app_api(self):
        datafilepath=dataDir
        
        listname=[]
        FileUtil.listdir(datafilepath,listname,'_result')

        for file_name in listname:        
            file_name_result=file_name.split('.')[0]+'_result.xls'
            print(file_name,file_name_result)
            if os.path.exists(file_name_result):
                os.remove(file_name_result)

            srcfile=file_name
            desfile=file_name_result


            #调用
            def run(line):
                if line[3]=='post':
                    Http.api_request('post',line[4],line[5])
                    return
                if line[3]=='get':
                    Http.api_request('get',line[4],line[5])
                    return
                if line[3]=='put':
                    Http.api_request('put',line[4],line[5])
                    return
                    return
                if line[3]=='delete':
                    Http.api_request('delete',line[4],line[5])
                    return
                if line[3]=='addheader':
                    Http.add_header(line[4],line[5])
                    return
                if line[3]=='assertequals':
                    Http.assert_equals(line[4],line[5])
                    return
                if line[3]=='savejson':
                    Http.saveJson(line[4],line[5])
                    return
                if  line[3]=='seturl':
                    Http.seturl(line[4])
                    return
                if  line[3]=='settimeout':
                    Http.settimeout(line[4])
                    return
                if  line[3]=='addparam':
                    Http.add_param(line[4],line[5])
                    return
                if  line[3]=='removeheader':
                    Http.remove_header(line[4])
                    return


            reader.open_excel(srcfile)
            writer.copy_open(srcfile,desfile)

            for i in range(0,reader.r):
                line=reader.readline()
                print(line)
                if len(line[0])>2 or len(line[1])>2:
                    #不去执行的行
                    pass
                else:
                    #执行
                    run(line)
                    pass
                                                                    
            writer.save_close()
Beispiel #2
0
        if line[3] == 'assertequals':
            app.assertequals(line[4], line[5])
            return
        if line[3] == 'savephoto':
            app.get_screenshot(resultfile, line[4])
            return

    except BaseException as e:
        print(e.args)
        app.get_screenshot(resultfile + 'error_', line[4])

        rerun(run)


reader.open_excel(srcfile)
writer.copy_open(srcfile, desfile)

for i in range(0, reader.r):
    line = reader.readline()
    print(line)
    if len(line[0]) > 2 or len(line[1]) > 2:
        #不去执行的行
        pass
    else:
        #执行
        run(line)
        pass

writer.save_close()
Beispiel #3
0
    def test_run(self):
        # -脚本-----------------------------------
        def run(line):
            if line[3] == 'caps':
                app.update_capability(line[4], line[5])
                return
            if line[3] == 'start':
                print(app.desired_caps)
                app.start(line[4], line[5])
                return
            if line[3] == 'sleep':
                app.sleep(line[4])
                return
            if line[3] == 'right':
                app.RIGHT()
                return
            if line[3] == 'left':
                app.LEFT()
                return
            if line[3] == 'up':
                app.UP()
                return
            if line[3] == 'down':
                app.DOWN()
                return
            if line[3] == 'id':
                app.get_element("id", line[4], line[5], line[6], line[2])
                return
            if line[3] == 'name':
                app.get_element("name", line[4], line[5], line[6], line[2])
                return
            if line[3] == 'text':
                app.get_element("text", line[4], line[5], line[6], line[2])
                return
            if line[3] == 'css':
                app.get_element("css", line[4], line[5], line[6], line[2])
                return
            if line[3] == 'xpath':
                app.get_element("xpath", line[4], line[5], line[6], line[2])
                return
            if line[3] == 'class':
                app.get_element("class", line[4], line[5], line[6], line[2])
                return
            if line[3] == 'click':
                app.clicks("click", line[4], line[5], line[6], line[2])
                return
            if line[3] == 'clear':
                app.clicks("clear", line[4], line[5], line[6], line[2])
                return
            if line[3] == 'input':
                app.clicks("input", line[4], line[5], line[6], line[2])
                return

            if line[3] == 'assertequals':
                #app.assert_equals(line[4], line[5],line[6])
                app.assert_method("equal", line[4], line[5], line[6])
                return

            if line[3] == 'savephoto':
                app.get_screenshot(resultfile, line[4])
                return

            if line[3] == 'text':
                app.get_element("text", line[4], line[5], line[6], line[2])
                return

            if line[3] == 'quit':
                app.quit()
                return

            if line[3] == 'back':
                app.back()
                return
            if line[3] == 'pagesource':
                app.get_pagessource(line[4])
                return
            if line[3] == 'assertequals_all':
                app.assert_equals_all(line[4], line[5], line[6])
                return

            if line[3] == 'assertin':
                #app.assert_in(line[4], line[5],line[6])
                app.assert_method("in", line[4], line[5], line[6])
                return
            if line[3] == 'assertin_all':
                app.assert_in_all(line[4], line[5], line[6])
                return

            if line[3] == 'toast':
                t.is_toast_exists(app.driver, line[4], line[5], line[6])
                return

            if line[3] == 'alwaysallow':
                t.always_allow(app.driver, line[4])
                return

            if line[3] == 'textContains':
                app.get_element("textContains", line[4], line[5], line[6],
                                line[2])
                return
            if line[3] == 'isexist':
                app.xpath_exist(line[4], line[5])
                return

            if line[3] == 'tanchuang':
                app.tanchuang(line[4])
                return
            if line[3] == 'tanchuangall':
                app.tanchuang_all()
                return
            if line[3] == 'backs':
                app.backs(line[4])
                return

            if line[3] == 'tappoint':
                app.tap_point(line[4], line[5])
                return

            if line[3] == 'taprandom':
                app.tap_random()
                return

            if line[3] == 'pagesource':
                app.get_pagessource(line[4])
                return

            if line[3] == 'sourceassert':
                app.source_assert(line[4])
                return

            if line[3] == 'activity':
                app.get_current_activity()
                return

            else:
                print('没有这个方法,请检查', line[3])

                return

        reader.open_excel(srcfile)
        writer.copy_open(srcfile, desfile)

        for i in range(0, reader.r):
            line = reader.readline()
            print(line)
            if len(line[0]) >= 2 or len(line[1]) >= 2 or line[0] == "#":
                # 不去执行的行
                pass
            else:
                # 执行
                run(line)
        #writer.writeformula()
        writer.save_close()

        print('执行完成---------------')