An error occurred while loading the file. Please try again.
An error occurred while loading the file. Please try again.
An error occurred while loading the file. Please try again.
-
章 登恒 authoreddf99124c
import datetime
import logging
import threading
import time
import traceback
import os
import sys
cur_path = os.path.abspath(os.path.dirname(__file__))# 获取当前文件的目录
proj_path = cur_path[:cur_path.find('testcase')]# 获取根目录
sys.path.append(proj_path)
# from airtest.core.api import *
# from selenium.webdriver import DesiredCapabilities
# from airtest_selenium.proxy import *
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import Chrome, ChromeOptions
from airtest.core.api import *
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.wait import WebDriverWait
from public.mail1 import send_email1
from public.tools import *
opt = ChromeOptions() # 创建 Chrome 参数对象
# opt.headless = False # 把 Chrome 设置成无界面模式,windows/Linux 皆可
opt.add_argument('--headless')# 把 Chrome 设置成无界面模式
opt.add_argument('--start-maximized')
opt.add_argument('--window-size=1280x1024')
chrome = webdriver.Chrome(options=opt)
# chrome =webdriver.Chrome()
# chrome.maximize_window()
wait = WebDriverWait(chrome,20,poll_frequency=0.2)
SIT_URL = 'http://scdev.cmic.com.cn:8088/beta/'#SIT环境地址
#通行证
usr1,pwd1 = 'bj_01','Gyxc1234'
usr2,pwd2 = 'bj_02','Gyxc1234'
usr3,pwd3 = 'bj_03','Gyxc1234'
usr4,pwd4 = 'bj_04','Gyxc1234'
usr5,pwd5 = 'bj_05','Gyxc1234'
warehousename = '北京强生非WMS仓'#仓库名称
contractnumber = 41007#合同号
salesman = '杨春刚'#业务员名称
productcode = 10156326#商品编码
productdate = '2023-10-01'#生产日期
expirdate = '2026-09-30'#失效日期
errmsg = '流程一:采购_采退流程异常,请检查!'#流程异常提示信息
class LoginSys():###登录
def loginsys(self,url,usr,pwd):
chrome.get(url)
sleep(2)
chrome.find_element_by_id('input1').clear()
chrome.find_element_by_id('input1').send_keys(usr)
chrome.find_element_by_id('input2').clear()
chrome.find_element_by_id('input2').send_keys(pwd)
chrome.find_element_by_id('input2').send_keys(Keys.ENTER)
locator = (By.XPATH, '//span[text()="退出"]')
wait.until(ec.presence_of_element_located(locator))
# while True:
# try:
# if(chrome.find_element_by_xpath('//span[text()="退出"]').is_displayed()==True):
# break
# except:
# continue
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
class PurchaseOrder():###普通采购单界面操作
def data_add_purchase(self):#填写表单数据
chrome.implicitly_wait(10)
###打开普通采购单###
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(2)
#点击新建按钮
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")]'))
sleep(2)
###获取订单号###
global orderno1
orderno1 = chrome.find_element_by_xpath('//div[text() = "订单号 "]/following-sibling::div/span').text
print('普通采购单号为:',orderno1)
###填写仓库信息###
#点击仓库名称,输入仓库名并查询出结果
chrome.find_element_by_xpath('//div[text()="仓库名称 "]/following-sibling::div/div/div/div/div/div/div/div/span/span/i').click()
sleep(1)
chrome.find_element_by_xpath('//input[@placeholder="模糊检索:仓库名称,仓库编码"]').send_keys(warehousename)
chrome.find_element_by_xpath('//input[@placeholder="模糊检索:仓库名称,仓库编码"]').send_keys(Keys.ENTER)
sleep(1)
#勾选查询出的仓库并点击确定按钮
btn_div= chrome.find_element_by_xpath('//span/input[@type="radio" and @value="022bc5d182335c5146b3817a500c2cbc7"]')
chrome.execute_script("arguments[0].click();", btn_div)
sleep(1)
chrome.find_element_by_xpath('(//button[@class="el-button el-button--primary el-button--default"])[2]').click()
sleep(1)
###填写合同信息###
#切到合同信息页
chrome.find_element_by_xpath('//div[text()="合同信息"]').click()
sleep(1)
#点击采购合同/协议号并输入信息,查询出结果
chrome.find_element_by_xpath(
'//div[text()="采购合同/协议号 "]/following-sibling::div/div/div/div/div/div/div/div/span/span/i').click()
sleep(1)
chrome.find_element_by_xpath(
'//input[@placeholder="模糊检索:合同协议号,合同号,项目编码,项目名称,业态编码,对方编码,产品线编码"]').send_keys(
contractnumber)
sleep(1)
chrome.find_element_by_xpath(
'//input[@placeholder="模糊检索:合同协议号,合同号,项目编码,项目名称,业态编码,对方编码,产品线编码"]').send_keys(
Keys.ENTER)
sleep(1)
# chrome.find_element_by_xpath(
# '//div[@class="multiple-header string_col" and text()="38443"]/ancestor-or-self::td/preceding-sibling::td/div/label/span/span').click()
#勾选查询出的合同号并点击确定按钮
btn_div= chrome.find_element_by_xpath('//span/input[@type="radio" and @value="03992a2172b8f7327a077e60ac1da11b8"]')
chrome.execute_script("arguments[0].click();", btn_div)
sleep(1)
chrome.find_element_by_xpath('(//button[@class="el-button el-button--primary el-button--default"])[2]').click()
sleep(1)
#点击业务员名称并输入查询条件,查询出结果
chrome.find_element_by_xpath(
'//div[text()="业务员名称 "]/following-sibling::div/div/div/div/div/div/div/div/span/span/i').click()
sleep(1)
chrome.find_element_by_xpath('//input[@placeholder="模糊检索:业务员编码,业务员名称,部门编码,部门名称"]').send_keys(salesman)
sleep(1)
chrome.find_element_by_xpath('//input[@placeholder="模糊检索:业务员编码,业务员名称,部门编码,部门名称"]').send_keys(Keys.ENTER)
sleep(1)
#勾选查询出的业务员并点击确定按钮
btn_div= chrome.find_element_by_xpath('//span/input[@type="radio" and @value="06c32a810e3dabf2a50d1ab040c7951c8"]')
chrome.execute_script("arguments[0].click();", btn_div)