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
27ea7d8c
Commit
27ea7d8c
authored
Oct 26, 2023
by
章 登恒
Browse files
commit
parent
3d1fe462
Changes
1
Hide whitespace changes
Inline
Side-by-side
testcase/test_scene1/scene1_mainflow.py
View file @
27ea7d8c
...
@@ -41,7 +41,8 @@ productdate = '2023-10-01'#生产日期
...
@@ -41,7 +41,8 @@ productdate = '2023-10-01'#生产日期
expirdate
=
'2026-09-30'
#失效日期
expirdate
=
'2026-09-30'
#失效日期
errmsg
=
'流程一:采购_采退流程异常,请检查!'
#流程异常提示信息
errmsg
=
'流程一:采购_采退流程异常,请检查!'
#流程异常提示信息
class
LoginSys
():
#登录
class
LoginSys
():
###登录
def
loginsys
(
self
,
url
,
usr
,
pwd
):
def
loginsys
(
self
,
url
,
usr
,
pwd
):
chrome
.
get
(
url
)
chrome
.
get
(
url
)
sleep
(
2
)
sleep
(
2
)
...
@@ -59,38 +60,44 @@ class LoginSys():#登录
...
@@ -59,38 +60,44 @@ class LoginSys():#登录
# except:
# except:
# continue
# continue
class
PurchaseOrder
():
#普通采购单界面操作
class
PurchaseOrder
():
#
##
普通采购单界面操作
def
data_add
(
self
):
#填写表单数据
def
data_add
(
self
):
#填写表单数据
chrome
.
implicitly_wait
(
10
)
chrome
.
implicitly_wait
(
10
)
###打开普通采购单###
order_link
=
chrome
.
find_element_by_xpath
(
'//span[text()="普通采购订单"]'
)
order_link
=
chrome
.
find_element_by_xpath
(
'//span[text()="普通采购订单"]'
)
chrome
.
execute_script
(
"arguments[0].click();"
,
order_link
)
chrome
.
execute_script
(
"arguments[0].click();"
,
order_link
)
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
(
2
)
#点击新建按钮
chrome
.
find_element_by_xpath
(
'//span[text()="新建"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="新建"]'
).
click
()
sleep
(
4
)
sleep
(
4
)
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
(
2
)
sleep
(
2
)
#
获取订单号
#
##
获取订单号
###
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
()
sleep
(
1
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:仓库名称,仓库编码"]'
).
send_keys
(
warehousename
)
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:仓库名称,仓库编码"]'
).
send_keys
(
warehousename
)
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:仓库名称,仓库编码"]'
).
send_keys
(
Keys
.
ENTER
)
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:仓库名称,仓库编码"]'
).
send_keys
(
Keys
.
ENTER
)
sleep
(
1
)
sleep
(
1
)
#勾选查询出的仓库并点击确定按钮
btn_div
=
chrome
.
find_element_by_xpath
(
'//span/input[@type="radio" and @value="022bc5d182335c5146b3817a500c2cbc7"]'
)
btn_div
=
chrome
.
find_element_by_xpath
(
'//span/input[@type="radio" and @value="022bc5d182335c5146b3817a500c2cbc7"]'
)
chrome
.
execute_script
(
"arguments[0].click();"
,
btn_div
)
chrome
.
execute_script
(
"arguments[0].click();"
,
btn_div
)
sleep
(
1
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'(//button[@class="el-button el-button--primary el-button--default"])[2]'
).
click
()
chrome
.
find_element_by_xpath
(
'(//button[@class="el-button el-button--primary el-button--default"])[2]'
).
click
()
sleep
(
1
)
sleep
(
1
)
#填写合同信息
###填写合同信息###
#切到合同信息页
chrome
.
find_element_by_xpath
(
'//div[text()="合同信息"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//div[text()="合同信息"]'
).
click
()
sleep
(
1
)
sleep
(
1
)
#点击采购合同/协议号并输入信息,查询出结果
chrome
.
find_element_by_xpath
(
chrome
.
find_element_by_xpath
(
'//div[text()="采购合同/协议号 "]/following-sibling::div/div/div/div/div/div/div/div/span/span/i'
).
click
()
'//div[text()="采购合同/协议号 "]/following-sibling::div/div/div/div/div/div/div/div/span/span/i'
).
click
()
sleep
(
1
)
sleep
(
1
)
...
@@ -104,13 +111,14 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -104,13 +111,14 @@ class PurchaseOrder():#普通采购单界面操作
sleep
(
1
)
sleep
(
1
)
# chrome.find_element_by_xpath(
# 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()
# '//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"]'
)
btn_div
=
chrome
.
find_element_by_xpath
(
'//span/input[@type="radio" and @value="03992a2172b8f7327a077e60ac1da11b8"]'
)
chrome
.
execute_script
(
"arguments[0].click();"
,
btn_div
)
chrome
.
execute_script
(
"arguments[0].click();"
,
btn_div
)
sleep
(
1
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'(//button[@class="el-button el-button--primary el-button--default"])[2]'
).
click
()
chrome
.
find_element_by_xpath
(
'(//button[@class="el-button el-button--primary el-button--default"])[2]'
).
click
()
sleep
(
1
)
sleep
(
1
)
#业务员名称
#
点击
业务员名称
并输入查询条件,查询出结果
chrome
.
find_element_by_xpath
(
chrome
.
find_element_by_xpath
(
'//div[text()="业务员名称 "]/following-sibling::div/div/div/div/div/div/div/div/span/span/i'
).
click
()
'//div[text()="业务员名称 "]/following-sibling::div/div/div/div/div/div/div/div/span/span/i'
).
click
()
sleep
(
1
)
sleep
(
1
)
...
@@ -118,18 +126,20 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -118,18 +126,20 @@ class PurchaseOrder():#普通采购单界面操作
sleep
(
1
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:业务员编码,业务员名称,部门编码,部门名称"]'
).
send_keys
(
Keys
.
ENTER
)
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:业务员编码,业务员名称,部门编码,部门名称"]'
).
send_keys
(
Keys
.
ENTER
)
sleep
(
1
)
sleep
(
1
)
#勾选查询出的业务员并点击确定按钮
btn_div
=
chrome
.
find_element_by_xpath
(
'//span/input[@type="radio" and @value="06c32a810e3dabf2a50d1ab040c7951c8"]'
)
btn_div
=
chrome
.
find_element_by_xpath
(
'//span/input[@type="radio" and @value="06c32a810e3dabf2a50d1ab040c7951c8"]'
)
chrome
.
execute_script
(
"arguments[0].click();"
,
btn_div
)
chrome
.
execute_script
(
"arguments[0].click();"
,
btn_div
)
sleep
(
1
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'(//span[@class="ensureBtn"]/button[1])[3]'
).
click
()
chrome
.
find_element_by_xpath
(
'(//span[@class="ensureBtn"]/button[1])[3]'
).
click
()
sleep
(
1
)
sleep
(
1
)
#其他信息页签
#
##切换到
其他信息页签
###
chrome
.
find_element_by_xpath
(
'//div[text()="其他信息"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//div[text()="其他信息"]'
).
click
()
sleep
(
1
)
sleep
(
1
)
#
子表信息录入
#
##
子表信息录入
###
chrome
.
find_element_by_xpath
(
'//div[text()="主体信息"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//div[text()="主体信息"]'
).
click
()
sleep
(
1
)
sleep
(
1
)
#点击添加商品并输入商品编码,查询出结果
chrome
.
find_element_by_xpath
(
'//span[text()="添加商品"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="添加商品"]'
).
click
()
sleep
(
1
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
chrome
.
find_element_by_xpath
(
...
@@ -138,20 +148,23 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -138,20 +148,23 @@ class PurchaseOrder():#普通采购单界面操作
chrome
.
find_element_by_xpath
(
chrome
.
find_element_by_xpath
(
'//input[@placeholder="模糊检索:商品编码,商品名称,规格型号,厂家物料编码"]'
).
send_keys
(
Keys
.
ENTER
)
'//input[@placeholder="模糊检索:商品编码,商品名称,规格型号,厂家物料编码"]'
).
send_keys
(
Keys
.
ENTER
)
sleep
(
2
)
sleep
(
2
)
#勾选查询出的商品并点击确定按钮
chrome
.
find_element_by_xpath
(
chrome
.
find_element_by_xpath
(
'//th[@class="el-table_15_column_199 multiple-column el-table-column--selection is-leaf headerCellClassName el-table__cell"]/div/label/span/span'
).
click
()
'//th[@class="el-table_15_column_199 multiple-column el-table-column--selection is-leaf headerCellClassName el-table__cell"]/div/label/span/span'
).
click
()
sleep
(
0.5
)
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'(//div[@class="el-dialog__body"]/div[2]/span/button[1]/span)[4]'
).
click
()
chrome
.
find_element_by_xpath
(
'(//div[@class="el-dialog__body"]/div[2]/span/button[1]/span)[4]'
).
click
()
sleep
(
5
)
sleep
(
5
)
#填写数量价格
##
#填写数量价格
###
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
)))
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
)
chrome
.
find_element_by_class_name
(
'awsui-input-number-right'
).
send_keys
(
'1'
)
chrome
.
find_element_by_class_name
(
'awsui-input-number-right'
).
send_keys
(
'1'
)
sleep
(
1
)
sleep
(
1
)
#点击其它地方让数量框失焦,让数量真正填入数量框(平台设计如此,不用纠结为啥要此步)
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_171" and @f="F_PURUNIT_TXT" and @i=%s])'
%
i
).
click
()
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_171" and @f="F_PURUNIT_TXT" and @i=%s])'
%
i
).
click
()
sleep
(
1
)
sleep
(
1
)
def
return_pchno
(
self
):
#返回采购单号
def
return_pchno
(
self
):
#返回采购单号
...
@@ -166,25 +179,30 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -166,25 +179,30 @@ class PurchaseOrder():#普通采购单界面操作
sleep
(
1
)
sleep
(
1
)
def
button_click1
(
self
,
type
=
2
,
el1
=
'el-loading-spinner'
,
el2
=
'//p[text()="办理成功"]'
):
#保存/提交订单:type=1为保存,否则为提交
def
button_click1
(
self
,
type
=
2
,
el1
=
'el-loading-spinner'
,
el2
=
'//p[text()="办理成功"]'
):
#保存/提交订单:type=1为保存,否则为提交
if
type
==
1
:
if
type
==
1
:
#保存
#点击保存按钮
chrome
.
find_element_by_xpath
(
'//span[text()="保存"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="保存"]'
).
click
()
sleep
(
1
)
sleep
(
1
)
#元素el1不可见时认为保存成功
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
))
else
:
else
:
#提交
#点击提交按钮
chrome
.
find_element_by_xpath
(
'//span[text()="提交"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="提交"]'
).
click
()
sleep
(
1
)
sleep
(
1
)
#元素el2出现时认为提交成功
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
))
self
.
closetab
()
self
.
closetab
()
def
query_click
(
self
,
menu_name
,
orderno
,
el
,
qrcond
=
'订单号'
):
#查询出订单并点击
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
)
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
(
1
)
sleep
(
1
)
# 输入
采购单号并查询
# 输入
orderno并查询出订单
chrome
.
find_element_by_xpath
(
'//label[text()="%s"]/parent::div/div/div/div/input'
%
qrcond
).
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()="%s"]/parent::div/div/div/div/input'
%
qrcond
).
send_keys
(
Keys
.
ENTER
)
chrome
.
find_element_by_xpath
(
'//label[text()="%s"]/parent::div/div/div/div/input'
%
qrcond
).
send_keys
(
Keys
.
ENTER
)
...
@@ -195,27 +213,31 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -195,27 +213,31 @@ class PurchaseOrder():#普通采购单界面操作
#点击采购单
#点击采购单
# chrome.find_element_by_xpath(
# chrome.find_element_by_xpath(
# '//span[text()="%s"]//parent::div/parent::td//preceding-sibling::td[1]/div/span' % orderno1).click()
# '//span[text()="%s"]//parent::div/parent::td//preceding-sibling::td[1]/div/span' % orderno1).click()
#点击订单,进入表单视图
element
=
chrome
.
find_element_by_xpath
(
'//td[@class="%s"]/div/span'
%
el
)
element
=
chrome
.
find_element_by_xpath
(
'//td[@class="%s"]/div/span'
%
el
)
element
.
click
()
element
.
click
()
sleep
(
1
)
sleep
(
1
)
def
commit_order
(
self
,
type
=
2
):
#保存/提交订单:type=1为保存,否则为提交
def
commit_order
(
self
,
type
=
2
):
#保存/提交订单:type=1为保存,否则为提交
#调用query_click查询并打开订单,进入表单视图
self
.
query_click
(
'普通采购订单'
,
orderno1
,
'vxe-body--column col_19 col--last col--ellipsis dw-click-cell'
)
self
.
query_click
(
'普通采购订单'
,
orderno1
,
'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")]'
))
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
sleep
(
0.5
)
#等待表单视图加载完
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
))
sleep
(
2
)
sleep
(
2
)
#
审批/驳回订单
#
调用button_click1保存/提交订单,type=1为保存,否则为提交
self
.
button_click1
(
type
)
self
.
button_click1
(
type
)
def
switch_loggin
(
self
,
usr
,
pwd
):
#切换登录
def
switch_loggin
(
self
,
usr
,
pwd
):
#切换登录
chrome
.
switch_to
.
default_content
()
chrome
.
switch_to
.
default_content
()
sleep
(
0.5
)
sleep
(
0.5
)
#退出系统
chrome
.
find_element_by_xpath
(
'//span[text()="退出"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="退出"]'
).
click
()
sleep
(
0.5
)
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//button[text()="确定"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//button[text()="确定"]'
).
click
()
sleep
(
1
)
sleep
(
1
)
#输入用户名密码登录
chrome
.
find_element_by_id
(
'input1'
).
clear
()
chrome
.
find_element_by_id
(
'input1'
).
clear
()
chrome
.
find_element_by_id
(
'input1'
).
send_keys
(
usr
)
chrome
.
find_element_by_id
(
'input1'
).
send_keys
(
usr
)
chrome
.
find_element_by_id
(
'input2'
).
clear
()
chrome
.
find_element_by_id
(
'input2'
).
clear
()
...
@@ -224,74 +246,91 @@ class PurchaseOrder():#普通采购单界面操作
...
@@ -224,74 +246,91 @@ 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
,
msg
=
'办理成功'
):
#审批/驳回订单:type=1为审批/其余为驳回订单
def
button_click2
(
self
,
type
=
1
,
msg1
=
'办理成功'
):
#审批/驳回订单: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="意见留言"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
sleep
(
0.5
)
sleep
(
0.5
)
#填写审核通过信息
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()="%s"]'
%
msg
)
#判断审核成功
locator
=
(
By
.
XPATH
,
'//p[text()="%s"]'
%
msg1
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
print
(
'订单审核成功'
)
print
(
'订单审核成功'
)
else
:
else
:
#驳回流程
#点击驳回
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="意见留言"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
sleep
(
0.5
)
sleep
(
0.5
)
#填写驳回信息
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()="发送成功"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
print
(
'订单驳回成功'
)
print
(
'订单驳回成功'
)
self
.
closetab
()
self
.
closetab
()
def
approve_order
(
self
,
type
=
1
):
#审核/驳回订单:type=1为审核通过,否则为审核驳回
def
approve_order
(
self
,
type
=
1
):
#审核/驳回订单:type=1为审核通过,否则为审核驳回
#调用query_click进入表单视图
self
.
query_click
(
'普通采购订单'
,
orderno1
,
'vxe-body--column col_19 col--last col--ellipsis dw-click-cell'
)
self
.
query_click
(
'普通采购订单'
,
orderno1
,
'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")]'
))
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
sleep
(
0.5
)
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
))
sleep
(
2
)
sleep
(
2
)
#调用button_click2审批/驳回
self
.
button_click2
(
type
)
self
.
button_click2
(
type
)
class
Instore
(
PurchaseOrder
):
class
Instore
(
PurchaseOrder
):
#入库三步曲
def
take_over_goods
(
self
,
orderno
,
type
=
2
):
def
take_over_goods
(
self
,
orderno
,
type
=
2
):
#仓库收货
#调用query_click进入表单视图
PurchaseOrder
.
query_click
(
self
,
'仓库收货'
,
orderno
,
'vxe-body--column col_19 col--left col--last col--ellipsis dw-click-cell'
)
PurchaseOrder
.
query_click
(
self
,
'仓库收货'
,
orderno
,
'vxe-body--column col_19 col--left col--last 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
.
presence_of_element_located
((
By
.
XPATH
,
'//span[text()="收货"]'
)))
sleep
(
0.5
)
sleep
(
0.5
)
#点击收货
chrome
.
find_element_by_xpath
(
'//span[text()="收货"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="收货"]'
).
click
()
wait
.
until
(
ec
.
presence_of_element_located
((
By
.
XPATH
,
'//span[text()="确定"]'
)))
wait
.
until
(
ec
.
presence_of_element_located
((
By
.
XPATH
,
'//span[text()="确定"]'
)))
sleep
(
0.5
)
sleep
(
0.5
)
#点击确定
chrome
.
find_element_by_xpath
(
'//span[text()="确定"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="确定"]'
).
click
()
wait
.
until
(
ec
.
presence_of_element_located
((
By
.
XPATH
,
'//span[text()="提交"]'
)))
wait
.
until
(
ec
.
presence_of_element_located
((
By
.
XPATH
,
'//span[text()="提交"]'
)))
sleep
(
0.5
)
sleep
(
0.5
)
#调用button_click3撤回/提交/保存订单
self
.
button_click3
(
type
)
self
.
button_click3
(
type
)
def
button_click3
(
self
,
type
):
def
button_click3
(
self
,
type
=
2
):
if
type
==
1
:
if
type
==
1
:
#撤回订单
chrome
.
find_element_by_xpath
(
'//span[text()="单据撤回"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="单据撤回"]'
).
click
()
elif
type
==
2
:
elif
type
==
2
:
#提交订单
chrome
.
find_element_by_xpath
(
'//span[text()="提交"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="提交"]'
).
click
()
wait
.
until
(
ec
.
presence_of_element_located
((
By
.
XPATH
,
'//p[text()="提交成功"]'
)))
wait
.
until
(
ec
.
presence_of_element_located
((
By
.
XPATH
,
'//p[text()="提交成功"]'
)))
print
(
"收货成功"
)
print
(
"
仓库
收货成功"
)
PurchaseOrder
.
closetab
(
self
)
PurchaseOrder
.
closetab
(
self
)
else
:
else
:
#保存订单
chrome
.
find_element_by_xpath
(
'//span[text()="保存"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="保存"]'
).
click
()
def
goods_check
(
self
,
orderno
,
type
=
2
):
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'
)
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
.
visibility_of_element_located
((
By
.
XPATH
,
'//span[text()="提交"]'
)))
wait
.
until
(
ec
.
visibility_of_element_located
((
By
.
XPATH
,
'//span[text()="提交"]'
)))
sleep
(
1.5
)
sleep
(
1.5
)
#浏览器页面右滑
chrome
.
execute_script
(
"document.getElementsByClassName('vxe-table--footer-wrapper body--wrapper')[0].scrollLeft = 2000"
)
chrome
.
execute_script
(
"document.getElementsByClassName('vxe-table--footer-wrapper body--wrapper')[0].scrollLeft = 2000"
)
sleep
(
1
)
sleep
(
1
)
# chrome.execute_script("document.getElementsByClassName('vxe-table--body-wrapper body--wrapper')[0].scrollTop = %s*30;" % i)
# chrome.execute_script("document.getElementsByClassName('vxe-table--body-wrapper body--wrapper')[0].scrollTop = %s*30;" % i)
#填写商品信息
for
i
in
range
(
1
):
for
i
in
range
(
1
):
#填写生产批号
#填写生产批号
element
=
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_161" and @f="F_PRO_NUM" and @i=%s])'
%
i
)
element
=
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_161" and @f="F_PRO_NUM" and @i=%s])'
%
i
)
...
@@ -342,22 +381,25 @@ class Instore(PurchaseOrder):
...
@@ -342,22 +381,25 @@ class Instore(PurchaseOrder):
sleep
(
0.5
)
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_165" and @f="F_STE_NUM" and @i=%s])'
%
i
).
click
()
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_165" and @f="F_STE_NUM" and @i=%s])'
%
i
).
click
()
sleep
(
0.5
)
sleep
(
0.5
)
#调用button_click1保存/提交订单
PurchaseOrder
.
button_click1
(
self
,
type
)
PurchaseOrder
.
button_click1
(
self
,
type
)
print
(
'仓库验收成功'
)
print
(
'仓库验收成功'
)
def
goods_grounding
(
self
,
orderno
,
type
=
2
):
def
goods_grounding
(
self
,
orderno
,
type
=
2
):
#仓库上架
#调用query_click打开表单视图
PurchaseOrder
.
query_click
(
self
,
'仓库上架'
,
orderno
,
PurchaseOrder
.
query_click
(
self
,
'仓库上架'
,
orderno
,
'vxe-body--column col_19 col--left col--ellipsis dw-click-cell'
)
'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
.
presence_of_element_located
((
By
.
XPATH
,
'//span[text()="提交"]'
)))
sleep
(
0.5
)
sleep
(
0.5
)
# 调用button_click1保存/提交订单
PurchaseOrder
.
button_click1
(
self
,
type
,
el2
=
'//p[text()="流程结束"]'
)
PurchaseOrder
.
button_click1
(
self
,
type
,
el2
=
'//p[text()="流程结束"]'
)
print
(
'仓库上架成功'
)
print
(
'仓库上架成功'
)
###采购退货单页面操作###
class
PurchaseReject
(
PurchaseOrder
):
class
PurchaseReject
(
PurchaseOrder
):
def
relate_order
(
self
,
orderno
,
type
=
2
):
def
relate_order
(
self
,
orderno
,
type
=
2
):
#关联原单退货
#打开采退单
#打开采退单
order_link
=
chrome
.
find_element_by_xpath
(
'//span[text()="采购退货单"]'
)
order_link
=
chrome
.
find_element_by_xpath
(
'//span[text()="采购退货单"]'
)
chrome
.
execute_script
(
"arguments[0].click();"
,
order_link
)
chrome
.
execute_script
(
"arguments[0].click();"
,
order_link
)
...
@@ -402,65 +444,75 @@ class PurchaseReject(PurchaseOrder):
...
@@ -402,65 +444,75 @@ class PurchaseReject(PurchaseOrder):
PurchaseOrder
.
button_click1
(
self
,
type
=
type
)
PurchaseOrder
.
button_click1
(
self
,
type
=
type
)
print
(
"关联原单创建采退单成功,采退单号为:"
,
orderno2
)
print
(
"关联原单创建采退单成功,采退单号为:"
,
orderno2
)
def
return_rejpchno
(
self
):
def
return_rejpchno
(
self
):
#返回采退单号
return
orderno2
return
orderno2
def
commit_order
(
self
,
orderno
,
type
=
2
):
#保存/提交订单:type=1为保存,否则为提交
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
=
'采退单号'
)
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")]'
))
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
sleep
(
0.5
)
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
))
sleep
(
2
)
sleep
(
2
)
# 保存/提交订单
#
调用button_click1
保存/提交订单
PurchaseOrder
.
button_click1
(
self
,
type
)
PurchaseOrder
.
button_click1
(
self
,
type
)
def
approve_order
(
self
,
orderno
,
type
=
1
):
#审核/驳回订单:type=1为审核通过,否则为审核驳回
def
approve_order
(
self
,
orderno
,
type
=
1
):
#审核/驳回订单:type=1为审核通过,否则为审核驳回
#调用query_click进入表单视图
PurchaseOrder
.
query_click
(
self
,
'采购退货单'
,
orderno
,
'vxe-body--column col_19 col--last col--ellipsis dw-click-cell'
,
qrcond
=
'采退单号'
)
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")]'
))
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
sleep
(
0.5
)
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
))
sleep
(
2
)
sleep
(
2
)
PurchaseOrder
.
button_click2
(
self
,
type
,
msg
=
'发送成功'
)
#调用button_click2审核/驳回订单
PurchaseOrder
.
button_click2
(
self
,
type
,
msg1
=
'发送成功'
)
class
Outstore
(
PurchaseOrder
):
class
Outstore
(
PurchaseOrder
):
#出库三步曲
def
deliver_goods
(
self
,
orderno
):
def
deliver_goods
(
self
,
orderno
):
#仓库发货
#调用query_click进入表单视图
PurchaseOrder
.
query_click
(
self
,
'仓库发货'
,
orderno
,
'vxe-body--column col_19 col--last col--ellipsis dw-click-cell'
)
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")]'
))
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
sleep
(
0.5
)
wait
.
until
(
ec
.
visibility_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
.
find_element_by_xpath
(
'//span[text()="确认发货"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="确认发货"]'
).
click
()
wait
.
until
(
ec
.
visibility_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
.
find_element_by_xpath
(
'//span[text()="确定"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="确定"]'
).
click
()
wait
.
until
(
ec
.
visibility_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
.
find_element_by_xpath
(
'//span[text()="确认发货"]'
).
click
()
chrome
.
find_element_by_xpath
(
'//span[text()="确认发货"]'
).
click
()
sleep
(
0.5
)
sleep
(
0.5
)
#判断发货成功
wait
.
until
(
ec
.
presence_of_element_located
((
By
.
XPATH
,
'//p[text()="办理成功"]'
)))
wait
.
until
(
ec
.
presence_of_element_located
((
By
.
XPATH
,
'//p[text()="办理成功"]'
)))
PurchaseOrder
.
closetab
(
self
)
PurchaseOrder
.
closetab
(
self
)
print
(
'仓库发货成功'
)
print
(
'仓库发货成功'
)
def
picking_goods
(
self
,
orderno
,
type
=
2
):
def
picking_goods
(
self
,
orderno
,
type
=
2
):
#仓库拣货
# 调用query_click进入表单视图
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")]'
))
#调用button_click1保存/提交
PurchaseOrder
.
button_click1
(
self
,
type
)
PurchaseOrder
.
button_click1
(
self
,
type
)
print
(
'仓库拣货成功'
)
print
(
'仓库拣货成功'
)
def
outbound_review
(
self
,
orderno
,
type
=
2
):
def
outbound_review
(
self
,
orderno
,
type
=
2
):
#出库复核
# 调用query_click进入表单视图
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")]'
))
#填写商品信息
for
i
in
range
(
1
):
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
)))
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
()
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_117" and @f="F_RECHECK_NUM" and @i=%s])'
%
i
).
click
()
sleep
(
0.5
)
sleep
(
0.5
)
chrome
.
find_element_by_class_name
(
'awsui-input-number-right'
).
send_keys
(
'1'
)
chrome
.
find_element_by_class_name
(
'awsui-input-number-right'
).
send_keys
(
'1'
)
sleep
(
1
)
sleep
(
1
)
# 调用button_click1保存/提交
PurchaseOrder
.
button_click1
(
self
,
type
,
el2
=
'//p[text()="流程结束"]'
)
PurchaseOrder
.
button_click1
(
self
,
type
,
el2
=
'//p[text()="流程结束"]'
)
print
(
'出库复核成功'
)
print
(
'出库复核成功'
)
...
@@ -468,7 +520,7 @@ class Outstore(PurchaseOrder):
...
@@ -468,7 +520,7 @@ class Outstore(PurchaseOrder):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
try
:
try
:
step1
=
LoginSys
1
()
step1
=
LoginSys
()
step2
=
PurchaseOrder
()
step2
=
PurchaseOrder
()
step3
=
Instore
()
step3
=
Instore
()
step4
=
PurchaseReject
()
step4
=
PurchaseReject
()
...
...
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