from datetime import datetime from playwright.sync_api import expect from common.condition_row import ConditionRow from pages.locator.body_page_locator import BodyPageLocator from tests.test_case.pur.test_data.data_pur_product import DataPurProduct import pytest TODAY = datetime.now().strftime('%Y-%m-%d') wwdddjbh = "SUB00002415" # 委外订单 单据编号 # 执行时间:4min 首次运行,选择物料加载超时。加等待。 @pytest.fixture(scope="module", autouse=True) def setup_teardown(orcl_helper): print(orcl_helper.execute_update(DataPurProduct.CREATE_SUBREQORDER_TEST_DATA)) # 单据编号=SUB00002415 yield # def test_subreqorder(page, home_page, head_page, body_page): # """ # 【委外成品采购】新增委外订单 # """ # home_page.change_org("鲁泰纺织") # home_page.close_all_opening_bills() # home_page.search_bill("委外订单") # # body_page.set_value(1, "物料编码", "P01C24-04904") # # body_page.get_value() # loc = page.locator(BodyPageLocator.FIELD_VALUE_ARGS_LOC % ("物料编码", 0, 1)) # 行号(从0开始),重名时第几个(从1开始) # expect(loc).to_contain_text("P01C24-04904", timeout=60000) # 等待 默认5000ms # # body_page.set_value(1, "数量", "5") # body_page.set_value(1, "供应商", "滨州市鑫笑服饰有限公司") # body_page.set_value(1, "衬衣订单号", "41324033") # body_page.set_value(1, "计划跟踪号", "20250102") # body_page.set_value(1, "尺码", "均码") # body_page.set_value(1, "销售类别", "外销") # # body_page.set_value(2, "物料编码", "P01C24-04906") # loc = page.locator(BodyPageLocator.FIELD_VALUE_ARGS_LOC % ("物料编码", 1, 1)) # expect(loc).to_contain_text("P01C24-04906") # 等待 # # body_page._activate_field(1, "数量") # body_page.click_button("批量填充") # body_page._activate_field(1, "供应商") # body_page.click_button("批量填充") # body_page._activate_field(1, "衬衣订单号") # body_page.click_button("批量填充") # body_page._activate_field(1, "计划跟踪号") # body_page.click_button("批量填充") # body_page.set_value(2, "尺码", "均码") # 尺码批量填充无效,只能set # body_page._activate_field(1, "销售类别") # body_page.click_button("批量填充") # # head_page.click_button("保存") # head_page.click_button("提交") # head_page.click_button("审核") # # global wwdddjbh # wwdddjbh = head_page.get_value("单据编号") # assert wwdddjbh != "" def test_purchaseorder(page, home_page, list_page, filter_page, head_page, body_page, push_page): """ 【委外成品采购】委外订单 下推 采购订单(标准委外订单) """ home_page.search_bill("委外订单列表") list_page.click_button("过滤") global wwdddjbh cond1 = ConditionRow(1, "单据头-单据编号", wwdddjbh) filter_page.filter(cond1) list_page.wait_list_loaded() list_page.check_line_by_rows(1, 2) list_page.click_button("下推") push_page.push_draw_bill("采购订单") head_page.set_value("采购部门", "制衣计划调度科") head_page.set_value("采购组", "委外采购组") head_page.set_value("采购员", "蒙顺德") head_page.set_value("采购合同交期", TODAY) head_page.set_value("是否保税", "否") body_page.set_value(1, "含税单价", "27") body_page.set_value(1, "需求部门", "制衣计划调度科") body_page.set_value(1, "物料来源", "自备") body_page._activate_field(1, "含税单价") body_page.click_button("批量填充") body_page._activate_field(1, "需求部门") body_page.click_button("批量填充") body_page._activate_field(1, "物料来源") body_page.click_button("批量填充") assert body_page.get_row_count() == "2" assert body_page.get_value(1, "采购数量") != "" assert body_page.get_value(2, "采购数量") != "" head_page.click_button("保存") head_page.click_button("提交") head_page.click_button("审核") def test_instock(page, home_page, head_page, body_page, push_page): """ 【委外成品采购】采购订单 下推 采购入库单(委外入库单) """ head_page.click_button("下推") push_page.push_draw_bill("采购入库单") head_page.set_value("收料部门", "仓储管理部") head_page.set_value("仓管员", "翟丽芹") body_page.set_value(1, "仓库", "成品仓库(国外)") body_page.set_value(1, "成品仓库仓位", "1311") body_page._activate_field(1, "仓库") body_page.click_button("批量填充") body_page._activate_field(1, "成品仓库仓位") body_page.click_button("批量填充") head_page.click_button("保存") head_page.click_button("提交") head_page.click_button("审核") # expect(page.locator("//span[text()='普通']").first).to_be_visible(timeout=30000) msg = head_page.get_multi_error_message() assert "采购入库单,审核成功" in msg assert "应付单,审核成功" in msg