Exemplo n.º 1
0
 itemDisplayType = datainfo.getColumnToDict(itemDataFill, "itemDisplayType", "value", "trueType")
 # itemDisplayType = {value : trueType}
 itemDataType = datainfo.getColumnToDict(itemDataFill, "itemDataType", "value", "trueType")
 dataHead = ["field", "itemName", "itemType", "itemId","itemVarName","css","inputValue","verifyValue"]
 dataFilePath = os.path.join(globalparam.data_path, itemDataFill)
 xls1 = xlrd.open_workbook(dataFilePath)
 table = xls1.sheet_by_name("allItem")
 allItemData = list()
 allItemData.append(dataHead)
 for i in range(1,table.nrows):
     item = list()
     print(table.row_values(i))
     try:
         item.append(itemBillType[table.row_values(i)[1]])
     except Exception as e:
         print(e)
     item.append(table.row_values(i)[4])
     trueType = getTrueType(table.row_values(i)[2],table.row_values(i)[3])
     item.append(trueType)
     item.append(table.row_values(i)[0])
     item.append(table.row_values(i)[5])
     if item[2] == "input" or item[2] == "pop" or item[2] == "currency" or item[2] == "date":
         item.append("xpath->//input[@itemvarname='{0}' and @itemid='{1}']".format(table.row_values(i)[5],table.row_values(i)[0]))
     elif item[2] == "select":
         item.append("xpath->//input[@itemvarname='{0}{1}' and @itemid='{2}']".format(table.row_values(i)[5],"_label",table.row_values(i)[0]))
     elif item[2] == "textarea":
         item.append("xpath->//textarea[@itemvarname='{0}' and @itemid='{1}']".format(table.row_values(i)[5],table.row_values(i)[0]))
     print(item)
     allItemData.append(item)
 datainfo.createFile("allItemData"+project+".xls",["billData"],[allItemData])
Exemplo n.º 2
0
        #print(BillGroupList[i].text)#find_element(By.XPATH,"td[3]").
        billGroupName = BillGroupList[i].text
        if "日常费用" not in billGroupName:
            continue
        #点击单据组
        #fsscTest.dr.click_by_element(billGroup)
        fsscTest.click("xpath->//table[@class='rich-tree-node'][" +
                       str(i + 1) + "]/tbody/tr")
        # sleep(3)
        sleep(1)
        # 切换iframe
        fsscTest.switch_to_iframe(SubmitToBillPageConfig.centerFrame)
        #切换到单据定义页签
        vouchers = "xpath->//td[@id='tab2_lbl']"
        fsscTest.click(vouchers)
        bills = fsscTest.dr.get_elements(xpath)
        # sleep(5)
        sleep(1)
        for j in range(0, len(bills)):
            billName = bills[j].text
            bill = [billGroupName, billName]
            allBill.append(bill)
            #fsscTest.click("xpath->//table[@class='rich-tree-node'][" + str(j + 1) + "]/tbody/tr")
            sleep(1)
            #fsscTest.click("xpath->//div[@id='budgetMenu:panel1_body']/table/tbody/tr/td[2]")
        fsscTest.switch_to_parent_iframe()
        #break  #调试只循环一次
    fsscTest.switch_to_iframe_out()
    fsscTest.dr.quit()
    datainfo.createFile("allBill_HT.xls", ["allBill"], [allBill])
