コード例 #1
0
 def test_3select(cls):
     '''选择查询车辆和时间'''
     driver = cls.driver
     test = BaseAction(driver)
     # 点击搜索框
     test.Click("xpath", "//*[@id='oil_radio_tree_content']/div[1]/input")
     # 输入要查询的车辆车牌号信息
     test.Input("xpath", "//*[@id='oil_radio_tree_content']/div[1]/input", "济宁00001")
     # 点击查询按钮
     test.Click("xpath", "//*[@id='oil_radio_tree_content']/div[1]/a")
     test.Wait(3)
     # 选中要查询的车辆
     test.Click("xpath",
                "//*[@class='checkboxcontent']/span[@id='20180131171228000000000000008188-jquery-extend-ui-radio']/span[2]")
     # 点击返回框
     test.wait(3)
     test.Click("xpath", "//*[@id='oil_radio_tree_content']/div[4]")
     # 点击下一步
     test.wait(2)
     test.Click("xpath", "//*[@id='tyre_next_setting']")
     report_name = test.Get_text("xpath", "//*[@id='rnavigation']/li[2]/span[2]")
     try:
         cls.assertEqual(report_name, '单车行驶里程及油耗报表')
         log.info("跳转到单车行驶里程及油耗报表查询界面")
     except AssertionError as e:
         test.get_windows_img('单车行驶里程及油耗报表')
         print("找不到报表标题:", report_name)
         raise
     test.scrollLow("id", "turnPageButton")  # 滑动到页面底部
     test.Wait(2)
     cls.switch_page()
コード例 #2
0
    def test_4yestoday(cls):
        '''查询系统昨日数据'''
        driver = cls.driver
        test = BaseAction(driver)
        # 点击条件选择
        test.Click("xpath", "//*[@id='_R201414']//span[1]/span[2]")
        # 点击时间选择
        test.Click("xpath", "//*[@id='_R201414']//tr[1]/td[6]//div[2]/div")
        # 选中昨天
        test.Click("xpath", "//*[@id='_R201414']//tr[1]/td[6]//div[2]/li[1]")
        # 点击提交按钮
        test.Click("xpath", "//*[@id='_R201414']//div[1]//tr[2]//input")
        test.Wait(3)
        # 滚动到底部
        test.scrollLow("id", "inputPageText201414")  # 滑动到页面底部
        test.Wait(3)
        # 获取分页数据
        cls.switch_page()
        log.info("查询昨日数据,保存到excel")
        # 获取系统中的总计里程和时长
        excel1 = "F:\\PyTesting\\AutoTest\\log\\excel\\Mile.xls"
        excel = Excel(excel1, 0)
        row = excel.get_rows()
        col = excel.get_cols()
        sum_time = excel.get_cell_value(row - 1, col - 4)
        sum_mile = excel.get_cell_value(row - 1, col - 3)
        print("行驶总时间:", float(sum_time.split('秒')[0]))
        print("行驶总里程:", sum_mile)
        log.info("获取里程时间数据")

        # 获取数据库中的总计里程和时长
        excel2 = "F:\\PyTesting\\AutoTest\\log\\excel\\Mile_Y_DB.xlsx"
        excel_db = Excel(excel2, 0)
        row1 = excel_db.get_rows()
        col1 = excel_db.get_cols()
        sum_mile1 = 0.0
        sum_time1 = 0.0
        for x in range(1, row1):
            sum_time1 = float(excel_db.get_cell_value(row1 - x, 4)) + sum_time1
            sum_mile1 = float(excel_db.get_cell_value(row1 - x, 5)) + sum_mile1
        print("数据库中行驶总时间:", sum_time1)
        print("数据库中行驶总里程:", sum_mile1)
        log.info("获取数据库中里程时间数据")
        sum_time1 == sum_time and sum_mile1 == sum_mile
        try:
            sum_time1 == sum_time and sum_mile1 == sum_mile
            log.info("数据查询成功!")
        except AssertionError as e:
            log.info("数据查询失败,页面数据和系统数据不一致!")
            raise
        log.info("验证数据")