Exemplo n.º 1
0
 def swipe_up(self, t=2000, n=1):
     s = self.driver.get_window_size()
     logging.info("swipe-up")
     x1 = s['width'] * 0.34  # 起点x坐标
     y1 = s['height'] * 0.84  # 起点y坐标
     y2 = s['height'] * 0.099075  # 终点y坐标
     for i in range(n):
         self.driver.swipe(x1, y1, x1, y2, t)
Exemplo n.º 2
0
 def swipe_down(self, t=500, n=1):
     s = self.driver.get_window_size()
     logging.info("swipe-down")
     x1 = s['width'] * 0.5  # x坐标
     y1 = s['height'] * 0.25  # 起点y坐标
     y2 = s['height'] * 0.75  # 终点y坐标
     for i in range(n):
         self.driver.swipe(x1, y1, x1, y2, t)
Exemplo n.º 3
0
    def test_user_register(self):
        logging.info("=========test_user_register===========")
        r = RegisterView(self.driver)
        username = "******" + "YE" + str(random.randint(1000, 9999))
        password = "******" + "YE" + str(random.randint(1000, 9999))
        email = "susg" + "YE" + str(random.randint(1000, 9999)) + "@163.com"
        r.register_action(username, password, email)

        self.assertTrue(r.register_action(username, password, email))
Exemplo n.º 4
0
 def get_elenment_count(self, *element):
     count = 0
     while (count >= 0):
         try:
             self.driver.find_elements(*element)[count]
         except:
             break
         else:
             count = count + 1
     logging.info('检测到' + str(count) + '个元素')
     return count
Exemplo n.º 5
0
 def wait_element_sendkeys(self, time, text, *element):
     try:
         WebDriverWait(self.driver,
                       time).until(lambda x: x.find_element(*element))
     except TimeoutException:
         self.photo(
             "方法%s().第%s行.%s" % (sys._getframe().f_back.f_code.co_name,
                                 str(sys._getframe().f_back.f_lineno),
                                 sys._getframe().f_code.co_name))
         logging.info("error" + str(self.get_current_function_name()))
     except NoSuchElementException:
         self.photo(
             "方法%s().第%s行.%s" % (sys._getframe().f_back.f_code.co_name,
                                 str(sys._getframe().f_back.f_lineno),
                                 sys._getframe().f_code.co_name))
         logging.info("error" + str(self.get_current_function_name()))
     else:
         self.find_element(*element).clear().send_keys(text)
Exemplo n.º 6
0
 def add_register_info(self):
     logging.info("=======choose schoolname======")
     self.driver.find_element(*self.school_name).click()
     self.driver.find_elements(*self.city)[1].click()
     self.driver.find_elements(*self.school)[1].click()
     logging.info("=======choose major======")
     self.driver.find_element(*self.major).click()
     self.driver.find_elements(*self.major_subject_title)[1].click()
     self.driver.find_elements(*self.major_group_title)[1].click()
     self.driver.find_elements(*self.major_search_item_name)[1].click()
     logging.info("=======click gobtn======")
     self.driver.find_element(*self.goBtn).click()
Exemplo n.º 7
0
 def check_registerStatus(self):
     self.check_market_ad()
     logging.info('==========check_registerStatus===========')
     try:
         self.driver.find_element(*self.myBtn).click()
         self.driver.find_element(*self.userinfo)
     except NoSuchElementException:
         logging.info("register failed")
         self.getScreenShot("register Fail")
         return False
     else:
         logging.info("register success")
         self.getScreenShot("register success")
         return True
Exemplo n.º 8
0
    def register_action(self, username, password, email):
        self.check_cancelBtn()
        self.check_skipBtn()
        logging.info("点击注册按钮")
        self.driver.find_element(*self.register_text).click()

        ###填写注册信息
        for i in range(3):
            logging.info("register_usename is %s" % username)
            self.driver.find_element(*self.username).set_value(username)
            time.sleep(1)
            logging.info("register_password is %s" % password)
            self.driver.find_element(*self.password).send_keys(password)
            # self.driver.press_keycode(29)
            # self.driver.press_keycode(29)
            # self.driver.press_keycode(29)
            # self.driver.press_keycode(29)
            # self.driver.press_keycode(29)
            # self.driver.press_keycode(29)
            # self.driver.press_keycode(29)
            # time.sleep(1)
            logging.info("register_email is %s" % email)
            self.driver.find_element(*self.email).click()
            self.driver.press_keycode(10)
            self.driver.press_keycode(8)
            self.driver.press_keycode(13)
            self.driver.press_keycode(41)
            self.driver.press_keycode(43)
            self.driver.press_keycode(43)
            self.driver.press_keycode(29)
            self.driver.press_keycode("Shift+Left")
            self.driver.press_keycode(9)

            time.sleep(1)
            # ##选择头像
            # logging.info('set userheader')
            # self.driver.find_element(*self.userheader).click()
            # logging.info("=======loading images==========")
            # # time.sleep(30)
            # self.driver.find_elements(*self.imageView)[1].click()
            # self.driver.find_element(*self.saveBtn).click()
            logging.info('点击注册按钮')
            self.driver.find_element(*self.registerBtn).click()
        #time.sleep(3)
        ##判断是否进入到完善信息界面--注册太频繁会被限制无法进入该界面
        try:
            self.driver.find_element(*self.school_name)
        except NoSuchElementException:
            logging.info("register failed")
            self.getScreenShot("register failed")
            return False
        else:
            self.add_register_info()
            # 注册结果判断
            if self.check_registerStatus():
                return True
            else:
                return False
Exemplo n.º 9
0
 def tearDown(self):
     logging.info('======tearDown=====')
     sleep(5)
     self.driver.close_app()
Exemplo n.º 10
0
 def setUp(self):
     logging.info('======setUp=========')
     self.driver = appium_desired()