Exemplo n.º 3
0
 def inputTrain(self,num,seatType,person):
     recordList = datainfo.getAllDataList("allTrainRecord.xls","allRecord")
     self.switchToContentIframe()
     if num == 1:
         self.click("xpath->//input[@itemvarname='trainno'][1]")
     else:
         self.click("xpath->//img[@areatype='train']")
         sleep(1)
         elements = self.dr.get_elements("xpath->//input[@itemvarname='trainno']")
         elements[num-1].click()
     sleep(1)
     self.switch_to_iframe_out()
     self.switchToJdIframe()
     self.click("xpath->//input[@value='确认']")
     sleep(1)
     self.switch_to_iframe_out()
     self.switchToJdIframe()
     self.dr.element_wait("xpath->//input[@id='fromCity']", 30)
     self.clearType("id->fromCity", "长沙南")
     sleep(1)
     self.clearType("id->toCity","广州南")
     sleep(1)
     dataTime = datetime.datetime.now()
     year = dataTime.year
     month = dataTime.month
     day = dataTime.day
     bookingDate = str(year) + "-" + str(month) + "-" + str(day+num)
     self.clearType("xpath->//input[@name='startDate']",bookingDate)
     sleep(1)
     self.click("xpath->//div[contains(text(),'出发城市')]")
     sleep(1)
     self.click("xpath->//span[@id='start-search']")
     sleep(1)
     self.dr.element_wait("xpath->//span[@class='buy buynow'][1]", 60)
     self.click("xpath->//img[@src='/ie8/images/checkbox-unchecked.png']")
     sleep(1)
     buyNowElements = self.dr.get_elements("xpath->//span[@class='buy buynow']")
     print(len(buyNowElements))
     for element in buyNowElements:
         trainNo = element.get_attribute("trainno")
         seatTypeNow = element.get_attribute("seattype")
         record = [person,trainNo,bookingDate]
         if record in recordList:
             continue
         if seatTypeNow == seatType:
             self.dr.click_by_element(element)
             recordList.append(record)
             break
         sleep(0.1)
     sleep(1)
     self.switch_to_iframe_out()
     self.switchToJdIframe()
     self.dr.element_wait("xpath->//span[contains(text(),'"+person+"')]",60)
     self.click("xpath->//span[contains(text(),'提交审批')]")
     sleep(5)
     self.switch_to_iframe_out()
     datainfo.createFile("allTrainRecord.xls", ["allRecord"], [recordList])
     self.switchToContentIframe()
     self.clearType("xpath->//input[@itemvarname='outstandardmemo' and @areatype='scroll_train_b']["+str(num)+"]","超标说明")
     sleep(2)
     self.switch_to_iframe_out()
