12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- '''
- @File : home_page.py
- @Time : 2024/11/06 22:51:00
- @Author : dulip3ng
- @Version : 1.0
- @Desc : None
- '''
- from pages.base_page import BasePage
- from playwright.sync_api import Page, expect
- class HomePage(BasePage):
-
- def __init__(self, page:Page, locator):
- super().__init__(page)
- self.locator = locator
- def change_org(self, org_num:str):
- """
- 切换组织
- :param org_num:组织代码
- :return: None
- """
- self.page.locator(self.locator.ORGANIZATION_LOC).click()
- self.page.locator(self.locator.ORG_ITEM_ARGS_LOC % org_num).nth(0).click()
- def search_bill(self, bill_name:str, order:int=1):
- """
- 查询并打开单据
- :param bill_name:单据名称
- :param order: 重名单据的情况下打开第几个
- :return: None
- """
- self.page.locator(self.locator.SEARCH_IMG_LOC).click()
- locator = self.page.locator(self.locator.SEARCH_LOC)
- locator.clear()
- locator.fill(bill_name)
- locator.press_sequentially(" ")
- locator.press("Backspace")
- self.page.locator(self.locator.BILL_LIST_ARGS_LOC % (bill_name, order)).click()
- expect(self.page.locator(self.locator.BILL_OPEN_ARGS_LOC % bill_name)).to_be_attached()
- self.page.wait_for_load_state("networkidle")
- def close_bill_by_name(self, bill_name:str):
- """
- 点击单据页签的"x"图标关闭单据,模糊匹配
- :TODO: 加入关闭单据提示
- :param bill_name:单据名称
- :return: None
- """
- self.page.locator(self.locator.BILL_CLOSE_ARGS_LOC % bill_name).click()
- def close_all_opening_bills(self):
- """
- 关闭所有已打开单据页签
- :TODO: 加入关闭单据提示
- :return: None
- """
- self.page.locator(self.locator.ALL_OPEN_FORM_BTN_LOC).click()
- self.page.locator(self.locator.CLOSE_ALL_BILLS_ITEM_LOC).click()
- def is_bill_opening(self, bill_name:str):
- """
- 判断单据是否是打开状态, 默认等待5秒
- :param bill_name:单据名称
- :return:打开True,未打开False
- """
- try:
- loctor = self.page.locator(self.locator.IS_BILL_OPENING_ARGS_LOC % bill_name)
- expect(loctor).to_be_attached()
- return True
- except AssertionError:
- return False
- def change_bill_tab(self, bill_name:str):
- """
- 在已打开单据间切换
- :param bill_name:单据名称
- :return: None
- """
- self.page.locator(self.locator.BILL_TAB_ARGS_LOC % bill_name).click()
- expect(self.page.locator(self.locator.BILL_OPEN_ARGS_LOC % bill_name)).to_be_attached()
|