示例#1
0
 def tearDown(self):
     if GlobalVarClass.get_case_platform() == "darwin":
         self.driver.quit()
         stop_ios_appium()
     else:
         # engines = self.driver.available_ime_engines
         # engines.remove(u'io.appium.android.ime/.UnicodeIME')
         # self.driver.activate_ime_engine(engines[0])
         self.driver.quit()
         stop_android_appium()
     pass
示例#2
0
 def setUp(self):
     i = 0
     start_success = False
     while i < 3 and not start_success:
         try:
             if GlobalVarClass.get_case_platform() == "darwin":
                 self.udid = get_ios_udid_cy()
                 print(self.udid)
                 stop_ios_appium()
                 start_ios_appium(self.udid)
                 driver_setting = parse_cfg("setting", "ios")
                 self.desired_caps = {
                     'platformName': driver_setting["platformname"],
                     'deviceName': driver_setting["devicename"],
                     'device': driver_setting["device"],
                     'bundleId': driver_setting["bundleid"],
                     'version': driver_setting["version"],
                     'udid': self.udid
                 }
                 self.driver = webdriver.Remote(
                     'http://127.0.0.1:4723/wd/hub', self.desired_caps)
             else:
                 restart_adb()
                 stop_android_appium()
                 self.udid = get_android_udid()
                 print(u"设备devices:" + str(self.udid))
                 devices_setting = parse_cfg("setting", "devices")
                 if self.udid.lower() in devices_setting:
                     device_name = devices_setting[self.udid.lower()]
                 else:
                     device_name = "else"
                 GlobalVarClass.set_device_name(device_name)
                 start_android_appium(self.udid)
                 driver_setting = parse_cfg("setting", "android")
                 self.desired_caps = {
                     'platformName': driver_setting["platformname"],
                     'version': driver_setting["version"],
                     'deviceName': '%s' % self.udid,
                     'appPackage': driver_setting["apppackage"],
                     'appActivity': driver_setting["appactivity"],
                     'unicodeKeyboard':
                     eval(driver_setting["unicodekeyboard"]),
                     'resetKeyboard': eval(driver_setting["resetkeyboard"]),
                     'noReset': eval(driver_setting["noreset"])
                 }
                 self.driver = webdriver.Remote(
                     'http://127.0.0.1:4723/wd/hub', self.desired_caps)
             start_success = True
         except Exception as e:
             start_success = False
         i += 1
     if i == 3:
         raise Exception
示例#3
0
    def setUp(self):
        stop_android_appium()
        self.udid = get_android_udid()
        print(self.udid)
        start_android_appium(self.udid)
        self.desired_caps = {
            'platformName': 'Android',
            'version': '4.4.2',
            'deviceName': '%s' % self.udid,
            'appPackage': 'com.iscs.mobilewcs',
            'appActivity':
            '.com.iscs.mobilewcs.activity.base.LauncherActivity',
            'unicodeKeyboard': 'True',
            'resetKeyboard': 'True'
        }
        self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',
                                       desired_capabilities={})
        self.driver.wait_activity(
            'com.iscs.mobilewcs.activity.base.LauncherActivity', 10)

        #  第一步,点击微信登录
        # Login = LoginPage(self.driver)
        LoginPage(self.driver).WeiChat_login()
        sleep(1)
        self.driver.tap([(500, 990)], 500)
        sleep(1)
        #  跳转至前往微信登录界面
        LoginPage(self.driver).Go_WeiChat()
        sleep(1)
        # 点击第一个人
        self.driver.tap([(600, 315)], 500)
        sleep(1)
        # 点击邀请链接
        self.driver.tap([(450, 505)], 500)
        sleep(1)
        # 点击更多
        self.driver.tap([(1010, 135)], 500)
        sleep(1)
        # 在浏览器中打开
        self.driver.tap([(167, 1445)], 500)
        sleep(1)
        # 跳转至网仓App,并点击微信登录
        LoginPage(self.driver).WeiChat_login()
        sleep(1)
        self.driver.tap([(500, 990)], 500)
        sleep(1)
        pass
示例#4
0
 def setUp(self):
     stop_android_appium()
     self.udid = get_android_udid()
     # resume_generate_bill()
     print(self.udid)
     self.desired_caps = {
         'platformName': 'Android',
         'version': '5.1.1',
         'deviceName': '%s' % self.udid,
         'appPackage': 'com.iscs.mobilewcs',
         'appActivity': 'com.iscs.mobilewcs.activity.base.LauncherActivity',
         'unicodeKeyboard': 'True',
         'resetKeyboard': 'True'
     }
     start_android_appium(self.udid)
     self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',
                                    self.desired_caps)
     pass
示例#5
0
 def setUp(self):
     self.user_id = 199289
     self.password = 1
     stop_android_appium()
     self.udid = get_android_udid()
     print(self.udid)
     self.desired_caps = {}
     self.desired_caps = dict(platformName='Android',
                              version='5.1.1',
                              deviceName='%s' % self.udid,
                              appPackage='com.iscs.mobilewcs',
                              appActivity='.activity.test.TextActivity',
                              unicodeKeyboard='True',
                              resetKeyboard='True')
     start_android_appium(self.udid)
     self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',
                                    self.desired_caps)
     StartLogin(self.driver).get_start_login(self.user_id, self.password)
示例#6
0
 def tearDown(self):
     self.driver.quit()
     stop_android_appium()
     print("释放资源~")
     pass
    def tearDown(self):
        self.browser.quit()
        ExitAppPage(self.driver).logout_app()
        stop_android_appium()

        pass
示例#8
0
 def tearDown(self):
     stop_android_appium()
     print("释放资源!")
     pass
示例#9
0
    def tearDown(self):
        self.browser.quit()
        self.driver.quit()
        stop_android_appium()

        pass
