1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- '''
- @File : push_page.py
- @Time : 2024/11/28 16:24:19
- @Author : dulip3ng
- @Version : 1.0
- @Desc : None
- '''
- from pages.base_page import BasePage
- from playwright.sync_api import Page
- class PushPage(BasePage):
- """
- 选单,下拉独立页面页面模型
- """
- def __init__(self, page:Page, locator):
- super().__init__(page)
- self.locator = locator
-
- def _pick_bill(self, bill_name:str):
- """
- 选择单据,精确匹配
- :param bill_name: 单据名称
- :return:
- """
- self.page.locator(self.locator.BILL_ARGSLOC % bill_name).click()
- def _select_bill_type(self, bill_type:str):
- """
- 选择单据类型,精确匹配
- :param bill_type: 单据类型名称,可选参数
- :return:
- """
- self.page.locator(self.locator.BILL_TYPE_LOC).click()
- self.page.locator(self.locator.SELECT_ITEM_ARGS_LOC % bill_type).click()
- def _select_convert_rule(self, rule_name:str):
- """
- 选择单据转换规则,精确匹配
- :param rule_name: 转换规则名称,可选参数
- :return:
- """
- self.page.locator(self.locator.CONVERT_RULE_LOC).click()
- self.page.locator(self.locator.SELECT_ITEM_ARGS_LOC % rule_name).click()
- def _select_target_org(self, org_name:str):
- """
- 选择目标组织,精确匹配
- :param org_name:
- :return:
- """
- self.page.locator(self.locator.TARGET_ORG_LOC).click()
- self.page.locator(self.locator.SELECT_ITEM_ARGS_LOC % org_name).click()
- def _click_ok_button(self):
- """
- 点击下推页面确定按钮
- :return:
- """
- self.page.locator(self.locator.OK_BUTTON_LOC).click()
- def push_draw_bill(self, bill_name:str, rule_name:str=None, bill_type:str=None, org_name:str=None):
- """
- 设置单据,单据类型,转换规则,目标组织进行下推操作
- **用法:**
- PushPage.push_draw_bill("生产订单")
- PushPage.push_draw_bill("生产订单", "犀牛销售订单2生产订单", "直接入库-普通生产", "制衣事业部")
- :param bill_name: 下游单据名称,精确匹配,必填
- :param rule_name: 转换规则,精确匹配,可选
- :param bill_type: 单据类型,精确匹配,可选
- :param org_name: 目标组织名,精确匹配,可选
- :return:
- """
- self.page.wait_for_load_state("networkidle")
- self._pick_bill(bill_name)
- # 下推时切换单据,页面会请求单据对应的转换规则,重新渲染转换规则下拉框,偶发渲染完成时点击太快报选择不上下拉选项问题,
- # 等待1秒,使其降低点击速度,增加稳定性
- self.page.wait_for_timeout(1000)
- if rule_name: self._select_convert_rule(rule_name)
- if bill_type: self._select_bill_type(bill_type)
- if org_name: self._select_target_org(org_name)
- self._click_ok_button()
|