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
de31e028
Commit
de31e028
authored
Oct 26, 2023
by
章 登恒
Browse files
commit
parent
b456f8a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
testcase/test_scene1/scene1_mainflow.py
View file @
de31e028
...
@@ -74,7 +74,7 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -74,7 +74,7 @@ class PurchaseOrder():#普通采购单界面操作
# 获取订单号
# 获取订单号
global
orderno1
global
orderno1
orderno1
=
chrome
.
find_element_by_xpath
(
'//div[text() = "订单号 "]/following-sibling::div/span'
).
text
orderno1
=
chrome
.
find_element_by_xpath
(
'//div[text() = "订单号 "]/following-sibling::div/span'
).
text
print
(
'普通采购单号为'
,
orderno1
)
print
(
'普通采购单号为
:
'
,
orderno1
)
#填写仓库信息
#填写仓库信息
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
(
'//div[text()="仓库名称 "]/following-sibling::div/div/div/div/div/div/div/div/span/span/i'
).
click
()
...
@@ -146,6 +146,7 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -146,6 +146,7 @@ class PurchaseOrder():#普通采购单界面操作
#填写数量价格
#填写数量价格
for
i
in
range
(
1
):
for
i
in
range
(
1
):
wait
.
until
(
ec
.
visibility_of_element_located
((
By
.
XPATH
,
'(//td[@colid="col_164" and @f="F_QUANTITY_ORD" and @i=%s])'
%
i
)))
element
=
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_164" and @f="F_QUANTITY_ORD" and @i=%s])'
%
i
)
element
=
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_164" and @f="F_QUANTITY_ORD" and @i=%s])'
%
i
)
chrome
.
execute_script
(
"arguments[0].click();"
,
element
)
chrome
.
execute_script
(
"arguments[0].click();"
,
element
)
sleep
(
0.5
)
sleep
(
0.5
)
...
@@ -170,24 +171,23 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -170,24 +171,23 @@ class PurchaseOrder():#普通采购单界面操作
sleep
(
1
)
sleep
(
1
)
locator
=
(
By
.
CLASS_NAME
,
f
'
{
el1
}
'
)
locator
=
(
By
.
CLASS_NAME
,
f
'
{
el1
}
'
)
wait
.
until_not
(
ec
.
presence_of_element_located
(
locator
))
wait
.
until_not
(
ec
.
presence_of_element_located
(
locator
))
print
(
'订单保存成功'
)
else
:
else
:
chrome
.
find_element_by_xpath
(
'//span[text()="提交"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="提交"]'
).
click
()
sleep
(
1
)
sleep
(
1
)
locator
=
(
By
.
XPATH
,
f
'
{
el2
}
'
)
locator
=
(
By
.
XPATH
,
f
'
{
el2
}
'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
print
(
'订单提交成功'
)
self
.
closetab
()
self
.
closetab
()
def
query_click
(
self
,
menu_name
,
orderno
,
el
):
#查询出订单并点击
def
query_click
(
self
,
menu_name
,
orderno
,
el
,
qrcond
=
'订单号'
):
#查询出订单并点击
order_link
=
chrome
.
find_element_by_xpath
(
'//span[text()="%s"]'
%
menu_name
)
order_link
=
chrome
.
find_element_by_xpath
(
'//span[text()="%s"]'
%
menu_name
)
chrome
.
execute_script
(
"arguments[0].click();"
,
order_link
)
chrome
.
execute_script
(
"arguments[0].click();"
,
order_link
)
sleep
(
3
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'(//iframe[@class="metro-main-frame"])[2]'
))
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'(//iframe[@class="metro-main-frame"])[2]'
))
sleep
(
2
)
sleep
(
1
)
# 输入采购单号并查询
# 输入采购单号并查询
chrome
.
find_element_by_xpath
(
'//label[text()="
订单号
"]/parent::div/div/div/div/input'
).
send_keys
(
orderno
)
chrome
.
find_element_by_xpath
(
'//label[text()="
%s
"]/parent::div/div/div/div/input'
%
qrcond
).
send_keys
(
orderno
)
sleep
(
1
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'//label[text()="
订单号
"]/parent::div/div/div/div/input'
).
send_keys
(
Keys
.
ENTER
)
chrome
.
find_element_by_xpath
(
'//label[text()="
%s
"]/parent::div/div/div/div/input'
%
qrcond
).
send_keys
(
Keys
.
ENTER
)
sleep
(
3
)
sleep
(
3
)
# locator = (By.CLASS_NAME, 'el-loading-spinner')
# locator = (By.CLASS_NAME, 'el-loading-spinner')
# wait.until_not(ec.presence_of_element_located(locator))
# wait.until_not(ec.presence_of_element_located(locator))
...
@@ -224,7 +224,7 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -224,7 +224,7 @@ class PurchaseOrder():#普通采购单界面操作
locator
=
(
By
.
XPATH
,
'//span[text()="退出"]'
)
locator
=
(
By
.
XPATH
,
'//span[text()="退出"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
def
button_click2
(
self
,
type
):
#审批/驳回订单:type=1为审批/其余为驳回订单
def
button_click2
(
self
,
type
,
msg
=
'办理成功'
):
#审批/驳回订单:type=1为审批/其余为驳回订单
if
type
==
1
:
if
type
==
1
:
chrome
.
find_element_by_xpath
(
'//span[text()="审核通过"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="审核通过"]'
).
click
()
locator
=
(
By
.
XPATH
,
'//textarea[@placeholder="意见留言"]'
)
locator
=
(
By
.
XPATH
,
'//textarea[@placeholder="意见留言"]'
)
...
@@ -233,7 +233,7 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -233,7 +233,7 @@ class PurchaseOrder():#普通采购单界面操作
chrome
.
find_element_by_xpath
(
'//textarea[@placeholder="意见留言"]'
).
send_keys
(
'审核通过'
)
chrome
.
find_element_by_xpath
(
'//textarea[@placeholder="意见留言"]'
).
send_keys
(
'审核通过'
)
sleep
(
0.5
)
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//span[text()="发送"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="发送"]'
).
click
()
locator
=
(
By
.
XPATH
,
'//p[text()="
办理成功"]'
)
locator
=
(
By
.
XPATH
,
'//p[text()="
%s"]'
%
msg
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
print
(
'订单审核成功'
)
print
(
'订单审核成功'
)
else
:
else
:
...
@@ -287,10 +287,11 @@ class Instore(PurchaseOrder):
...
@@ -287,10 +287,11 @@ class Instore(PurchaseOrder):
PurchaseOrder
.
query_click
(
self
,
'仓库验收'
,
orderno
,
'vxe-body--column col_19 col--left col--ellipsis dw-click-cell'
)
PurchaseOrder
.
query_click
(
self
,
'仓库验收'
,
orderno
,
'vxe-body--column col_19 col--left col--ellipsis dw-click-cell'
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
sleep
(
0.5
)
wait
.
until
(
ec
.
presence
_of_element_located
((
By
.
XPATH
,
'//span[text()="提交"]'
)))
wait
.
until
(
ec
.
visibility
_of_element_located
((
By
.
XPATH
,
'//span[text()="提交"]'
)))
sleep
(
0.5
)
sleep
(
0.5
)
chrome
.
execute_script
(
chrome
.
execute_script
(
"document.getElementsByClassName('vxe-table--footer-wrapper body--wrapper')[0].scrollLeft = 2000"
)
"document.getElementsByClassName('vxe-table--footer-wrapper body--wrapper')[0].scrollLeft = 2000"
)
sleep
(
1
)
# chrome.execute_script(
# chrome.execute_script(
# "document.getElementsByClassName('vxe-table--body-wrapper body--wrapper')[0].scrollTop = %s*30;" % i)
# "document.getElementsByClassName('vxe-table--body-wrapper body--wrapper')[0].scrollTop = %s*30;" % i)
for
i
in
range
(
1
):
for
i
in
range
(
1
):
...
@@ -357,14 +358,131 @@ class Instore(PurchaseOrder):
...
@@ -357,14 +358,131 @@ class Instore(PurchaseOrder):
PurchaseOrder
.
button_click1
(
self
,
type
,
el2
=
'//p[text()="流程结束"]'
)
PurchaseOrder
.
button_click1
(
self
,
type
,
el2
=
'//p[text()="流程结束"]'
)
print
(
'仓库上架成功'
)
print
(
'仓库上架成功'
)
class
PurchaseReject
(
PurchaseOrder
):
def
relate_order
(
self
,
orderno
,
type
=
2
):
#打开采退单
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
(
3
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
# 输入采购单号并查询
chrome
.
find_element_by_xpath
(
'//label[text()="原始订单号"]/parent::div/div/div/div/input'
).
send_keys
(
orderno
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'//label[text()="原始订单号"]/parent::div/div/div/div/input'
).
send_keys
(
Keys
.
ENTER
)
sleep
(
5
)
#选中订单点击采退
chrome
.
find_element_by_xpath
(
'//th[@class="vxe-header--column col_18 col--center col--checkbox col--ellipsis"]/div/span/span'
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//span[text()="采退"]'
).
click
()
sleep
(
0.5
)
# chrome.find_element_by_class_name("el-button el-button--primary el-button--mini").click()
chrome
.
find_element_by_xpath
(
'//button[@class="el-button el-button--primary el-button--mini"]'
).
click
()
sleep
(
3
)
#获取采退单号
# wait.until(ec.presence_of_element_located((By.XPATH, '//span[text()="提交"]')))
# locator = (By.XPATH,'//iframe[contains(@name,"awsui-dialog-iframe")]')
# wait.until(ec.frame_to_be_available_and_switch_to_it(locator))
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
wait
.
until
(
ec
.
visibility_of_element_located
((
By
.
XPATH
,
'//span[text()="提交"]'
)))
global
orderno2
orderno2
=
chrome
.
find_element_by_xpath
(
'//div[text() = "订单号 "]/following-sibling::div/span'
).
text
#选择退货原因
chrome
.
find_element_by_xpath
(
'//div[text()="其他信息"]'
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//label[text() = "退货原因 "]/following-sibling::div//input'
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//li[text()="质量召回"]'
).
click
()
sleep
(
1
)
#保存/提交订单
PurchaseOrder
.
button_click1
(
self
,
type
=
type
)
print
(
"关联原单创建采退单成功,采退单号为:"
,
orderno2
)
def
return_rejpchno
(
self
):
return
orderno2
def
commit_order
(
self
,
orderno
,
type
=
2
):
#保存/提交订单:type=1为保存,否则为提交
#查询出订单并点击
PurchaseOrder
.
query_click
(
self
,
'采购退货单'
,
orderno
,
'vxe-body--column col_19 col--last col--ellipsis dw-click-cell'
,
qrcond
=
'采退单号'
)
#切框架
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
locator
=
(
By
.
XPATH
,
'//span[text()="提交"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
sleep
(
2
)
# 保存/提交订单
PurchaseOrder
.
button_click1
(
self
,
type
)
def
approve_order
(
self
,
orderno
,
type
=
1
):
#审核/驳回订单:type=1为审核通过,否则为审核驳回
PurchaseOrder
.
query_click
(
self
,
'采购退货单'
,
orderno
,
'vxe-body--column col_19 col--last col--ellipsis dw-click-cell'
,
qrcond
=
'采退单号'
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
locator
=
(
By
.
XPATH
,
'//span[text()="审核通过"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
sleep
(
2
)
PurchaseOrder
.
button_click2
(
self
,
type
,
msg
=
'发送成功'
)
class
Outstore
(
PurchaseOrder
):
def
deliver_goods
(
self
,
orderno
):
PurchaseOrder
.
query_click
(
self
,
'仓库发货'
,
orderno
,
'vxe-body--column col_19 col--last col--ellipsis dw-click-cell'
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
wait
.
until
(
ec
.
visibility_of_element_located
((
By
.
XPATH
,
'//span[text()="确认发货"]'
)))
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//span[text()="确认发货"]'
).
click
()
wait
.
until
(
ec
.
visibility_of_element_located
((
By
.
XPATH
,
'//span[text()="确定"]'
)))
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//span[text()="确定"]'
).
click
()
wait
.
until
(
ec
.
visibility_of_element_located
((
By
.
XPATH
,
'//span[text()="确认发货"]'
)))
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//span[text()="确认发货"]'
).
click
()
sleep
(
0.5
)
wait
.
until
(
ec
.
presence_of_element_located
((
By
.
XPATH
,
'//p[text()="办理成功"]'
)))
PurchaseOrder
.
closetab
(
self
)
print
(
'仓库发货成功'
)
def
picking_goods
(
self
,
orderno
,
type
=
2
):
PurchaseOrder
.
query_click
(
self
,
'仓库拣货'
,
orderno
,
'vxe-body--column col_19 col--left col--ellipsis dw-click-cell'
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
PurchaseOrder
.
button_click1
(
self
,
type
)
print
(
'仓库拣货成功'
)
def
outbound_review
(
self
,
orderno
,
type
=
2
):
PurchaseOrder
.
query_click
(
self
,
'出库复核'
,
orderno
,
'vxe-body--column col_19 col--left col--ellipsis dw-click-cell'
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
for
i
in
range
(
1
):
wait
.
until
(
ec
.
visibility_of_element_located
((
By
.
XPATH
,
'(//td[@colid="col_117" and @f="F_RECHECK_NUM" and @i=%s])'
%
i
)))
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_117" and @f="F_RECHECK_NUM" and @i=%s])'
%
i
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_class_name
(
'awsui-input-number-right'
).
send_keys
(
'1'
)
sleep
(
1
)
PurchaseOrder
.
button_click1
(
self
,
type
,
el2
=
'//p[text()="流程结束"]'
)
print
(
'出库复核成功'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
step1
=
LoginSys
()
step1
=
LoginSys
()
step2
=
PurchaseOrder
()
step2
=
PurchaseOrder
()
step3
=
Instore
()
step3
=
Instore
()
step4
=
PurchaseReject
()
step5
=
Outstore
()
step1
.
loginsys
(
SIT_URL
,
usr2
,
pwd2
)
#登录系统
step1
.
loginsys
(
SIT_URL
,
usr2
,
pwd2
)
#登录系统
step2
.
data_add
()
#填写表单数据
step2
.
data_add
()
#填写表单数据
step2
.
button_click1
()
#1为保存,否则为提交
step2
.
button_click1
()
#1为保存,否则为提交
# step2.commitorder(1)#1为保存,否则为提交
# step2.commit
_
order(1)#
提交采购单:
1为保存,否则为提交
step2
.
switch_loggin
(
usr1
,
pwd1
)
#切换登录
step2
.
switch_loggin
(
usr1
,
pwd1
)
#切换登录
step2
.
approve_order
()
#1为审核通过,否则为审核驳回
step2
.
approve_order
()
#1为审核通过,否则为审核驳回
purchord
=
step2
.
return_pchno
()
#获取采购订单号
purchord
=
step2
.
return_pchno
()
#获取采购订单号
...
@@ -374,3 +492,15 @@ if __name__ == '__main__':
...
@@ -374,3 +492,15 @@ if __name__ == '__main__':
step3
.
goods_check
(
purchord
)
#仓库验收:1为保存,否则为提交
step3
.
goods_check
(
purchord
)
#仓库验收:1为保存,否则为提交
step3
.
switch_loggin
(
usr4
,
pwd4
)
step3
.
switch_loggin
(
usr4
,
pwd4
)
step3
.
goods_grounding
(
purchord
)
#仓库上架:1为保存,否则为提交
step3
.
goods_grounding
(
purchord
)
#仓库上架:1为保存,否则为提交
step4
.
switch_loggin
(
usr2
,
pwd2
)
step4
.
relate_order
(
purchord
)
#创建采退单1为保存,否则为提交
rejpurchord
=
step4
.
return_rejpchno
()
# step4.commit_order(rejpurchord)#提交采退单:1为保存,否则为提交
step4
.
switch_loggin
(
usr1
,
pwd1
)
step4
.
approve_order
(
rejpurchord
)
step4
.
switch_loggin
(
usr4
,
pwd4
)
step5
.
deliver_goods
(
rejpurchord
)
step5
.
picking_goods
(
rejpurchord
)
step5
.
switch_loggin
(
usr5
,
pwd5
)
step5
.
outbound_review
(
rejpurchord
)
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