Пример #1
0
 def exists(self, element):
     print u"%s 判断元素是否存在 -> %s" % (util.log_time(
         datetime.datetime.now()), element[2])
     device = find_element(self.device, element[0], element[1])
     if device.exists:
         print u"%s 元素存在" % util.log_time(datetime.datetime.now())
         return True
     else:
         print u"%s 元素不存在" % util.log_time(datetime.datetime.now())
         return False
Пример #2
0
def check_list_data(my_device, index, el_name, text, current):
    stock_name = my_device.get_text_by_index(element.get_element(el_name), index)
    print u"%s %s -> %s" % (
        util.log_time(current),
        text,
        stock_name
    )
    assert stock_name != "None"
Пример #3
0
 def setup_method(self):
     self.my_service.screen_on()
     self.my_service.click(element.get_element("common_app_name"))
     self.my_service.sleep_screen(5)
     if self.my_service.exists(element.get_element("common_welcome_indicator")):
         self.my_service.swipe("left", 0.7, 0.2, 10)
         self.my_service.swipe("left", 0.7, 0.2, 10)
         self.my_service.click(element.get_element("common_welcome_experience"))
     else:
         print u"%s 跳过欢迎页" % util.log_time(datetime.datetime.now())
Пример #4
0
 def swipe(self, direction, start, end, step):
     data = self.device.info
     mobile_width = data.get("displayWidth")
     mobile_height = data.get("displayHeight")
     if direction == "up":
         print u"%s 向上滑" % util.log_time(datetime.datetime.now())
         self.device.swipe(mobile_width * 0.5, mobile_height * start,
                           mobile_width * 0.5, mobile_height * end, step)
     if direction == "down":
         print u"%s 向下滑" % util.log_time(datetime.datetime.now())
         self.device.swipe(mobile_width * 0.5, mobile_height * start,
                           mobile_width * 0.5, mobile_height * end, step)
     if direction == "left":
         print u"%s 向左滑" % util.log_time(datetime.datetime.now())
         self.device.swipe(mobile_width * start, mobile_height * 0.5,
                           mobile_width * end, mobile_height * 0.5, step)
     if direction == "right":
         print u"%s 向右滑" % util.log_time(datetime.datetime.now())
         self.device.swipe(mobile_width * start, mobile_height * 0.5,
                           mobile_width * end, mobile_height * 0.5, step)
Пример #5
0
def reinstall_app(env, app_path):
    print u"============================= 初始化测试环境 ============================="
    # 查看手机中安装所有应用的包名
    find_data = os.popen("adb shell pm list packages").readlines()
    for data in find_data:
        if config.PACKAGE.get(env) in data.strip():
            print u"%s 删除已安装APP, Package=%s" % (util.log_time(
                datetime.datetime.now()), config.PACKAGE.get(env))
            return_data = os.popen("adb uninstall %s" %
                                   config.PACKAGE.get(env)).readlines()
            for item in return_data:
                print u"%s %s" % (util.log_time(
                    datetime.datetime.now()), item.strip())
    local = "APP.apk"
    urllib.urlretrieve(app_path, local)
    print u"%s 安装APP, Package=%s" % (util.log_time(
        datetime.datetime.now()), config.PACKAGE.get(env))
    return_data = os.popen("adb install %s" % local).readlines()
    print u"%s %s" % (util.log_time(
        datetime.datetime.now()), return_data[-2].strip())
    print u"%s %s" % (util.log_time(
        datetime.datetime.now()), return_data[-1].strip())