示例#10
0
    def recursion_run_case(self, testMethod, result=None, num=2):
        success = False

        try:
            self.setUp()
        except SkipTest as e:
            self._addSkip(result, str(e))
        except KeyboardInterrupt:
            raise
        except Exception as e:
            if self.driver:
                if GlobalVarClass.get_case_platform() == "darwin":
                    self.driver.quit()
                    stop_ios_appium()
                else:
                    # engines = self.driver.available_ime_engines
                    # engines.remove(u'io.appium.android.ime/.UnicodeIME')
                    # self.driver.activate_ime_engine(engines[0])
                    self.driver.quit()
                    stop_android_appium()
            result.addError(self, sys.exc_info())
        else:
            try:
                testMethod()
            except KeyboardInterrupt:
                raise
            except self.failureException:
                result.addFailure(self, sys.exc_info())
            except _ExpectedFailure as e:
                addExpectedFailure = getattr(result, 'addExpectedFailure',
                                             None)
                if addExpectedFailure is not None:
                    addExpectedFailure(self, e.exc_info)
                else:
                    warnings.warn(
                        "TestResult has no addExpectedFailure method, reporting as passes",
                        RuntimeWarning)
                    result.addSuccess(self)
            except _UnexpectedSuccess:
                addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess',
                                               None)
                if addUnexpectedSuccess is not None:
                    addUnexpectedSuccess(self)
                else:
                    warnings.warn(
                        "TestResult has no addUnexpectedSuccess method, reporting as failures",
                        RuntimeWarning)
                    result.addFailure(self, sys.exc_info())
            except SkipTest as e:
                self._addSkip(result, str(e))
            except Exception as e:
                if num > 0:
                    num -= 1
                    print("")
                    print(
                        "*****************case出错,重新运行一次case*****************")
                    video_p = None
                    # try:
                    #     if num == GlobalVar.get_case_error_num() - 1:
                    #         video_file = GlobalVar.get_case_name() + "_" + str(time.time()) + "_video.wma"
                    #         # video_cmd = 'ffmpeg -rtbufsize 2000M -r 25 -f dshow -i video="Medialooks Screen Capture"  ' + \
                    #         #     GlobalVar.get_video_path() + video_file
                    #         video_cmd = 'ffmpeg -rtbufsize 2000M -f dshow -i video="Medialooks Screen Capture" -r 20 -qscale 8  d:\direj.avi'
                    #         print (video_cmd)
                    #         video_p = subprocess.Popen(video_cmd)
                    #         # os.system(video_cmd)y
                    # except Exception as e:
                    #     print ("暂时无法进行错误录屏,请安装对应组件后再录屏")
                    self.recursion_run_case(testMethod, result, num)
                    # try:
                    #     if video_p:
                    #         video_p.terminate()
                    # except Exception as e:
                    #     pass
                else:
                    result.addError(self, sys.exc_info())
            else:
                success = True
            try:
                self.tear_run += 1
                if num == 0 and self.tear_run == 1:
                    self.tearDown()
            except KeyboardInterrupt:
                raise
            except:
                # result.addError(self, sys.exc_info())
                success = False
            return success
示例#11
0
    def setUp(self):
        stop_android_appium()
        self.udid = get_android_udid()
        print(self.udid)
        self.desired_caps = {
            'platformName': 'Android',
            'version': '5.1.1',
            'deviceName': '%s' % self.udid,
            'appPackage': 'com.iscs.mobilewcs',
            'appActivity': 'com.iscs.mobilewcs.activity.base.LauncherActivity',
            'unicodeKeyboard': 'True',
            'resetKeyboard': 'True'
        }
        start_android_appium(self.udid)
        self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',
                                       self.desired_caps)
        sleep(30)

        setFirstOne()  # 还原task库注册信息
        sleep(1)
        setSQlDelete_common()  # 还原BASIC库注册信息
        '''
                Team3组开始
                进行授权服务邀请:进入App后,点击伟大的三组button,进入界面后,输入10000243;点击登录
                进入界面,点击服务认证邀请,进入邀请好友界面,点击选择好友BUTTON,选择张三,点击邀请button,
                跳入微信,选择折耳喵,点击分享,点击返回网仓三号,点击退出。完成
            '''
        PageFollow = FollowPage(self.driver)
        PageFollow.click_team_three_btn_element()  # 点击伟大的三组button
        sleep(1)
        PageFollow.click_login_input_element()  # 进入界面后,输入10000243
        sleep(1)
        PageFollow.click_login_btn_element()  # 点击登录
        # 服务认证邀请
        LinearLayout = get_elements(
            self.driver, ("CLASS_NAME", "android.widget.LinearLayout"))
        LinearLayout[3].click()
        PageFollow.click_select_friend_btn_element()  # 选择好友
        sleep(1)
        # 选择测试账号
        Invite_Button = get_elements(self.driver,
                                     ("CLASS_NAME", "android.widget.Button"))
        Invite_Button[1].click()
        sleep(2)
        # 跳转至微信界并点击人物
        self.driver.tap([(240, 590)], 500)
        sleep(2)
        # 点击分享按钮
        self.driver.tap([(870, 1190)], 500)
        sleep(4)
        # 留在微信
        self.driver.tap([(820, 1155)], 500)
        sleep(2)
        # 点击测试账号
        self.driver.tap([(540, 260)], 500)
        sleep(3)
        # 点击邀请链接
        self.driver.tap([(561, 403)], 500)
        sleep(5)
        # 点击下载客户端右边按钮 105
        self.driver.tap([(1015, 120)], 100)
        sleep(2)
        # 点击在浏览器中打开 -->跳入网仓三号
        self.driver.tap([(900, 700)], 500)
        sleep(2)
        pass