Exemplo n.º 4
0
 def inputFlight(self,num,flightType,person):
     recordList = datainfo.getAllDataList("allFlightRecord.xls","allRecord")
     self.switchToContentIframe()
     if num == 1:
         self.click("xpath->//input[@itemvarname='flightno'][1]")
     else:
         self.click("xpath->//img[@areatype='flight']")
         sleep(1)
         elements = self.dr.get_elements("xpath->//input[@itemvarname='flightno']")
         elements[num-1].click()
     sleep(2)
     self.switch_to_iframe_out()
     self.switchToJdIframe()
     self.dr.element_wait("xpath->//input[@id='setInCity']", 30)
     sleep(5)
     setInCity = ""
     setOutCity = ""
     if flightType == 1:
         setInCity = "上海"
         setOutCity = "海口"
     elif flightType == 2:
         setInCity = "郑州"
         setOutCity = "沈阳"
     elif flightType == 3:
         setInCity = "长沙"
         setOutCity = "哈尔滨"
     self.dr.element_wait("xpath->//button[contains(text(),'查询机票')]", 30)
     self.clearType("id->setInCity",setInCity)
     sleep(1)
     self.clearType("id->setOutCity",setOutCity)
     sleep(1)
     self.click("xpath->//input[@placeholder='请选择出发日期']")
     sleep(1)
     self.dr.element_wait("xpath->//td[@class='day']",10)
     dayElements = self.dr.get_elements("xpath->//td[@class='day']")
     delayDay = random.randint(0, len(dayElements)-1)
     dataTime = datetime.datetime.now()
     year = dataTime.year
     month = dataTime.month
     day = dataTime.day
     dayChoose = int(dayElements[delayDay].text)
     dayElements[delayDay].click()
     if day > dayChoose:
         month+=1
     bookingTime = str(year) + "-" + str(month) + "-" + str(dayChoose)
     sleep(1)
     self.click("xpath->//button[contains(text(),'查询机票')]")
     self.dr.element_wait("xpath->//button[@class='select_btn'][1]", 60)
     sleep(1)
     self.click("xpath->//label[contains(text(),'显示所有航班')]")
     sleep(2)
     chooseButtons = self.dr.get_elements("xpath->//button[@class='select_btn']")
     sleep(1)
     #flightElements =self.dr.get_elements("xpath->//div[@class='flight_no']/span")
     print(len(chooseButtons))
     isFixed = False
     for chooseButton in chooseButtons:
         flight = chooseButton.get_attribute('data-flightno')
         record = [person, flight, bookingTime, str(flightType)]
         index = chooseButtons.index(chooseButton) + 1
         if record in recordList:
             continue
         else:
             recordList.append(record)
         sleep(1)
         self.dr.click_by_element(chooseButton)
         sleep(2)
         #//*[@id="flightList"]/div[1]/div[2]/div[2]/div[2]/button
         #//*[@id="flightList"]/div[3]/div[2]/div[2]/div[2]/button
         #//*[@id="flightList"]/div[1]/div[2]/div[2]/div[3]/div/strong
         #//*[@id="flightList"]/div[3]/div[2]/div[2]/div[3]/div/strong
         fixedElements = self.dr.get_elements("xpath->//div[@id='flightList']/div["+str(index)+"]/div[2]/div/div[2]/button")
         priceElements = self.dr.get_elements("xpath->//div[@id='flightList']/div["+str(index)+"]/div[2]/div/div[3]/div/strong")
         print(len(fixedElements))
         print(len(priceElements))
         for fixedElement,priceElement in zip(fixedElements,priceElements):
             price = float(priceElement.text)
             if flightType == 1 and 740<=price<=1440:
                 self.dr.click_by_element(fixedElement)
                 isFixed = True
                 break
             if flightType == 2 and price < 740:
                 self.dr.click_by_element(fixedElement)
                 isFixed = True
                 break
             if flightType == 3 and price > 1440:
                 self.dr.click_by_element(fixedElement)
                 isFixed = True
                 break
         if isFixed:
             break
     sleep(2)
     self.switch_to_iframe_out()
     self.switchToJdIframe()
     self.dr.element_wait("xpath->//button[contains(text(),'提交审批')][1]", 30)
     sleep(1)
     self.click("xpath->//button[contains(text(),'提交审批')][1]")
     sleep(5)
     self.switch_to_iframe_out()
     datainfo.createFile("allFlightRecord.xls",["allRecord"],[recordList])
Exemplo n.º 5
0
                        datas.append(billAllItemData[key])
                    else:
                        if itemType == "单行文本型":
                            itemType = "input"  #也可能是date,pop
                        elif itemType == "多行文本":
                            itemType = "textarea"
                        elif itemType == "货币型":  #数据校验时,货币型数据特殊处理
                            itemType = "currency"
                        elif itemType == "下拉型":
                            itemType = "select"
                        else:
                            itemType = ""
                        item = list()
                        item.append(field)
                        item.append(itemName)
                        item.append(itemType)
                        datas.append(item)
            actionList = list()
            actionList = datainfo.getAllDataList(billDataFilePath, "action")
            if len(actionList) == 0:
                actionList = [["serialNumber", "user", "action"],
                              ["1", "张一", "填单"], ["2", "张二", "审批"]]
            datainfo.createFile(billDataFilePath, ["billData", "action"],
                                [datas, actionList])
            #break  #调试只循环一次
        sleep(1)
        fsscTest.switch_to_parent_iframe()
        #break  #调试只循环一次
    fsscTest.switch_to_iframe_out()
    fsscTest.dr.quit()