Пример #6
0
    def test_new_stock(self):
        try:
            # 进入新股日历
            self.my_service.click(
                element.get_element("stock_market_marketButton"))
            self.my_service.click(element.get_element("stock_market_newStock"))
            self.my_service.sleep_screen(5)
            # 通过上市时间和IPO以来表现的差异进行划分待上市数据和已上市数据
            data_three_length = self.my_service.get_length(
                element.get_element("stock_market_hk_new_stock_num_three"))
            wait_public_num = 0
            for i in range(data_three_length):
                three_text = self.my_service.get_text_by_index(
                    element.get_element("stock_market_hk_new_stock_num_three"),
                    i)
                if "%" not in three_text:
                    wait_public_num += 1
            already_public_num = data_three_length - wait_public_num
            print "%s 待上市 -> %s  已上市 -> %s" % (util.log_time(
                datetime.datetime.now()), str(wait_public_num),
                                               str(already_public_num))
            # 检测待上市 -> 1级数据
            print u"%s 检测待上市 -> 1级数据" % util.log_time(datetime.datetime.now())
            if wait_public_num == 0:
                print u"%s -- Check Point -- 待上市列表中没有数据,请手动进行检测" %\
                      util.log_time(datetime.datetime.now())
            else:
                for i in range(wait_public_num):
                    baseTest.check_list_data(self.my_service, i,
                                             "stock_market_hk_new_stock_name",
                                             u"股票名称", datetime.datetime.now())
                    baseTest.check_list_data(self.my_service, i,
                                             "stock_market_hk_new_stock_code",
                                             u"股票代码", datetime.datetime.now())
                    baseTest.check_list_data(
                        self.my_service, i,
                        "stock_market_hk_new_stock_num_one", u"申购价",
                        datetime.datetime.now())
                    baseTest.check_list_data(
                        self.my_service, i,
                        "stock_market_hk_new_stock_num_two", u"入场费",
                        datetime.datetime.now())
                    baseTest.check_list_data(
                        self.my_service, i,
                        "stock_market_hk_new_stock_num_three", u"上市时间",
                        datetime.datetime.now())
            # 检测待上市 -> 2级数据

            # 检测已上市 -> 1级数据
            print u"%s 检测已上市 -> 1级数据" % util.log_time(datetime.datetime.now())
            if already_public_num == 0:
                print u"%s -- Check Point -- 已上市列表中没有数据,请手动进行检测" % \
                      util.log_time(datetime.datetime.now())
            else:
                for i in range(already_public_num):
                    baseTest.check_list_data(self.my_service, i,
                                             "stock_market_hk_new_stock_name",
                                             u"股票名称", datetime.datetime.now())
                    baseTest.check_list_data(self.my_service, i,
                                             "stock_market_hk_new_stock_code",
                                             u"股票代码", datetime.datetime.now())
                    baseTest.check_list_data(
                        self.my_service, i,
                        "stock_market_hk_new_stock_num_one", u"发行价",
                        datetime.datetime.now())
                    baseTest.check_list_data(
                        self.my_service, i,
                        "stock_market_hk_new_stock_num_two", u"现价",
                        datetime.datetime.now())
                    baseTest.check_list_data(
                        self.my_service, i,
                        "stock_market_hk_new_stock_num_three", u"IPO以来表现",
                        datetime.datetime.now())
            # 检测已上市 -> 2级数据

        except:
            util.fail_screen_shot(self.my_service)
            assert False
Пример #7
0
 def sleep_screen(self, second):
     print u"%s 等待%s秒" % (util.log_time(
         datetime.datetime.now()), str(second))
     sleep(second)
Пример #8
0
 def click(self, element):
     print u"%s 点击 -> %s" % (util.log_time(
         datetime.datetime.now()), element[2])
     device = find_element(self.device, element[0], element[1])
     device.click()
Пример #9
0
 def get_length(self, element):
     device = find_element(self.device, element[0], element[1])
     element_length = len(device)
     print u"%s 长度 -> %s" % (util.log_time(
         datetime.datetime.now()), str(element_length))
     return element_length
Пример #10
0
 def set_text(self, element, text):
     print u"%s 输入 -> %s" % (util.log_time(datetime.datetime.now()), text)
     device = find_element(self.device, element[0], element[1])
     device.set_text(text)
Пример #11
0
 def screen_shot(self, pic):
     print u"%s 失败截图 -> %s" % (util.log_time(datetime.datetime.now()), pic)
     self.device.screenshot(pic)
Пример #12
0
 def press_back(self):
     print u"%s 点击手机回退键" % util.log_time(datetime.datetime.now())
     self.device.press.back()
Пример #13
0
 def press_home(self):
     print u"%s 点击手机HOME键" % util.log_time(datetime.datetime.now())
     self.device.press.home()
Пример #14
0
 def screen_off(self):
     print u"%s 熄灭屏幕" % util.log_time(datetime.datetime.now())
     self.device.screen.off()
Пример #15
0
 def screen_on(self):
     print u"%s 点亮屏幕" % util.log_time(datetime.datetime.now())
     self.device.screen.on()