class Aa(unittest.TestCase): def setUp(self): self.logger = Logs.getLogger() self.conf = Configs() self.driver = self.conf.getDriver() # 浏览器对象 self.base_url = self.conf.getURL() # 获取URL self.driver.implicitly_wait(30) self.driver.maximize_window() self.verificationErrors = [] self.accept_next_alert = True self.logger.info('初始化测试模板完成') def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) self.logger.info('清理测试模板完成') # 测试名字 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_template(self): u"""测试模板""" log = self.logger log.info('测试测试模板') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始进行测试') sleep(5)
class BreakageManage(unittest.TestCase): def setUp(self): self.logger = Logs.getLogger() self.conf = Configs() self.driver = self.conf.getDriver() # 浏览器对象 self.base_url = self.conf.getURL() # 获取URL self.driver.implicitly_wait(30) self.driver.maximize_window() self.verificationErrors = [] self.accept_next_alert = True self.logger.info('初始化报损管理完成') def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) self.logger.info('清理报损管理完成') # 报损管理_查询 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_A_breakageManage_see(self): u"""scm报损管理_查询""" log = self.logger log.info('测试报损管理_查询') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始报损管理_查询测试') # 定位“报损管理” breakageManage = BreakageManagePage(driver) log.info('已进入报损管理模块') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader( r'\scm_warehouse_manage\BreakageManage\BreakageManageSee_data.xlsx' ) see_values = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取报损管理_查询测试数据') i = 1 at = Asserts() # 创建断言对象 for v in see_values: log.info('第 %d 组测试数据' % i) i += 1 breakageManage.optionWarehouse(v.get('warehouseCode')) breakageManage.optionAuditState(v.get('auditStatus')) breakageManage.optionStockRemovalState(v.get('outStatus')) breakageManage.inputBreakageNumber(v.get('BreakageNumber')) breakageManage.clickSee() sleep(1) es = breakageManage.getBreakageNumbers() at.assertTexts(es, v.get('BreakageNumber'), '报损管理_查询', driver) breakageManage.joinBreakageManage() sleep(0.5)
class PurchaseManage(unittest.TestCase): def setUp(self): self.logger = Logs.getLogger() self.conf = Configs() self.driver = self.conf.getDriver() # 浏览器对象 self.base_url = self.conf.getURL() # 获取URL self.driver.implicitly_wait(30) self.driver.maximize_window() self.verificationErrors = [] self.accept_next_alert = True self.logger.info('初始化采购管理完成') def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) self.logger.info('清理采购管理完成') # 订单管理_查询 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_A_OrderManageSee(self): u"""scm订单管理_查询""" log = self.logger log.info('测试订单管理_查询') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始订单管理_查询测试') # 定位“订单管理” orderManage = OrderManagePage(driver) log.info('已进入订单管理页面') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader(r'\scm_PurchaseManage\OrderManageSee_data.xlsx') see_values = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取订单管理_查询测试数据') i = 1 at = Asserts() # 创建断言对象 for v in see_values: log.info('第 %d 组测试数据' % i) i += 1 orderManage.inputOrderNumber(v.get('OrderNumber')) orderManage.optionWarehouse(v.get('Warehouse')) orderManage.optionStorageLocation(v.get('StorageLocation')) orderManage.inputSupplier(v.get('Supplier')) orderManage.optionInventoryState(v.get('InventoryState')) orderManage.inputBuyer(v.get('Buyer')) orderManage.optionOrderState(v.get('OrderState')) orderManage.clickSee() sleep(1) log.info('开始断言') es1 = orderManage.getOrderBasicInfors() at.assertValueInTexts(es1, v.get('OrderNumber'), '订单管理查询_采购单号', driver) at.assertValueInTexts(es1, v.get('Warehouse'), '订单管理查询_仓库', driver) at.assertValueInTexts(es1, v.get('StorageLocationAssert'), '订单管理查询_库位', driver) at.assertValueInTexts(es1, v.get('Supplier'), '订单管理查询_供应商', driver) es2 = orderManage.getStates() at.assertValueInTexts(es2, v.get('InventoryState'), '订单管理查询_入库状态', driver) at.assertValueInTexts(es2, v.get('OrderState'), '订单管理查询_订单状态', driver) es3 = orderManage.getOthers() at.assertValueInTexts(es3, v.get('Buyer'), '订单管理查询_采购员', driver) log.info('断言通过') orderManage.joinOrderManagePage() # 退货管理_查询 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_B_SalesReturnManageSee(self): u"""scm退货管理_查询""" log = self.logger log.info('测试退货管理_查询') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始退货管理_查询测试') # 定位“退货管理” salesReturnManage = SalesReturnManagePage(driver) log.info('已进入退货管理页面') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader(r'\scm_PurchaseManage\OrderManageSee_data.xlsx') see_values = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取退货管理_查询测试数据') i = 1 at = Asserts() # 创建断言对象 for v in see_values: log.info('第 %d 组测试数据' % i) i += 1
class OtherOutbound(unittest.TestCase): def setUp(self): self.logger = Logs.getLogger() self.conf = Configs() self.driver = self.conf.getDriver() # 浏览器对象 self.base_url = self.conf.getURL() # 获取URL self.driver.implicitly_wait(30) self.driver.maximize_window() self.verificationErrors = [] self.accept_next_alert = True self.logger.info('初始化其他出库完成') def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) self.logger.info('清理其他出库完成') # 其他出库_查询 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_A_OtherOutboundSee(self): u"""scm其他出库_查询""" log = self.logger log.info('测试其他出库_查询') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始其他出库_查询测试') # 定位“其他出库” otherOutbound = OtherOutboundPage(driver) log.info('已进入损益管理模块') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader( r'\scm_warehouse_manage\OtherOutbound\OtherOutboundSee_data.xlsx') see_values = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取损益管理_查询测试数据') i = 1 at = Asserts() # 创建断言对象 for v in see_values: log.info('第 %d 组测试数据' % i) i += 1 otherOutbound.optionWarehouse(v.get('Warehouse')) otherOutbound.optionCheckState(v.get('CheckState')) otherOutbound.optionStockRemovalState(v.get('StockRemovalState')) otherOutbound.inputOtherOrderNumber(v.get('OtherOrderNumber')) otherOutbound.clickSee() sleep(1) log.info('开始断言') es1 = otherOutbound.getOtherOrderNumbers() at.assertValueInTexts(es1, v.get('OtherOrderNumber'), '其他出库查询_单号', driver) es2 = otherOutbound.getCheckStates() at.assertValueInTexts(es2, v.get('CheckState'), '其他出库查询_审核状态', driver) es3 = otherOutbound.getStockRemovalStates() at.assertValueInTexts(es3, v.get('StockRemovalState'), '其他出库查询_出库状态', driver) es4 = otherOutbound.getWarehouses() at.assertValueInTexts(es4, v.get('Warehouse'), '其他出库查询_仓库', driver) log.info('断言通过') otherOutbound.joinOtherOutbound()
class Login(unittest.TestCase): def setUp(self): self.log = Logs.getLogger() self.verificationErrors = [] self.accept_next_alert = True self.conf = Configs() # 创建配置对象 self.log.info('登录测试初始化完成') def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) self.log.info('清理登录完成') # scm登录测试 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_A_login(self): u"""scm登录测试""" log = self.log log.info('测试登录') data_path = self.conf.getDataPath() # 获取登录测试数据路径 file_path = data_path + r'\scm_login\login_data.txt' path = self.conf.getScreenshotPath() # 获取截图路径 f = open(file_path, "r") log.info('已获得测试数据文件') ups = [] try: lines = f.readlines() # 一次性读取整个文件,并安行为单位分成列表 for line in lines: li = re.split(',', line) ups.append(li) finally: f.close() log.info('已获得测试数据') i = 1 for up in ups: log.info('第 %d 组测试数据' % i) i = i + 1 self.driver = self.conf.getDriver() # 浏览器对象 self.base_url = self.conf.getURL() # 获取URL driver = self.driver driver.get(self.base_url) log.info('已进入登录页面') # 调用登录模块 login.login_test(self, up[0], up[1], up[2]) time.sleep(2) log.info('已调用登录模块,断言登录') # 判断是否登录是否正确 now_time = time.strftime("%Y%m%d-%H%M%S", time.localtime()) try: e = driver.find_element_by_xpath( '//*[@id="root"]/div/div[1]/div[2]/span') at = Asserts() # 创建断言对象 at.assertText(e, up[3], '账号不匹截图', driver) # text断言一个元素 except: driver.get_screenshot_as_file(path + '\\' + up[4] + '[' + now_time + '].png') # 截图操作 print('登录失败截图成功') print(path) log.info('断言通过') time.sleep(1) driver.quit()
class SupplyChainManage(unittest.TestCase): def setUp(self): self.logger = Logs.getLogger() self.conf = Configs() self.driver = self.conf.getDriver() # 浏览器对象 self.base_url = self.conf.getURL() # 获取URL self.driver.implicitly_wait(30) self.driver.maximize_window() self.verificationErrors = [] self.accept_next_alert = True self.logger.info('初始化供应链管理完成') def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) self.logger.info('清理供应链管理完成') # 地点管理_查询 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_A_locationManageSee(self): u"""scm地点管理_查询""" log = self.logger log.info('测试地点管理_查询') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始地点管理_查询测试') # 定位“库存管理” addressmanage = AddressManage(driver) # 创建对象,直接进入页面 log.info('已进入地点管理模块') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader(r'\scm_SupplyChainManage\LocationManageSee_data.xlsx') seevalues = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取地点管理_查询测试数据') i = 1 at = Asserts() # 创建断言对象 for v in seevalues: log.info('第 %d 组测试数据' % i) i += 1 addressmanage.optionWarehouse(v.get('Warehouse')) # 选择仓库 addressmanage.optionCity(v.get('City')) # 选择城市 log.info('已输入完查询信息') addressmanage.clickSee() # 点击查询 sleep(1.5) e = addressmanage.getWarehouse() # 获取查询结果中的仓库元素 log.info('已输查询到信息,开始断言') av = v.get('AssertValue1') + '\n' + v.get('AssertValue2') # 拼接断言值 print(av) at.assertText(e, av, '地点管理_查询', driver) log.info('断言通过') sleep(1) addressmanage.joinAddressManage() # 再次进入地址管理页面 # 地点管理_编辑 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_B_locationManageEdit(self): u"""scm地点管理_编辑""" log = self.logger log.info('测试地点管理_编辑') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始地点管理_编辑测试') # 定位“库存管理” addressmanage = AddressManage(driver) # # 创建对象,直接进入页面 log.info('已进入地点管理模块') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader( r'\scm_SupplyChainManage\LocationManageEdit_data.xlsx') edit_values = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取地点管理_编辑测试数据') i = 1 at = Asserts() # 创建断言对象 for v in edit_values: log.info('第 %d 组测试数据' % i) i += 1 addressmanage.optionWarehouse(v.get('Warehouse')) # 选择仓库 log.info('已输入完查询信息') addressmanage.clickSee() # 点击查询 sleep(0.5) # 必须有 addressmanage.clickEdit() # 点击编辑 log.info('已进入编辑弹框') addressmanage.inputContactMan(v.get('ContactMan')) # 输入联系人 addressmanage.inputTelephone(v.get('inputTelephone')) # 输入电话 addressmanage.clickSave() # 点保存 sleep(1) # 必须加等待时间,因为元素以存在,当时内容为空,等待一会才有内容 e = addressmanage.getAlertInfoElement() # 获取操作提示信息元素 log.info('已编辑完成,开始断言') at.assertText(e, '操作成功!', '地点管理_编辑', driver) log.info('断言通过') sleep(0.5) addressmanage.clickClose() # 关闭提示信息弹框 sleep(0.5) addressmanage.joinAddressManage() # 再次进入地址管理页面 # 地点管理_新增 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_C_locationManageNewAddress(self): u"""scm地点管理_编辑""" log = self.logger log.info('测试地点管理_新增') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始地点管理_新增测试') # 定位“库存管理” addressmanage = AddressManage(driver) # 创建对象,直接进入页面 log.info('已进入地点管理模块') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader( r'\scm_SupplyChainManage\LocationManageNewAddress_data.xlsx') edit_values = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取地点管理_新增测试数据') i = 1 at = Asserts() # 创建断言对象 for v in edit_values: log.info('第 %d 组测试数据' % i) i += 1 addressmanage.clickNewAddress() # 点击“新增地点” log.info('已进入新增弹框,开始填写信息') now_time = time.strftime("%M%S", time.localtime()) # 获取当前系统时间 AddressCode = v.get('AddressCode') + now_time # 拼接仓库编码 AddressName = v.get('AddressName') + now_time # 拼接仓库名称 # print(AddressCode) addressmanage.inputAddressCode(AddressCode) addressmanage.inputAddressName(AddressName) addressmanage.inputWarehouseAddress(v.get('WarehouseAddress')) addressmanage.inputContactMan(v.get('ContactMan')) addressmanage.inputTelephone(v.get('Telephone')) addressmanage.optionProvinceNewAdd(v.get('ProvinceNewAdd')) addressmanage.optionCityNewAdd(v.get('CityNewAdd')) addressmanage.optionCountyNewAdd(v.get('CountyNewAdd')) addressmanage.clickYes() # 设为可用 sleep(0.5) addressmanage.clickSave() sleep(0.5) # 必须加等待时间,因为元素以存在,当时内容为空,等待一会才有内容 e = addressmanage.getAlertInfoElement() # 获取操作提示信息元素 log.info('已新增完成,开始断言') at.assertText(e, '操作成功!', '地点管理_编辑', driver) log.info('断言通过') sleep(0.5) addressmanage.clickClose() # 关闭提示信息弹框 sleep(0.5) addressmanage.joinAddressManage() # 再次进入地址管理页面 # 地点管理_查询明细 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_D_locationManageSeeDetail(self): u"""scm地点管理_查询明细""" log = self.logger log.info('测试地点管理_查询明细') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始地点管理_查询明细测试') # 定位“库存管理” addressmanage = AddressManage(driver) # 创建对象,直接进入页面 log.info('已进入地点管理模块') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader(r'\scm_SupplyChainManage\LocationManageSee_data.xlsx') seeDetail_values = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取地点管理_查询明细测试数据') i = 1 at = Asserts() # 创建断言对象 for v in seeDetail_values: log.info('第 %d 组测试数据' % i) i += 1 Warehouse = v.get('Warehouse') addressmanage.optionWarehouse(Warehouse) # 选择仓库 # addressmanage.optionProvince(v.get('Province')) # 选择省份 addressmanage.optionCity(v.get('City')) # 选择城市 log.info('已输入完查询信息') addressmanage.clickSee() # 点击查询 sleep(0.5) addressmanage.clickSeeDetail() # 点击查看明细 sleep(1) e = addressmanage.inputAddressName() # 获取地址名称元素:不传值时,返回元素 log.info('已查询到明细,开始断言') at.assertAttribute(e, Warehouse, 'value', '地点管理_查询明细', driver) log.info('断言通过') addressmanage.clickCancel() # 点击取消,便于下一组测试数据测试 log.info('已点几取消') sleep(1) addressmanage.joinAddressManage() # 再次进入地址管理页面 # 辐射管理_查询 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_E_radiateManageSee(self): u"""scm辐射管理_查询""" log = self.logger log.info('测试辐射管理_查询') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始辐射管理_查询测试') # 定位“库存管理” radiateManage = RadiateManage(driver) log.info('已进入地点管理模块') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader(r'\scm_SupplyChainManage\RadiateManageSee_data.xlsx') see_values = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取地点管理_查询明细测试数据') i = 1 at = Asserts() # 创建断言对象 for v in see_values: log.info('第 %d 组测试数据' % i) i += 1 radiateManage.optionWarehouse(v.get('Warehouse')) radiateManage.inputShop(v.get('ShopName')) radiateManage.optionCity(v.get('City')) radiateManage.optionShopType(v.get('ShopType')) radiateManage.optionShopState(v.get('ShopState')) log.info('已输入信息,开始查询') radiateManage.clickSee() sleep(1) e = radiateManage.getShopName() log.info('已查询到结果,开始断言') at.assertText(e, v.get('ShopName'), '辐射管理_查询', driver) log.info('断言通过') sleep(1) radiateManage.joinRadiateManage()
class ReplenishManage(unittest.TestCase): def setUp(self): self.logger = Logs.getLogger() self.conf = Configs() self.driver = self.conf.getDriver() # 浏览器对象 self.base_url = self.conf.getURL() # 获取URL self.driver.implicitly_wait(30) self.driver.maximize_window() self.verificationErrors = [] self.accept_next_alert = True self.logger.info('初始化补货管理完成') def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) self.logger.info('清理补货管理完成') # 补货管理_查询 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_A_ReplenishManageSee(self): u"""scm补货管理_查询""" log = self.logger log.info('测试补货管理_查询') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始补货管理_查询测试') # 定位“补货管理” replenishManage = ReplenishManagePage(driver) log.info('已进入补货管理模块') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader( r'\scm_warehouse_manage\ReplenishManage\ReplenishManageSee_data.xlsx' ) see_values = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取补货管理_查询测试数据') i = 1 at = Asserts() # 创建断言对象 for v in see_values: log.info('第 %d 组测试数据' % i) i += 1 replenishManage.optionWarehouse(v.get('Warehouse')) replenishManage.inputReplenishNumber(v.get('ReplenishNumber')) replenishManage.inputOutboundNumber(v.get('OutboundNumber')) replenishManage.inputShop(v.get('Shop')) replenishManage.optionState(v.get('State')) replenishManage.clickSee() sleep(1) log.info('开始断言') es1 = replenishManage.getReplenishNumbers() at.assertValueInTexts(es1, v.get('ReplenishNumber'), '补货管理查询_需求单号', driver) es2 = replenishManage.getOutboundNumbers() at.assertValueInTexts(es2, v.get('OutboundNumber'), '补货管理查询_波次单号', driver) es3 = replenishManage.getWareHouses() at.assertValueInTexts(es3, v.get('Warehouse'), '补货管理查询_仓库', driver) es5 = replenishManage.getShops() at.assertValueInTexts(es5, v.get('Shop'), '补货管理查询_货柜', driver) es6 = replenishManage.getStates() at.assertValueInTexts(es6, v.get('State'), '补货管理查询_状态', driver) log.info('断言通过') replenishManage.joinReplenishManage()
class AllotManage(unittest.TestCase): def setUp(self): self.logger = Logs.getLogger() self.conf = Configs() self.driver = self.conf.getDriver() # 浏览器对象 self.base_url = self.conf.getURL() # 获取URL self.driver.implicitly_wait(30) self.driver.maximize_window() self.verificationErrors = [] self.accept_next_alert = True self.logger.info('初始化调拨管理完成') def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) self.logger.info('清理调拨管理完成') # 调拨管理_查询 # @unittest.skip("跳过这条用例执行") # 跳过这个用例 def test_A_allotManageSee(self): u"""scm调拨管理_查询""" log = self.logger log.info('测试调拨管理_查询') driver = self.driver driver.get(self.base_url) jumplogin.jumpLogin(self) # 跳过登录,跳过验证码,若已有cookie信息已过期则调用等模块 log.info('已跳过登录') joinscm.joinScm(self) # 进入scm joinscm.joinScmIframe(self) # 跳入scm_iframe log.info('已进入scm_iframe') """========开始测试内容=====================================================""" log.info('开始调拨管理_查询测试') # 定位“调拨管理” allotManage = AllotManagePage(driver) log.info('已进入调拨管理模块') # 获取测试用例数据(需要传入测试用例数据文件再各环境中的测试目录) rf = ExcelReader( r'\scm_warehouse_manage\AllotManage\AllotManageSee_data.xlsx') see_values = rf.getTestData # 调用此方法时不需要加括号 log.info('以获取调拨管理_查询测试数据') i = 1 at = Asserts() # 创建断言对象 for v in see_values: log.info('第 %d 组测试数据' % i) i += 1 allotManage.optionOutWarehouse(v.get('OutWarehouse')) allotManage.optionOutStorageLocation(v.get('OutStorageLocation')) allotManage.optionJoinWarehouse(v.get('JoinWarehouse')) allotManage.optionJoinStorageLocation(v.get('JoinStorageLocation')) allotManage.optionAllotType(v.get('AllotType')) allotManage.inputAllotNumber(v.get('AllotNumber')) allotManage.optionAllotNumberState(v.get('AllotNumberState')) allotManage.optionOutPutState(v.get('OutPutState')) log.info('已输入完信息') allotManage.clickSee() sleep(1) log.info('获取短信信息') es = allotManage.getAllotNumbers() log.info('开始断言') at.assertValueInTexts(es, v.get('OutWarehouse'), '调拨管理查询_调出仓库', driver) at.assertValueInTexts(es, v.get('OutStorageLocation'), '调拨管理查询_调出仓库', driver) at.assertValueInTexts(es, v.get('JoinWarehouse'), '调拨管理查询_调入仓库', driver) at.assertValueInTexts(es, v.get('JoinStorageLocation'), '调拨管理查询_调入库位', driver) at.assertValueInTexts(es, v.get('AllotNumber'), '调拨管理查询_调拨单号', driver) log.info('断言通过') allotManage.joinAllotManage() sleep(0.5)