Beispiel #1
0
 def environmentPrepar(self):
     mobile_emulation = {'deviceName': 'iPhone 5'}
     options = webdriver.ChromeOptions()
     options.add_experimental_option("mobileEmulation", mobile_emulation)
     self.driver = webdriver.Chrome(executable_path='chromedriver.exe',
                                    chrome_options=options)
     self.driver.implicitly_wait(15)
     self.driver.maximize_window()
     self.driver.get(dict_load['url']['C端URL'])
     sleep(1)
     loc = (By.CSS_SELECTOR, dict_load['C端页面元素']['用户积分'])
     WebDriverWait(self.driver, 10).until(
         expected_conditions.visibility_of_element_located(loc))
     u1 = means.get_text(self, 'css', dict_load['C端页面元素']['用户积分'])
     u2 = re.findall(r"(......+?)", str(u1))
     u3 = str(u2).replace(',', '')
     # C端用户下单前用户积分
     u4 = u3[2:-2]
     # 0>>>
     table.cretaTable(self)
     table.write(self, 0, u4)
     sleep(4)
     if int(u4) <= 4000:
         print('用户积分不足,请充值积分!')
     elif int(u4) > 4000:
         print('积分充足!准备执行用例......')
     else:
         print('用户积分为0,请检查环境!')
     # 数据库初始化
     self.db = pymysql.connect(
         host=dict_load['mysql']['host'],
         user=dict_load['mysql']['user'],
         password=dict_load['mysql']['pwd'],
     )
     try:
         self.db
         print('数据库连接成功!准备执行用例......')
     except:
         print('数据库连接失败!请检查!')
     self.cursor = self.db.cursor()
     self.cursor.execute('SHOW DATABASES')
     c = MySql.db_Query(self, dict_load['mysql']['商家菜籽db'],
                        dict_load['mysql']['查询商家菜籽sql'])
     c1 = re.findall(r"[(]'(.......+?).", str(c))
     if int(c1[0]) <= 1000000:
         MySql.db_NotQuery(self, dict_load['mysql']['商家菜籽db'],
                           dict_load['mysql']['加菜籽sql'])
         print('菜籽充足!准备执行用例......')
     else:
         print('菜籽充足!准备执行用例......')
Beispiel #2
0
    def test(self):
        print('>>>>>>>>>>>>>>>>>>>未填收货地址 >> 跳转至收货地址填写<<<<<<<<<<<<<<<<<<<<<<')
        # 环境检测
        intializating.initialization.environmentPrepar(self)
        time.sleep(1)
        # 清空收货地址
        MySql.db_NotQuery(self, dict_load['mysql']['清空收货地址db'],
                          dict_load['mysql']['清空收货地址sql'])
        time.sleep(1)
        # 选取商品
        get_goods.get_goods(self)
        time.sleep(1)
        loc = (By.CSS_SELECTOR, dict_load['商品']['立即兑换'])
        WebDriverWait(self.driver, 5).until(
            expected_conditions.visibility_of_element_located(loc))
        means.click(self, 'css', dict_load['商品']['立即兑换'])
        time.sleep(1)
        # 获取跳转收货地址填写页面截图
        means.get_img(self)
        time.sleep(1)
        # 获取收货地址页面元素
        text = means.get_text(self, 'css', dict_load['C端页面元素']['收货地址页面'])
        text1 = re.search(r"^(....)", str(text))
        text2 = text1.group()
        time.sleep(1)

        print(
            '********************************状态*******************************************'
        )
        print('跳转到页面信息:', format(str(text)))
        print(
            '********************************断言*******************************************'
        )
        # 断言
        assert text2 == '收货地址'
        print('用例通过!')
Beispiel #3
0
 def wipe_data(self):
     MySql.db_NotQuery(self, dict_load['mysql']['清空所有订单db'],
                       dict_load['mysql']['清空所有订单sql'])