销售订单_多明细100.py 22.83 KiB
import datetime
import threading
import time
import traceback
from airtest.core.api import *
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import *
from selenium.webdriver import Chrome, ChromeOptions
from airtest.core.api import *
from airtest_selenium.proxy import *
from public.mail1 import send_email1
from public.tools import *
# chrome = webdriver.Chrome(chrome_options=opt)
def job(type=2):
    print("这是一个需要执行的任务。。。。。")
    create_salesorder(type)
    print("当前线程的个数:", threading.active_count())
    time.sleep(1)
    print("当前线程的信息:", threading.current_thread())
def add_goods(goodsname,chrome):
    sleep(4)
    chrome.find_element_by_xpath(
        '//input[@placeholder="模糊检索:商品编码,商品名称,规格型号,主计量单位,销售计量单位,厂家物料编码,存储条件说明,生产企业编码,供应商编码,行类型,商品性质,批发价,进口/国产/港澳台,件包数,产品备注,是否免备案,产品描述"]').send_keys(
        goodsname)
    sleep(2)
    chrome.find_element_by_xpath(
        '//input[@placeholder="模糊检索:商品编码,商品名称,规格型号,主计量单位,销售计量单位,厂家物料编码,存储条件说明,生产企业编码,供应商编码,行类型,商品性质,批发价,进口/国产/港澳台,件包数,产品备注,是否免备案,产品描述"]').send_keys(
        Keys.ENTER)
    sleep(2)
    #获取页数
    # pagecount=chrome.find_element_by_xpath('(// li[ @class ="number"])[16]').text
    pagecount=10
    for i in range(int(pagecount)):
        # chrome.find_element_by_xpath('//span[text()="添加商品"]').click()
        # chrome.find_element_by_xpath(
        #     '//input[@placeholder="模糊检索:商品编码,商品名称,规格型号,主计量单位,销售计量单位,厂家物料编码,存储条件说明,生产企业编码,供应商编码,行类型,商品性质,批发价,进口/国产/港澳台,件包数,产品备注,是否免备案,产品描述"]').send_keys(
        #     goodsname)
        # chrome.find_element_by_xpath(
        #     '//input[@placeholder="模糊检索:商品编码,商品名称,规格型号,主计量单位,销售计量单位,厂家物料编码,存储条件说明,生产企业编码,供应商编码,行类型,商品性质,批发价,进口/国产/港澳台,件包数,产品备注,是否免备案,产品描述"]').send_keys(
        #     Keys.ENTER)
        sleep(1)
        chrome.find_element_by_xpath(
            '//th[@class="el-table_18_column_269 multiple-column el-table-column--selection is-leaf headerCellClassName el-table__cell"]/div/label/span/span').click()
        #翻页
        sleep(2)
        chrome.find_element_by_xpath('(//button[@class="btn-next is-last"])[6]').click()
        #点击确定
        # chrome.find_element_by_xpath('(//div[@class="el-dialog__body"]/div[2]/span/button[1]/span)[5]').click()
        sleep(2)
def create_salesorder(type=1):
    import time
    pro_path = get_pro_path()
    start = time.clock()
    print('订单开始时间', start)
    # caps = DesiredCapabilities().CHROME
    # caps["pageLoadStrategy"] = "normal"  # complete
    # caps["pageLoadStrategy"] = "eager"  #  interactive
    # caps["pageLoadStrategy"] = "none"
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
# chrome = webdriver.Chrome(desired_capabilities=caps) opt = ChromeOptions() # 创建 Chrome 参数对象 # opt.headless = True # 把 Chrome 设置成无界面模式,windows/Linux 皆可 opt.headless = False # 把 Chrome 设置成无界面模式,windows/Linux 皆可 opt.add_argument('--start-maximized') opt.add_argument('--window-size=1280x1024') # chrome = Chrome(options=opt) # 创建无界面对象 # chrome = WebChrome(chrome_options=opt) # chrome = WebChrome(chrome_options=opt) chrome=webdriver.Chrome(chrome_options=opt) try: chrome.implicitly_wait(20) chrome.get("http://10.17.65.200:8088/portal/") # chrome.get("http://10.17.65.207:8088/uat/r/w") sleep(2) chrome.implicitly_wait(30) # chrome.maximize_window() chrome.find_element_by_id('input1').clear() chrome.find_element_by_id('input1').send_keys('admin') chrome.find_element_by_id('input2').clear() chrome.find_element_by_id('input2').send_keys('Gyxc1234') chrome.find_element_by_id('input2').send_keys(Keys.ENTER) while True: try: if(chrome.find_element_by_xpath('//span[text()="退出"]').is_displayed()==True): break except: continue #切换所属公司 chrome.find_element_by_class_name('changeCom').click() sleep(1) chrome.find_element_by_xpath('//span[text()="国药集团北京医疗器械有限公司"]/following-sibling::button').click() sleep(1) chrome.find_element_by_xpath('// button[text() = "确定"]').click() sleep(1) # chrome.find_element_by_xpath('//div[text()="销售管理"]').click() # actions = ActionChains(chrome) # actions.move_to_element(chrome.find_element_by_xpath('//div[text()="销售业务"]')).perform() # chrome.find_element_by_xpath('//span[text()="销售订单"]').click() order_link = chrome.find_element_by_xpath('//span[text()="销售订单"]') chrome.execute_script("arguments[0].click();", order_link) chrome.switch_to.frame(chrome.find_element_by_xpath('(//iframe[@class="metro-main-frame"])[2]')) sleep(4) chrome.find_element_by_xpath('//span[text()="新建"]').click() sleep(4) chrome.switch_to.frame(chrome.find_element_by_xpath('//iframe[contains(@name,"awsui-dialog-iframe")]')) #获取订单号 orderno=chrome.find_element_by_xpath('//div[text() = "销售订单号 "]/following-sibling::div/span').text print(orderno) # chrome.switch_to.default_content() sleep(4) # while True: # try: # if chrome.find_element_by_xpath('//div[text()="订单公司名称 "]').is_displayed(): # print(chrome.find_element_by_xpath('//div[text()="订单公司名称 "]').text) # break # except: # continue print(chrome.find_element_by_xpath('//div[text()="订单公司名称 "]').text) sleep(2) # chrome.find_element_by_xpath( # '//div[text()="订单公司名称 "]/following-sibling::div/div/div/div/div/div/div/div/span/span/i').click() # chrome.find_element_by_xpath('//input[@placeholder="模糊检索:公司名称,公司编码"]').send_keys('国药集团北京') # chrome.find_element_by_xpath('//input[@placeholder="模糊检索:公司名称,公司编码"]').send_keys(Keys.ENTER) # chrome.find_element_by_xpath('(//span[@class="el-radio__inner"])[1]').click()