Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
test
autotest-airtest-web-sc
Commits
3e85d52d
Commit
3e85d52d
authored
Oct 30, 2023
by
章 登恒
Browse files
commit
parent
d086f26a
Changes
3
Hide whitespace changes
Inline
Side-by-side
testcase/test_scene1/scene1_mainflow.py
View file @
3e85d52d
...
...
@@ -180,6 +180,7 @@ class PurchaseOrder():###普通采购单界面操作
sleep
(
1
)
def
button_click1
(
self
,
type
=
2
,
el1
=
'el-loading-spinner'
,
el2
=
'//p[text()="办理成功"]'
):
#保存/提交订单:type=1为保存,否则为提交
wait
.
until
(
ec
.
visibility_of_element_located
((
By
.
XPATH
,
'//span[text()="保存"]'
)))
if
type
==
1
:
#保存
#点击保存按钮
chrome
.
find_element_by_xpath
(
'//span[text()="保存"]'
).
click
()
...
...
@@ -187,13 +188,22 @@ class PurchaseOrder():###普通采购单界面操作
#元素el1不可见时认为保存成功
locator
=
(
By
.
CLASS_NAME
,
f
'
{
el1
}
'
)
wait
.
until_not
(
ec
.
presence_of_element_located
(
locator
))
el
se
:
#提交
el
if
type
==
2
:
#提交(提交后界面无弹框)
#点击提交按钮
chrome
.
find_element_by_xpath
(
'//span[text()="提交"]'
).
click
()
sleep
(
1
)
#元素el2出现时认为提交成功
locator
=
(
By
.
XPATH
,
f
'
{
el2
}
'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
elif
type
==
3
:
#提交(提交后界面还有弹框)
#点击保存按钮
chrome
.
find_element_by_xpath
(
'//span[text()="提交"]'
).
click
()
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'//span[text()="确定"][1]'
).
click
()
#元素el2出现时认为提交成功
locator
=
(
By
.
CLASS_NAME
,
f
'
{
el2
}
'
)
wait
.
until_not
(
ec
.
presence_of_element_located
(
locator
))
self
.
closetab
()
def
query_click
(
self
,
menu_name
,
orderno
,
el
,
qrcond
=
'订单号'
):
#查询出订单并点击
...
...
@@ -544,7 +554,7 @@ if __name__ == '__main__':
step2
.
approve_order
()
#1为审核通过,否则为审核驳回
purchord
=
step2
.
return_pchno
()
#获取采购订单号
step3
.
switch_loggin
(
usr4
,
pwd4
)
step3
.
take_over_goods
(
purchord
)
#1为收货单据撤回,2为提交,其余为保存
step3
.
take_over_goods
(
purchord
)
#
仓库收货:
1为收货单据撤回,2为提交,其余为保存
step3
.
switch_loggin
(
usr5
,
pwd5
)
step3
.
goods_check
(
purchord
)
#仓库验收:1为保存,否则为提交
step3
.
switch_loggin
(
usr4
,
pwd4
)
...
...
testcase/test_scene1/scene3_mainflow.py
View file @
3e85d52d
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.by
import
By
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
selenium.webdriver.support
import
expected_conditions
as
ec
from
selenium.webdriver.support.wait
import
WebDriverWait
from
testcase.test_scene1.scene1_mainflow
import
*
from
selenium.webdriver.common.action_chains
import
ActionChains
from
public.mail1
import
send_email1
from
public.tools
import
*
SIT_URL
=
'http://scdev.cmic.com.cn:8088/beta/'
#SIT环境地址
#通行证
usr1
,
pwd1
=
'bj_01'
,
'Gyxc1234'
...
...
@@ -27,11 +9,11 @@ usr2,pwd2 = 'bj_02','Gyxc1234'
usr3
,
pwd3
=
'bj_03'
,
'Gyxc1234'
usr4
,
pwd4
=
'bj_04'
,
'Gyxc1234'
usr5
,
pwd5
=
'bj_05'
,
'Gyxc1234'
warehousename
=
'103
305
'
#仓库名称
warehousename
=
'103
999
'
#仓库名称
purcontractnumber
=
41007
#采购合同号
salcontractnumber
=
1222720
#销售合同号
salcontractnumber
=
'YLTEST88'
#销售合同号
salesman
=
'杨春刚'
#业务员名称
salcust
=
1000486
salcust
=
1000486
#销售客户名称
productcode
=
10156326
#商品编码
productdate
=
'2023-10-01'
#生产日期
expirdate
=
'2026-09-30'
#失效日期
...
...
@@ -66,7 +48,7 @@ class QuickPurchase():#快速采购单界面操作
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="0
93e125f132ba7792b1d6752aa9bc9cf1
"]'
)
btn_div
=
chrome
.
find_element_by_xpath
(
'//span/input[@type="radio" and @value="0
0c286e0a9e96a7ba5ed168b3103a719a
"]'
)
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
()
...
...
@@ -126,7 +108,7 @@ class QuickPurchase():#快速采购单界面操作
# '//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="0
9121f3b324320394
a0837
52e0a5f392
c"]'
)
'//span/input[@type="radio" and @value="0
b1ab563e8d07fdfe3
a08
7
37
ef3b9863
c"]'
)
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
()
...
...
@@ -220,7 +202,7 @@ class SalesOrder():
salesorder
=
chrome
.
find_element_by_xpath
(
'//td[@class="vxe-body--column col_104 col--ellipsis dw-click-cell"]/div/div'
).
text
print
(
'生成的销售订单号为:'
,
salesorder
)
status
=
chrome
.
find_element_by_xpath
(
'//td[@class="vxe-body--column col_107 col--ellipsis"]/div/div'
).
text
assert
status
==
'待
出库
'
,
f
'销售订单推送WMS失败,当前状态为:"
{
status
}
",正确状态为"待
出库
"!'
assert
status
==
'待
发货
'
,
f
'销售订单推送WMS失败,当前状态为:"
{
status
}
",正确状态为"待
发货
"!'
print
(
'销售订单推送WMS成功'
)
...
...
testcase/test_scene1/scene4_mainflow.py
0 → 100644
View file @
3e85d52d
from
testcase.test_scene1.scene1_mainflow
import
*
from
key_word.key_cncap
import
WebKeys
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'
outwarehouse
=
'103356'
#调拨出库仓
inwarehouse
=
'103396'
#调拨入库仓
salesman
=
'杨春刚'
#业务员名称
productcode
=
10005528
#商品编码
STASHIP_TEMP
=
24
#启运温度
ARRIVAL_TEMP
=
24
#到货温度
STASHIP_DATE
=
'2023-10-01'
#启运日期
STASHIP_TIME
=
'00:00:00'
#启运时间
ARRIVAL_TIME
=
'00:00:00'
#启运时间
TRANS_MACHINE
=
'冷冻车'
#运输工具
errmsg
=
'流程四:调拨出库-入库-红冲流程异常,请检查!'
#流程异常提示信息
class
TransferOut
():
def
data_add_allocate
(
self
):
###打开普调拨出库单###
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
(
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="053bd01a610bae0ff25d8a6dca563b2fa"]'
)
chrome
.
execute_script
(
"arguments[0].click();"
,
btn_div
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'(//span[@class="ensureBtn"]/button[1])'
).
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="模糊检索:调拨出库仓库编码,调拨出库仓库名称,是否WMS仓"]'
).
send_keys
(
outwarehouse
)
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:调拨出库仓库编码,调拨出库仓库名称,是否WMS仓"]'
).
send_keys
(
Keys
.
ENTER
)
sleep
(
1
)
#勾选查询出的仓库并点击确定按钮
btn_div
=
chrome
.
find_element_by_xpath
(
'//span/input[@type="radio" and @value="0bc65b238650bc6abf44397198474a21d"]'
)
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="模糊检索:调拨入库仓库编码,调拨入库仓库名称,是否WMS"]'
).
send_keys
(
inwarehouse
)
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:调拨入库仓库编码,调拨入库仓库名称,是否WMS"]'
).
send_keys
(
Keys
.
ENTER
)
sleep
(
1
)
#勾选查询出的仓库并点击确定按钮
btn_div
=
chrome
.
find_element_by_xpath
(
'//span/input[@type="radio" and @value="026f9c1311022a92efbee8ec9597317f3"]'
)
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
(
'//span[text()="添加商品"]'
).
click
()
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:商品编码,商品全称,规格型号,主计量单位,采购计量单位,厂家物料编码,存储条件,存储条件说明,生产企业编码,行类型,件包数,产品备注,产品描述,商品性质,是否免备案"]'
).
send_keys
(
productcode
)
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:商品编码,商品全称,规格型号,主计量单位,采购计量单位,厂家物料编码,存储条件,存储条件说明,生产企业编码,行类型,件包数,产品备注,产品描述,商品性质,是否免备案"]'
).
send_keys
(
Keys
.
ENTER
)
sleep
(
2
)
# 勾选查询出的商品并点击确定按钮
chrome
.
find_element_by_xpath
(
'//th[@class="el-table_15_column_135 multiple-column el-table-column--selection is-leaf headerCellClassName el-table__cell"]/div/label/span/span'
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'(//div[@class="el-dialog__body"]/div[2]/span/button[1]/span)[4]'
).
click
()
sleep
(
3
)
###填写数量价格###
for
i
in
range
(
1
):
wait
.
until
(
ec
.
visibility_of_element_located
(
(
By
.
XPATH
,
'(//td[@colid="col_108" and @f="F_QUANTITY_ORD" and @i=%s])'
%
i
)))
# 定位数量框并输入数量
element
=
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_108" and @f="F_QUANTITY_ORD" and @i=%s])'
%
i
)
chrome
.
execute_script
(
"arguments[0].click();"
,
element
)
sleep
(
0.5
)
chrome
.
find_element_by_class_name
(
'awsui-input-number-right'
).
send_keys
(
'1'
)
sleep
(
1
)
# 点击其它地方让数量框失焦,让数量真正填入数量框(平台设计如此,不用纠结为啥要此步)
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_110" and @f="F_PURUNIT_CODE" and @i=%s])'
%
i
).
click
()
sleep
(
1
)
def
return_allono
(
self
):
# 返回采购单号
return
orderno1
class
TransferIn
():
def
transfer_in
(
self
,
orderno
):
# 打开菜单
order_link
=
chrome
.
find_element_by_xpath
(
'//span[text()="调拨入库单"]'
)
chrome
.
execute_script
(
"arguments[0].click();"
,
order_link
)
sleep
(
5
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'(//iframe[@class="metro-main-frame"])[2]'
))
sleep
(
1
)
# 切换到已办页面
chrome
.
find_element_by_xpath
(
'//li[text()="已办"]'
).
click
()
sleep
(
0.5
)
wait
.
until_not
(
ec
.
presence_of_element_located
((
By
.
CLASS_NAME
,
'el-loading-mask'
)))
# 输入orderno并查询出订单
chrome
.
find_element_by_xpath
(
'//label[text()="调拨出库单号"]/parent::div/div/div/div/input'
).
send_keys
(
orderno
)
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//label[text()="调拨出库单号"]/parent::div/div/div/div/input'
).
send_keys
(
Keys
.
ENTER
)
wait
.
until
(
ec
.
presence_of_element_located
((
By
.
XPATH
,
'//div[text()="%s"]'
%
orderno
)))
sleep
(
0.5
)
#获取调拨入库单
global
orderno2
orderno2
=
chrome
.
find_element_by_xpath
(
'//td[@class="vxe-body--column col_68 col--ellipsis dw-click-cell"]/div/div'
).
text
print
(
'调拨入库单号为:'
,
orderno2
)
status
=
chrome
.
find_element_by_xpath
(
'//td[@class="vxe-body--column col_74 col--ellipsis"]/div/div'
).
text
assert
status
==
'待收货'
,
f
'调拨入库单状态不正确,当前状态为:"
{
status
}
",正确状态为"待收货"!'
print
(
'调拨入库单自动审核成功,状态为:待收货!'
)
def
return_traninord
(
self
):
return
orderno2
class
Instore1
(
Instore
):
def
goods_check
(
self
,
orderno
,
type
=
2
):
# 仓库验收
# 调用query_click进入表单视图
PurchaseOrder
.
query_click
(
self
,
'仓库验收'
,
orderno
,
'vxe-body--column col_19 col--left col--ellipsis dw-click-cell'
)
wait
.
until
(
ec
.
visibility_of_element_located
((
By
.
XPATH
,
'//span[text()="提交"]'
)))
sleep
(
1.5
)
# 浏览器页面右滑
chrome
.
execute_script
(
"document.getElementsByClassName('vxe-table--body-wrapper body--wrapper')[0].scrollLeft = 5500"
)
sleep
(
1
)
# chrome.execute_script("document.getElementsByClassName('vxe-table--footer-wrapper body--wrapper')[0].scrollLeft = 2000")
# chrome.execute_script("document.getElementsByClassName('vxe-table--body-wrapper body--wrapper')[0].scrollTop = %s*30;" % i)
# 填写商品信息
for
i
in
range
(
1
):
#填写启运温度
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_185" and @f="F_STASHIP_TEMP" and @i=%s])'
%
i
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_class_name
(
'el-input__inner'
).
send_keys
(
STASHIP_TEMP
)
sleep
(
0.5
)
#填写到货温度
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_186" and @f="F_ARRIVAL_TEMP" and @i=%s])'
%
i
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_class_name
(
'el-input__inner'
).
send_keys
(
ARRIVAL_TEMP
)
sleep
(
0.5
)
#填写启运日期
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_187" and @f="F_STASHIP_DATE" and @i=%s])'
%
i
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_class_name
(
'el-input__inner'
).
send_keys
(
STASHIP_DATE
)
sleep
(
0.5
)
#填写启运时间
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_188" and @f="F_STASHIP_TIME" and @i=%s])'
%
i
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_class_name
(
'el-input__inner'
).
send_keys
(
STASHIP_TIME
)
sleep
(
0.5
)
#填写到货时间
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_190" and @f="F_ARRIVAL_TIME" and @i=%s])'
%
i
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_class_name
(
'el-input__inner'
).
send_keys
(
ARRIVAL_TIME
)
sleep
(
0.5
)
#填写运输工具
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_191" and @f="F_TRANS_MACHINE" and @i=%s])'
%
i
).
click
()
sleep
(
0.5
)
# chrome.find_element_by_class_name('el-input__inner').send_keys(TRANS_MACHINE)
chrome
.
find_element_by_xpath
(
'//li[text()="%s"]'
%
TRANS_MACHINE
).
click
()
sleep
(
0.5
)
# 调用button_click1保存/提交订单
PurchaseOrder
.
button_click1
(
self
,
type
)
print
(
'仓库验收成功'
)
if
__name__
==
'__main__'
:
step1
=
LoginSys
()
step2_1
=
TransferOut
()
step2_2
=
PurchaseOrder
()
step3
=
Outstore
()
step4
=
TransferIn
()
step5
=
Instore1
()
step1
.
loginsys
(
SIT_URL
,
usr2
,
pwd2
)
step2_1
.
data_add_allocate
()
#填写主表数据
allono
=
step2_1
.
return_allono
()
step2_2
.
button_click1
()
#提交
step2_2
.
switch_loggin
(
usr1
,
pwd1
)
step2_2
.
query_click
(
'调拨出库单'
,
allono
,
'vxe-body--column col_19 col--left col--ellipsis dw-click-cell'
,
qrcond
=
'调拨出库单号'
)
step2_2
.
button_click2
(
msg1
=
'发送成功'
)
#审核
step3
.
switch_loggin
(
usr4
,
pwd4
)
step3
.
deliver_goods
(
allono
)
# 仓库发货
step3
.
picking_goods
(
allono
)
# 仓库拣货
step3
.
switch_loggin
(
usr5
,
pwd5
)
step3
.
outbound_review
(
allono
,
type
=
3
)
# 出库复核
step3
.
switch_loggin
(
usr1
,
pwd1
)
step4
.
transfer_in
(
allono
)
#检查自动审配订单状态
traninord
=
step4
.
return_traninord
()
#获取调拨入库单号
step5
.
switch_loggin
(
usr4
,
pwd4
)
step5
.
take_over_goods
(
traninord
)
# 仓库收货:1为收货单据撤回,2为提交,其余为保存
step5
.
switch_loggin
(
usr5
,
pwd5
)
step5
.
goods_check
(
traninord
,
type
=
3
)
# 仓库验收:1为保存,否则为提交
step5
.
switch_loggin
(
usr4
,
pwd4
)
step5
.
goods_grounding
(
traninord
)
# 仓库上架:1为保存,否则为提交
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment