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
0d59e4b6
Commit
0d59e4b6
authored
Oct 24, 2023
by
章 登恒
Browse files
commit
parent
8481cd3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
testcase/test_scene1/scene1_mainflow.py
View file @
0d59e4b6
...
@@ -6,11 +6,14 @@ import traceback
...
@@ -6,11 +6,14 @@ import traceback
from
airtest.core.api
import
*
from
airtest.core.api
import
*
from
selenium
import
webdriver
from
selenium
import
webdriver
from
selenium.webdriver
import
DesiredCapabilities
from
selenium.webdriver
import
DesiredCapabilities
from
selenium.webdriver.common.by
import
By
from
selenium.webdriver.common.keys
import
Keys
from
selenium.webdriver.common.keys
import
Keys
from
airtest_selenium.proxy
import
*
from
airtest_selenium.proxy
import
*
from
selenium.webdriver
import
Chrome
,
ChromeOptions
from
selenium.webdriver
import
Chrome
,
ChromeOptions
from
airtest.core.api
import
*
from
airtest.core.api
import
*
from
airtest_selenium.proxy
import
*
from
airtest_selenium.proxy
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.mail1
import
send_email1
from
public.tools
import
*
from
public.tools
import
*
...
@@ -20,6 +23,8 @@ opt.headless = False # 把 Chrome 设置成无界面模式,windows/Linux 皆
...
@@ -20,6 +23,8 @@ opt.headless = False # 把 Chrome 设置成无界面模式,windows/Linux 皆
opt
.
add_argument
(
'--start-maximized'
)
opt
.
add_argument
(
'--start-maximized'
)
opt
.
add_argument
(
'--window-size=1280x1024'
)
opt
.
add_argument
(
'--window-size=1280x1024'
)
chrome
=
webdriver
.
Chrome
(
chrome_options
=
opt
)
chrome
=
webdriver
.
Chrome
(
chrome_options
=
opt
)
wait
=
WebDriverWait
(
chrome
,
20
,
poll_frequency
=
0.2
)
SIT_URL
=
'http://scdev.cmic.com.cn:8088/beta/'
#SIT环境地址
SIT_URL
=
'http://scdev.cmic.com.cn:8088/beta/'
#SIT环境地址
#通行证
#通行证
...
@@ -43,12 +48,14 @@ class LoginSys():
...
@@ -43,12 +48,14 @@ class LoginSys():
chrome
.
find_element_by_id
(
'input2'
).
clear
()
chrome
.
find_element_by_id
(
'input2'
).
clear
()
chrome
.
find_element_by_id
(
'input2'
).
send_keys
(
pwd
)
chrome
.
find_element_by_id
(
'input2'
).
send_keys
(
pwd
)
chrome
.
find_element_by_id
(
'input2'
).
send_keys
(
Keys
.
ENTER
)
chrome
.
find_element_by_id
(
'input2'
).
send_keys
(
Keys
.
ENTER
)
while
True
:
locator
=
(
By
.
XPATH
,
'//span[text()="退出"]'
)
try
:
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
if
(
chrome
.
find_element_by_xpath
(
'//span[text()="退出"]'
).
is_displayed
()
==
True
):
# while True:
break
# try:
except
:
# if(chrome.find_element_by_xpath('//span[text()="退出"]').is_displayed()==True):
continue
# break
# except:
# continue
class
PurchaseOrder
():
class
PurchaseOrder
():
def
data_add
(
self
):
def
data_add
(
self
):
...
@@ -133,7 +140,7 @@ class PurchaseOrder():
...
@@ -133,7 +140,7 @@ class PurchaseOrder():
'//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
(
4
)
sleep
(
5
)
#填写数量价格
#填写数量价格
for
i
in
range
(
1
):
for
i
in
range
(
1
):
...
@@ -153,19 +160,110 @@ class PurchaseOrder():
...
@@ -153,19 +160,110 @@ class PurchaseOrder():
# 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")]'))
# chrome.find_element_by_class_name('awsui-tabs-icon close').click()
# chrome.find_element_by_class_name('awsui-tabs-icon close').click()
chrome
.
find_element_by_xpath
(
'//span[@class="awsui-tabs-icon close"]'
).
click
()
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_click
(
self
,
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
)
locator
=
(
By
.
CLASS_NAME
,
'el-loading-spinner'
)
wait
.
until_not
(
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
()
sleep
(
1
)
locator
=
(
By
.
XPATH
,
'//span[text()="办理成功"]'
)
wait
.
until_not
(
ec
.
presence_of_element_located
(
locator
))
print
(
'订单提交成功'
)
print
(
'订单提交成功'
)
sleep
(
10
)
self
.
closetab
()
def
commitorder
(
self
,
type
=
2
):
#1为保存,否则为提交
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
(
'//label[text()="订单号"]/parent::div/div/div/div/input'
).
send_keys
(
orderno1
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'//label[text()="订单号"]/parent::div/div/div/div/input'
).
send_keys
(
Keys
.
ENTER
)
sleep
(
3
)
# locator = (By.CLASS_NAME, 'el-loading-spinner')
# wait.until_not(ec.presence_of_element_located(locator))
# sleep(1)
# 点击采购单
# chrome.find_element_by_xpath(
# '//span[text()="%s"]//parent::div/parent::td//preceding-sibling::td[1]/div/span' % orderno1).click()
chrome
.
find_element_by_xpath
(
'//td[@class="vxe-body--column col_19 col--last col--ellipsis dw-click-cell"]/div/span'
).
click
()
sleep
(
1
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
locator
=
(
By
.
XPATH
,
'//span[text()="提交"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
sleep
(
2
)
# 审批/驳回订单
self
.
button_click1
(
type
)
def
switchloggin
(
self
,
usr
,
pwd
):
chrome
.
switch_to
.
default_content
()
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//span[text()="退出"]'
).
click
()
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//button[text()="确定"]'
).
click
()
sleep
(
1
)
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
))
def
approveorder
(
self
,
type
=
1
):
#type=1为审核通过,否则为审核驳回
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
(
'//label[text()="订单号"]/parent::div/div/div/div/input'
).
send_keys
(
orderno1
)
sleep
(
1
)
chrome
.
find_element_by_xpath
(
'//label[text()="订单号"]/parent::div/div/div/div/input'
).
send_keys
(
Keys
.
ENTER
)
sleep
(
3
)
# locator = (By.CLASS_NAME, 'el-loading-spinner')
# wait.until_not(ec.presence_of_element_located(locator))
# sleep(1)
#点击采购单
# chrome.find_element_by_xpath(
# '//span[text()="%s"]//parent::div/parent::td//preceding-sibling::td[1]/div/span' % orderno1).click()
chrome
.
find_element_by_xpath
(
'//td[@class="vxe-body--column col_19 col--last col--ellipsis dw-click-cell"]/div/span'
).
click
()
sleep
(
1
)
chrome
.
switch_to
.
frame
(
chrome
.
find_element_by_xpath
(
'//iframe[contains(@name,"awsui-dialog-iframe")]'
))
locator
=
(
By
.
XPATH
,
'//span[text()="审核通过"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
sleep
(
2
)
#审批/驳回订单
if
type
==
1
:
chrome
.
find_element_by_xpath
(
'//span[text()="审核通过"]'
).
click
()
locator
=
(
By
.
XPATH
,
'//textarea[@placeholder="意见留言"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//textarea[@placeholder="意见留言"]'
).
send_keys
(
'审核通过'
)
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//span[text()="发送"]'
).
click
()
locator
=
(
By
.
XPATH
,
'//p[text()="办理成功"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
print
(
'订单审核成功'
)
else
:
chrome
.
find_element_by_xpath
(
'//span[text()="审核驳回"]'
).
click
()
locator
=
(
By
.
XPATH
,
'//textarea[@placeholder="意见留言"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//textarea[@placeholder="意见留言"]'
).
send_keys
(
'审核驳回'
)
sleep
(
0.5
)
chrome
.
find_element_by_xpath
(
'//span[text()="发送"]'
).
click
()
locator
=
(
By
.
XPATH
,
'//p[text()="发送成功"]'
)
wait
.
until
(
ec
.
presence_of_element_located
(
locator
))
print
(
'订单驳回成功'
)
self
.
closetab
()
self
.
closetab
()
...
@@ -176,6 +274,9 @@ class PurchaseOrder():
...
@@ -176,6 +274,9 @@ class PurchaseOrder():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
step1
=
LoginSys
()
step1
=
LoginSys
()
step2
=
PurchaseOrder
()
step2
=
PurchaseOrder
()
step1
.
loginsys
(
SIT_URL
,
usr2
,
pwd2
)
step1
.
loginsys
(
SIT_URL
,
usr2
,
pwd2
)
#登录系统
step2
.
data_add
()
step2
.
data_add
()
#填写表单数据
step2
.
button_click
()
step2
.
button_click1
(
1
)
#1为保存,否则为提交
\ No newline at end of file
# step2.commitorder(1)#1为保存,否则为提交
step2
.
switchloggin
(
usr1
,
pwd1
)
#切换登录
step2
.
approveorder
()
#1为审核通过,否则为审核驳回
\ 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