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
37e5bfc2
Commit
37e5bfc2
authored
Oct 25, 2023
by
章 登恒
Browse files
commit
parent
f557de3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
testcase/test_scene1/scene1_mainflow.py
View file @
37e5bfc2
...
...
@@ -39,7 +39,7 @@ salesman = '杨春刚'#业务员名称
productcode
=
10156326
#商品编码
class
LoginSys
():
class
LoginSys
():
#登录
def
loginsys
(
self
,
url
,
usr
,
pwd
):
chrome
.
get
(
url
)
sleep
(
2
)
...
...
@@ -57,8 +57,8 @@ class LoginSys():
# except:
# continue
class
PurchaseOrder
():
def
data_add
(
self
):
class
PurchaseOrder
():
#普通采购单界面操作
def
data_add
(
self
):
#填写表单数据
chrome
.
implicitly_wait
(
10
)
order_link
=
chrome
.
find_element_by_xpath
(
'//span[text()="普通采购订单"]'
)
chrome
.
execute_script
(
"arguments[0].click();"
,
order_link
)
...
...
@@ -151,9 +151,9 @@ class PurchaseOrder():
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'(//td[@colid="col_171" and @f="F_PURUNIT_TXT" and @i=%s])'
%
i
).
click
()
sleep
(
1
)
def
return_pchno
(
self
):
def
return_pchno
(
self
):
#返回采购单号
return
orderno1
def
closetab
(
self
):
def
closetab
(
self
):
#关闭菜单
chrome
.
switch_to
.
default_content
()
sleep
(
1
)
# chrome.switch_to.frame(chrome.find_element_by_xpath('(//iframe[@class="metro-main-frame"])[2]'))
...
...
@@ -162,8 +162,7 @@ class PurchaseOrder():
chrome
.
find_element_by_xpath
(
'//span[@class="awsui-tabs-icon close"]'
).
click
()
sleep
(
1
)
def
button_click1
(
self
,
type
=
2
):
#type=1为保存,2为提交
def
button_click1
(
self
,
type
=
2
):
#保存/提交订单:type=1为保存,否则为提交
if
type
==
1
:
chrome
.
find_element_by_xpath
(
'//span[text()="保存"]'
).
click
()
sleep
(
1
)
...
...
@@ -178,7 +177,7 @@ class PurchaseOrder():
print
(
'订单提交成功'
)
self
.
closetab
()
def
query_c
ommit
(
self
):
def
query_c
lick
(
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]'
))
...
...
@@ -198,15 +197,15 @@ class PurchaseOrder():
sleep
(
1
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
sleep
(
0.5
)
def
commit_order
(
self
,
type
=
2
):
#1为保存,否则为提交
self
.
query_c
ommit
()
def
commit_order
(
self
,
type
=
2
):
#保存/提交订单:type=1为保存,否则为提交
self
.
query_c
lick
()
locator
=
(
By
.
XPATH
,
'//span[text()="提交"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
sleep
(
2
)
# 审批/驳回订单
self
.
button_click1
(
type
)
def
switch_loggin
(
self
,
usr
,
pwd
):
def
switch_loggin
(
self
,
usr
,
pwd
):
#切换登录
chrome
.
switch_to
.
default_content
()
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//span[text()="退出"]'
).
click
()
...
...
@@ -221,8 +220,7 @@ class PurchaseOrder():
locator
=
(
By
.
XPATH
,
'//span[text()="退出"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
def
button_click2
(
self
,
type
):
#1为审批/其余为驳回订单
def
button_click2
(
self
,
type
):
#审批/驳回订单:type=1为审批/其余为驳回订单
if
type
==
1
:
chrome
.
find_element_by_xpath
(
'//span[text()="审核通过"]'
).
click
()
locator
=
(
By
.
XPATH
,
'//textarea[@placeholder="意见留言"]'
)
...
...
@@ -247,9 +245,8 @@ class PurchaseOrder():
print
(
'订单驳回成功'
)
self
.
closetab
()
def
approve_order
(
self
,
type
=
1
):
#type=1为审核通过,否则为审核驳回
self
.
query_commit
()
def
approve_order
(
self
,
type
=
1
):
#审核/驳回订单:type=1为审核通过,否则为审核驳回
self
.
query_click
()
locator
=
(
By
.
XPATH
,
'//span[text()="审核通过"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
sleep
(
2
)
...
...
@@ -266,7 +263,8 @@ if __name__ == '__main__':
step2
=
PurchaseOrder
()
step1
.
loginsys
(
SIT_URL
,
usr2
,
pwd2
)
#登录系统
step2
.
data_add
()
#填写表单数据
step2
.
button_click1
(
1
)
#1为保存,否则为提交
step2
.
button_click1
()
#1为保存,否则为提交
# step2.commitorder(1)#1为保存,否则为提交
step2
.
switch_loggin
(
usr1
,
pwd1
)
#切换登录
step2
.
approve_order
()
#1为审核通过,否则为审核驳回
\ No newline at end of file
step2
.
approve_order
()
#1为审核通过,否则为审核驳回
purchord
=
step2
.
return_pchno
()
#获取采购订单号
\ No newline at end of file
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