Beispiel #1
0
from public.common import datainfo
from config import globalparam
from time import sleep
import time
from public.pages.SubmitToBillPageConfig import SubmitToBillPageConfig


class CreateBillData(basepage.Page):
    def getBillData(self):
        self.alertAccept()


if __name__ == '__main__':
    #获取单据字段数据模板文件内容,字典,key = filed+itemName
    #billList = datainfo.getAllData("allBaseData.xlsx","bill")
    dr = pyselenium.PySelenium("ie")
    # sleep(4)
    sleep(1)
    dr.max_window()
    fsscTest = CreateBillData(dr)
    fsscTest.openSystem(globalparam.system_address)
    fsscTest.loginSystem("admin", "1")
    #fsscTest.intoModular("系统管理/单据定义/单据定义")
    fsscTest.infoPrint("系统管理/单据定义/单据定义")
    fromIndex = "home.pathGo('designer/manageForm.jsf?" + str(
        time.time()) + "',this)"
    fsscTest.dr.js(fromIndex)
    # sleep(5)
    sleep(1)
    #切换iframe
    fsscTest.switch_to_iframe(SubmitToBillPageConfig.mainIframe)
Beispiel #2
0
def ObtainData(bill_grounp, bill_name):
    # bill_dict = {
    #     "主表区-字段1": [0,1],
    #     "主表区-字段2": [1,1],
    # }

    # #获取单据所有字段文件数据列表
    # billItemData = datainfo.getAllDataDict("allItemData_HT.xls","billData")
    # #定义列表对象
    # billList = datainfo.getAllDataList("allBill_HT.xls","allBill")

    #定义数据字段数据列表
    field_Data = {}
    #定义对象
    dr = pyselenium.PySelenium("ie")
    sleep(2)
    #浏览器最大化
    dr.max_window()
    #所有页面的基类
    MTestPage = basepage.Page(dr)
    sleep(2)
    #输入测试环境地址
    MTestPage.openSystem(globalparam.system_address)
    #输入账号密码
    MTestPage.loginSystem("admin", "1")

    ####************************************************************************************
    #进入系统  移动填单字段配置
    MTestPage.infoPrint("系统管理/单据定义/移动填单字段配置")
    #移动填单字段配置xpath
    fromIndex = "home.pathGo('form/mobileFieldConfig.jsf?" + str(
        time.time()) + "',this)"
    MTestPage.dr.js(fromIndex)
    sleep(2)
    # switch_to_iframe切换表单
    MTestPage.switch_to_iframe(BasePageConfig.mainIframe)
    #点击单据组"可以传任何一个单据组"
    useSelect = "xpath->//div[@title='{}']/img".format(bill_grounp)
    # BXZ = MTestPage.getElement(useSelect)
    # BXZ.click()
    #*****
    MTestPage.clickIE(useSelect)
    sleep(1)
    #选择表单
    DSingle = "xpath->//div[@title='{}']".format(bill_name)
    # SQD =MTestPage.getElement(DSingle)
    # SQD.click()
    MTestPage.clickIE(DSingle)
    sleep(1)
    #**判断  是否启用移动填单是否勾选  是,生成xls. 否,不生成.
    #获取勾选框xpath
    mobileBill = "xpath->//input[@id='mobileBill']"
    mob = MTestPage.getElement(mobileBill)

    if mob.is_selected():
        #获取下拉框区域xpath
        XLK = "xpath->//select[@id='billfieldtype']"
        xlk1 = MTestPage.getElement(XLK)
        a = Select(xlk1)
        #根据option索引来定位下拉选项主表区/明细区
        # a.select_by_index(0)
        #循环下拉区域
        i = 0
        while i < len(a.options):
            a.select_by_index(i)
            #**判断是否启动移动区域,勾选生成文件,否,获取移动区域xpath
            mobileBillFieldCheck = "xpath->//input[@id='mobileBillFieldCheck']"
            mobFC = MTestPage.getElement(mobileBillFieldCheck)
            #判断区域字段是否可见
            if mobFC.is_selected():
                #***获取下拉文本信息
                drop_text = a.options[i].text  ####
                #对文本信息文字切割    引用丰富TextCutexx
                Cute_text = TextCutexx(drop_text)
                # So = "xpath->//input[@id='itemdisplay']"
                # ZDso = MTestPage.getElement(So)
                #获取移动审批所有字段的元素xpath,返回一个字段元素列表
                # ZdName = "xpath->//tr[@id='hiddenTr']"
                # ZD1 = MTestPage.getElements(ZdName)
                Ziduan_Xpath = "xpath->//tr[@id='hiddenTr'and @name='cloneTr']"
                Zid_elementlist = MTestPage.getElements(Ziduan_Xpath)

                #循环遍历区域字段元素
                for ZD_element in Zid_elementlist:
                    #获取字段名称   #*****通过字段元素定位xpath
                    ZidName = ZD_element.find_element_by_xpath(
                        "td[2]/input").get_attribute("value")
                    #通过元素获取子元素
                    Zi_element = ZD_element.find_element_by_xpath(
                        "td[4]/input")

                    #判断判断填单字段元素(hiddenTr)是否可见
                    if Zi_element.is_selected():
                        inputShow = 1
                    else:
                        inputShow = 0
                    #拼接key *********下拉文本信息,字段名称
                    Zid_key = "{}-{}".format(Cute_text, ZidName)
                    #打印字段键
                    print(Zid_key)
                    field_Data[Zid_key] = [inputShow]
            i += 1

    #默认恢复页面,再进入移动审批菜单
    #MTestPage.switch_to.default_content()
    MTestPage.dr.driver.switch_to.default_content()

    # ### """获取移动审批字段"""********************************************************************
    # 移动填单字段配置xpath
    fromIndex = "home.pathGo('form/mobileApprovalConfig.jsf?" + str(
        time.time()) + "',this)"
    MTestPage.dr.js(fromIndex)
    sleep(2)
    # switch_to_iframe切换表单
    MTestPage.switch_to_iframe(BasePageConfig.mainIframe)
    # 点击单据组
    useSelect = "xpath->//div[@title='{}']/img".format(bill_grounp)
    # BXZ = MTestPage.getElement(useSelect)
    # BXZ.click()
    #******点击元素
    MTestPage.click(useSelect)
    sleep(1)
    # 选择表单
    DSingle = "xpath->//div[@title='{}']".format(bill_name)
    # SQD = MTestPage.getElement(DSingle)
    # SQD.click()
    #点击元素
    MTestPage.click(DSingle)
    sleep(1)
    # **判断  是否启用移动填单是否勾选  是,生成xls. 否,不生成.
    # 获取勾选框xpath
    mobileBill = "xpath->//input[@id='mobileBill']"
    mob = MTestPage.getElement(mobileBill)

    if mob.is_selected():
        # 获取下拉框区域xpath
        XLK = "xpath->//select[@id='billfieldtype']"
        xlk1 = MTestPage.getElement(XLK)
        a = Select(xlk1)
        # 根据option索引来定位下拉选项主表区/明细区
        # a.select_by_index(0)
        # 循环下拉区域
        i = 0
        while i < len(a.options):
            a.select_by_index(i)
            # **判断是否启动移动区域,勾选生成文件,否,获取移动区域xpath
            mobileBillFieldCheck = "xpath->//input[@id='mobileBillFieldCheck']"
            mobFC = MTestPage.getElement(mobileBillFieldCheck)
            # 判断区域字段是否可见
            if mobFC.is_selected():
                # ***获取下拉文本信息
                drop_text = a.options[i].text  ####
                # 对文本信息文字切割    引用方法extCutexx
                Cute_text = TextCutexx(drop_text)
                #获取所有字段xpath
                Ziduan_Xpath = "xpath->//tr[@id='hiddenTr'and @name='cloneTr']"
                #获取字段元素
                Zid_elementlist = MTestPage.getElements(Ziduan_Xpath)

                # 循环遍历区域字段元素
                for ZD_element in Zid_elementlist:
                    # 获取字段名称   #*****通过字段元素定位xpath
                    ZidName = ZD_element.find_element_by_xpath(
                        "td[3]/input").get_attribute("value")
                    # 通过元素获取子元素
                    Zi_element = ZD_element.find_element_by_xpath(
                        "td[4]/input")

                    # 判断判断填单字段元素()是否显示
                    if Zi_element.is_selected():
                        inputShow = 1
                    else:
                        inputShow = 0

                    # 拼接key *********下拉文本信息(区域),字段名称
                    Zid_key = "{}-{}".format(Cute_text, ZidName)
                    # 打印字段键
                    print(Zid_key)
                    #字段数据的key*********
                    field_Data[Zid_key].append(inputShow)
            i += 1
    #关闭浏览器
    MTestPage.dr.driver.quit()
    #*******返回字段数据
    return field_Data
Beispiel #3
0
from autoTestFrame import pyselenium
from config import globalparam
from time import sleep
from public.pages.SubmitToBillPage import SubmitToBillPage
from public.pages.billTestData import BillTestData
if __name__ == '__main__':
    dr = pyselenium.PySelenium(globalparam.browser)
    sleep(4)
    dr.max_window()
    fsscTest = SubmitToBillPage(dr)
    billName = "8.01-事项申请单"
    fillPerson = "填单用户001"
    approvalModel = "Manual"
    testCaseFile = "AutoTestGroup\\8.01-事项申请单-01.xls"
    testCaseData = BillTestData(testCaseFile)
    #fillPerson = testCaseData.handleUsers["1"]
    #打开系统,使用指定用户登陆系统
    fsscTest.openSystem(globalparam.system_address)
    fsscTest.login(fillPerson)
    #打开单据
    fsscTest.intoFillBillPage(billName)
    # 获取单据编号
    billNum = fsscTest.getBillNum()
    #给单据输入数据
    fsscTest.typeInputBillValue(testCaseData)
    sleep(1)
    fsscTest.saveBill()
    sleep(2)
    # 跳转iframe
    fsscTest.switchToContentIframe()
    #验证单据数据