示例#1
0
文件: BasePage.py 项目: wl99/app-ui
    def swip_up(self, count=1, method=None, speed=1000):
        """ 向上刷新
        :param count: 滑动次数
        :param method: 传入的方法 method(action) ,如果返回为True,则终止刷新
        :param speed: 滑动速度 ms
        :return:

        """
        # 检查是否出现弹窗导致无法查找元素
        if self.click_shoot_pop():
            log.i("出现弹窗,关闭后继续")
        if count == 1:
            self.sleep(1)
            self.driver.swipe(self.width / 2, self.height * 3 / 4, self.width / 2, self.height / 4, speed)
            self.sleep(2)
        else:
            for x in range(count):
                self.driver.swipe(self.width / 2, self.height * 3 / 4, self.width / 2, self.height / 4, speed)
                self.sleep(2)
                try:
                    if method(self):
                        break
                except:
                    pass
        log.i("[滑动]向上刷新 ")
示例#2
0
文件: BasePage.py 项目: wl99/app-ui
 def switch_to_webview(self):
     """
     切换至webview
     :return:
     """
     self.driver.switch_to.context("WEBVIEW_stetho_com.tenbent.bxjd")
     # self.driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {"name": "WEBVIEW_stetho_com.tenbent.bxjd"})
     log.i("切换至webview:WEBVIEW_stetho_com.tenbent.bxjd")
     print(self.driver)
示例#3
0
文件: BasePage.py 项目: wl99/app-ui
 def _finds(self, by, value, timeout=10) -> WebElements:
     log.i("查找方式:{0},查找值数组:{1}".format(by, value))
     try:
         element: WebElement = WebDriverWait(self.driver, timeout).until(lambda x: x.find_elements(by, value))
         return element
     except Exception as e:
         log.e("通过方式{0}未查找到元素{1}".format(by, value))
         log.e(e)
         # 截图
         self.screen_shot("未找到元素")
         # 检查是否是因为权限弹窗导致无法查找元素
         if self.click_shoot_windows():
             log.i("出现权限弹窗,允许后重新查找元素")
             return self._find(by, value)
         return False
示例#4
0
文件: BasePage.py 项目: wl99/app-ui
 def swip_right(self, height=0.5, count=1, speed=1000):
     """向右滑动
     :param height: 高度满屏幕为1
     :param count: 滑动次数
     :param speed: 滑动速度 ms
     :return:
     """
     # 检查是否出现弹窗导致无法查找元素
     if self.click_shoot_pop():
         log.i("出现弹窗,关闭后继续")
     for x in range(count):
         self.sleep(1)
         self.driver.swipe(self.width / 8, self.height * height, self.width * 7 / 8, self.height * height, speed)
         self.sleep(2)
         log.i("[滑动]向右滑动 ")
示例#5
0
文件: Driver.py 项目: wl99/app-ui
 def quit(cls):
     log.i("====退出app====")
     cls.driver.quit()
示例#6
0
文件: Driver.py 项目: wl99/app-ui
 def restart_app(cls, platform) -> WebDriver:
     log.i("=====启动app====")
     return cls.initDriver("restart_app", platform)
示例#7
0
文件: BasePage.py 项目: wl99/app-ui
 def get_logcat(self, name: str):
     logcat = self.driver.get_log('logcat')
     c = '\n'.join([i['message'] for i in logcat])
     log.i("获取日志:{}".format(name))
     allure.attach(c, name, allure.attachment_type.TEXT)
示例#8
0
文件: BasePage.py 项目: wl99/app-ui
 def element_shot(self, element, name: str):
     log.i("元素截图:{}".format(name))
     png_byte = element.screenshot_as_png
     allure.attach(png_byte, name, allure.attachment_type.PNG)
示例#9
0
文件: BasePage.py 项目: wl99/app-ui
 def screen_shot(self, name: str):
     log.i("屏幕截图:{}".format(name))
     png_byte = self.driver.get_screenshot_as_png()
     allure.attach(png_byte, name, allure.attachment_type.PNG)
示例#10
0
文件: BasePage.py 项目: wl99/app-ui
 def switch_to_native(self):
     self.driver.switch_to.context("NATIVE_APP")
     # self.driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {"name": "NATIVE_APP"})
     log.i("切换至原生页面")
     print(self.driver)
示例#11
0
文件: BasePage.py 项目: wl99/app-ui
 def typing(self, by, value, sendStr, timeout=10):
     element = self.find(by, value, timeout)
     element.click()  # Let the element in focus.
     # element.clear()
     element.send_keys(sendStr)
     log.i("输入数据:{}".format(sendStr))
示例#12
0
文件: BasePage.py 项目: wl99/app-ui
 def click(self, by, value, timeout=10):
     el = self.find(by, value, timeout)
     if el:
         el.click()
         log.i("点击元素")