Пример #1
0
 def update(self, newUserName, db, mobile):
     self.comePersonal.clickPersonal(db, mobile)
     if self.base.iosCheckElement(self.updateNameButton):
         self.base.iosClick(self.updateNameButton)
         self.base.setValue(self.updateNameInputButton, newUserName, 15)
         self.base.iosClick(self.saveButton)
     else:
         raise EleNotFound("进入修改用户名页面失败")
Пример #2
0
    def login(self, userName, password):
        """
        登录
        :param userName: 账号
        :param password: 密码
        :return:
        """
        self.loginOut()  # 如果已登录会退出登录

        if self.baseView.checkElement(self.mobileLoginButton):
            self.baseView.click(self.mobileLoginButton)
        else:
            raise EleNotFound("账号登录按钮未找到")
        if self.baseView.checkElement(self.aaccount):
            self.baseView.sendKeys(self.aaccount, userName)
            self.baseView.sendKeys(self.passwd, password)
            self.baseView.click(self.submitButton)
            print('登录成功')
        else:
            raise EleNotFound("输入账号按钮未找到")
Пример #3
0
 def findElements(self, loc, timeout=5):
     """
     查找多个元素
     :param loc: id,kw
     :param timeout: 超时时间
     :return: Element LIst
     """
     if self.checkElement(loc, timeout):
         return self.driver.find_elements(*loc)
     else:
         self.logger.error("元素:{0} 查找失败".format(loc))
         raise EleNotFound("{0} 元素列表未找到".format(loc))
Пример #4
0
 def iosPredicate(self, ele, timeout=5):
     """
     查找单个元素 iOS专用
     :param ele:
     :param timeout:
     :return:
     """
     if self.iosCheckElement(ele, timeout):
         ele = self.driver.find_element_by_ios_predicate(ele)
         return ele
     else:
         raise EleNotFound("iOS ios_predicate:{} 元素未找到".format(ele))
Пример #5
0
 def findAccessiblity(self, loc, timeout=10):
     """
     accessibility Android 使用的是 content-desc
     属性 IOS使用的是 accessibility identifier属性
     :param loc:
     :param timeout:
     :return:
     """
     if self.checkAccessiblity(loc, timeout):
         ele = self.driver.find_element_by_accessibility_id(loc)
         return ele
     else:
         self.logger.error("元素:{0} 查找失败".format(loc))
         raise EleNotFound("findAccessiblity find element error ")
Пример #6
0
    def switchNavigation(self, navigation):
        buttonDict = {
            "探索": lambda: Explore(self.driver).switchNavigation(),
            "班级": lambda: ClassIm(self.driver).switchNavigation(),
            "学习中心": lambda: Learn(self.driver).switchNavigation(),
            "题库": lambda: QuestionBank(self.driver).switchNavigation(),
            "我的": lambda: Myself(self.driver).switchNavigation()
        }

        button = buttonDict.get(navigation, False)
        if button:
            button()
        else:
            raise EleNotFound("首页导航类型错误")
Пример #7
0
    def login(self,account,password):
        self.loginout()
        mobileLoginEles = self.base.iosPredicates(self.mobileLoginButton)
        for loginButton in mobileLoginEles:
            visible = loginButton.get_attribute("visible")
            if visible == "true":
                loginButton.click()
                break

        if self.base.iosCheckElement(self.account):
            self.base.setValue(self.account,account,1)
            self.base.setValue(self.passwd,password,10)
            self.base.iosClick(self.submit)
        else:
            raise EleNotFound("输入账号框未找到")
Пример #8
0
    def findElementUiautomator(self, loc):
        """
        使用uiuatomator定位元素 Android专用
        :param loc:  new UiSelector().text("id")
        :return:  Element
        """

        self.logger.info(
            str(('正在使用 new UiSelector().{0}(\"{1}\")'.format(loc[0], loc[1]))))
        try:
            EleRes = self.driver.find_element_by_android_uiautomator \
                ('new UiSelector().{0}(\"{1}\")'.format(loc[0], loc[1]))
            return EleRes
        except:
            self.logger.error("元素:{0} 查找失败".format(loc))
            raise EleNotFound("findElementUiautomator Error")
Пример #9
0
 def update(self, summary, db, mobile):
     """
     修改个人简介
     :param summary:
     :return:
     """
     self.comePersonal.clickPersonal(db, mobile)
     if self.base.iosCheckElement(self.updateSummaryButton):
         self.base.iosClick(self.updateSummaryButton)
     else:
         raise EleNotFound("进入修改简介页面失败")
     self.base.iosClick(self.SummaryFlage)
     ele = self.base.iosPredicate(self.setSummary)
     ele.click()
     self.base.iosClearText(20)
     ele.set_value(summary)
     self.base.iosClick(self.saveButton)
Пример #10
0
    def checkElement(self, loc, timeout=5):
        """
        检查元素是否存在
        :param loc: loc type is tuple
        :return: check result
        """

        if not isinstance(timeout, int):
            raise EleNotFound("超时时间必须是的整数")

        flage = True
        while flage and timeout > 0:
            try:
                self.driver.find_element(*loc)
                return True
            except:
                pass
            time.sleep(0.5)
            if flage and timeout == 0:
                return False
            timeout -= 0.5
Пример #11
0
 def supperElement(self, loc, errorString, time=5):
     if not self.checkElement(loc, time):
         raise EleNotFound(errorString)
Пример #12
0
 def switchNavigation(self):
     self.closeAd()
     if self.base.iosCheckElement(self.myselfButton):
         self.base.iosClick(self.myselfButton)
     else:
         raise EleNotFound("我的按钮未找到")
Пример #13
0
 def chooseNavigation(self):
     if self.base.checkElement(self.questionBank):
         self.base.click(self.questionBank)
     else:
         raise EleNotFound("题库按钮未找到")
Пример #14
0
 def chooseNavigation(self):
     if self.base.checkElement(self.myStudy):
         self.base.click(self.myStudy)
     else:
         raise EleNotFound("学习中心按钮未找到")
Пример #15
0
 def chooseNavigation(self):
     if self.base.checkElement(self.classTab):
         self.base.click(self.classTab)
     else:
         raise EleNotFound("班级按钮未找到")
Пример #16
0
 def chooseNavigation(self):
     if self.base.checkElement(self.explore):
         self.base.click(self.explore)
     else:
         raise EleNotFound("探索按钮未找到")
Пример #17
0
 def chooseNavigation(self):
     if self.base.checkElement(self.mySelf, 180):
         self.base.click(self.mySelf)
     else:
         raise EleNotFound("我的按钮未找到")
Пример #18
0
 def switchNavigation(self):
     self.closeAd()
     if self.base.iosCheckElement(self.questionBankButton):
         self.base.iosClick(self.questionBankButton)
     else:
         raise EleNotFound("题库按钮未找到")