使用contest+fixture优化
This commit is contained in:
parent
fdbe145b8b
commit
1bc742299f
|
@ -0,0 +1,12 @@
|
|||
*.pytest_cache
|
||||
*.ini
|
||||
*allure-report
|
||||
*report
|
||||
*.xlsx
|
||||
*.json
|
||||
*.idea
|
||||
*.vscode
|
||||
|
||||
|
||||
# Package Files #
|
||||
|
|
@ -3,12 +3,10 @@
|
|||
# @Time : 2019/11/6 16:15
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : dataCenterAction.py
|
||||
# @File : datacenteraction.py
|
||||
# @Software: PyCharm
|
||||
|
||||
import allure
|
||||
|
||||
from time import sleep
|
||||
from public.pages import dataCenterPage
|
||||
from public.common import log
|
||||
|
|
@ -2,28 +2,32 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2019/10/23 15:04
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : loginAction.py
|
||||
# @Site :
|
||||
# @File : loginaction.py
|
||||
# @Software: PyCharm
|
||||
import allure
|
||||
|
||||
from time import sleep
|
||||
from public.pages import loginPage
|
||||
from public.pages import loginPage
|
||||
from public.pages import basepage
|
||||
from public.common import log
|
||||
|
||||
|
||||
class Login(object):
|
||||
|
||||
def __init__(self,driver):
|
||||
def __init__(self, driver):
|
||||
self.dr = driver
|
||||
self.log = log.Log()
|
||||
|
||||
|
||||
|
||||
@allure.step("登录系统")
|
||||
def login(self, username, password):
|
||||
|
||||
try:
|
||||
with allure.step("登录系统"):
|
||||
allure.attach("用户名:%s"%username)
|
||||
allure.attach("密码:%s"%password)
|
||||
allure.attach("用户名:%s" % username)
|
||||
allure.attach("密码:%s" % password)
|
||||
allure.attach("验证码:1234")
|
||||
|
||||
login = loginPage.LoginPage(self.dr)
|
||||
self.dr.wait(10)
|
||||
login.into_cmp_page()
|
||||
|
@ -35,20 +39,15 @@ class Login(object):
|
|||
login.input_code(1234)
|
||||
sleep(0.5)
|
||||
login.click_loginbutton()
|
||||
|
||||
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
@allure.step("退出系统")
|
||||
def logout(self):
|
||||
self.dr.origin_driver.delete_all_cookies()
|
||||
|
||||
|
||||
|
||||
# class ShowFunName():
|
||||
# def __init__(self, func):
|
||||
# self._func = func
|
||||
#
|
||||
# def __call__(self, a):
|
||||
# print('function name:', self._func.__name__)
|
||||
# return self._func(a)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import json
|
||||
|
@ -56,10 +55,8 @@ if __name__ == '__main__':
|
|||
from config import globalparam
|
||||
dr = pyselenium.PySelenium(globalparam.browser)
|
||||
dr.max_window()
|
||||
login = Login(dr).login("上海管理员","1qaz!QAZ")
|
||||
login = Login(dr).login("上海管理员", "1qaz!QAZ")
|
||||
cookies = dr.origin_driver.get_cookies()
|
||||
jsonCookies = json.dumps(cookies)
|
||||
with open('cookies.json', 'w') as f:
|
||||
f.write(jsonCookies)
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2019/12/11 9:04
|
||||
# @Author : mrwuzs
|
||||
# @Email : mrwuzs@outlook.com
|
||||
# @File : logoutaction.py
|
||||
# @Software: PyCharm
|
||||
|
||||
import allure
|
||||
|
||||
from time import sleep
|
||||
from public.pages import basepage
|
||||
|
||||
|
||||
class Logout(object):
|
||||
|
||||
def __init__(self, driver):
|
||||
self.dr = driver
|
||||
|
||||
@allure.step("退出系统")
|
||||
def logout(self):
|
||||
|
||||
try:
|
||||
bspage = basepage.Page(self.dr)
|
||||
bspage.move_to_el_icon_right()
|
||||
sleep(2)
|
||||
bspage.click_logout_button()
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.common import cookiesAction
|
||||
|
||||
dr = pyselenium.PySelenium(globalparam.browser)
|
||||
dr.max_window()
|
||||
dr.open('http://192.168.54.13/#/login')
|
||||
dr = cookiesAction.add_cookie(dr)
|
||||
dr.open('http://192.168.54.13/csdp/portal/#/resourceUsage')
|
||||
logout = Logout(dr)
|
||||
logout.logout()
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
# @Time : 2019/11/6 15:45
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : phyNetworkResAction.py
|
||||
# @File : phynetworkresaction.py
|
||||
# @Software: PyCharm
|
||||
|
||||
import allure
|
||||
|
@ -11,10 +11,10 @@ import allure
|
|||
from time import sleep
|
||||
from public.pages import dataCenterPage
|
||||
from public.common import log
|
||||
from public.appModel import dataCenterAction
|
||||
from public.appmodel import datacenteraction
|
||||
|
||||
|
||||
class PhyNetworkResAction(dataCenterAction.DataCenterAction):
|
||||
class PhyNetworkResAction(datacenteraction.DataCenterAction):
|
||||
@allure.step("创建物理网络")
|
||||
def create_pht_netwok(
|
||||
self,
|
|
@ -3,7 +3,7 @@
|
|||
# @Time : 2019/10/25 10:07
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : projectAction.py
|
||||
# @File : projectaction.py
|
||||
# @Software: PyCharm
|
||||
import allure
|
||||
|
||||
|
@ -52,7 +52,7 @@ class PojectAction(object):
|
|||
if __name__ == '__main__':
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
dr = pyselenium.PySelenium(globalparam.browser)
|
||||
dr.max_window()
|
|
@ -3,7 +3,7 @@
|
|||
# @Time : 200.59/0.50/23 0.55:48
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : resNodeAction.py
|
||||
# @File : resnodeaction.py
|
||||
# @Software: PyCharm
|
||||
import allure
|
||||
|
||||
|
@ -240,7 +240,7 @@ class Add_Res_Node(object):
|
|||
if __name__ == '__main__':
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
dr = pyselenium.PySelenium(globalparam.browser)
|
||||
dr.max_window()
|
|
@ -3,7 +3,7 @@
|
|||
# @Time : 2019/10/24 8:47
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : resSyncAction.py
|
||||
# @File : ressyncaction.py
|
||||
# @Software: PyCharm
|
||||
import allure
|
||||
|
||||
|
@ -49,10 +49,9 @@ class ResSync(object):
|
|||
sleep(1)
|
||||
# self.syncPage.switch_commit_page()
|
||||
self.syncPage.click_commit_buttun()
|
||||
sleep(1)
|
||||
commit_button_flag = self.syncPage.is_exists_commit_buttun()
|
||||
if commit_button_flag is True:
|
||||
commit_button_element = self.syncPage.commit_buttun_element().is_displayed()
|
||||
print(commit_button_element)
|
||||
publicfunction.add_image(self.dr, "物理资源无法同步")
|
||||
self.dr.ESC()
|
||||
sleep(60)
|
||||
|
@ -61,11 +60,10 @@ class ResSync(object):
|
|||
if __name__ == '__main__':
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
dr = pyselenium.PySelenium(globalparam.browser)
|
||||
dr.max_window()
|
||||
login = Login(dr).login("系统管理员", "123456")
|
||||
|
||||
res = ResSync(dr)
|
||||
res.phy_res_sync("", "111111", "DC1", "DC2")
|
||||
res.phy_res_sync("上海", "上海资源池", "DC1", "DC2")
|
|
@ -3,7 +3,7 @@
|
|||
# @Time : 2019/10/24 19:38
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : tenantAction.py
|
||||
# @File : tenantaction.py
|
||||
# @Software: PyCharm
|
||||
import allure
|
||||
|
||||
|
@ -73,7 +73,7 @@ class TenantAction(object):
|
|||
if __name__ == '__main__':
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
dr = pyselenium.PySelenium(globalparam.browser)
|
||||
dr.max_window()
|
|
@ -3,7 +3,7 @@
|
|||
# @Time : 2019/10/24 15:19
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : userAction.py
|
||||
# @File : useraction.py
|
||||
# @Software: PyCharm
|
||||
import allure
|
||||
|
||||
|
@ -81,8 +81,11 @@ class UserAction(object):
|
|||
self.mgrpage.click_general_post()
|
||||
self.mgrpage.click_user_buttun()
|
||||
self.mgrpage.input_and_search_user(username)
|
||||
self.mgrpage.click_remove_user_button()
|
||||
self.mgrpage.click_remove_user_success_button()
|
||||
try:
|
||||
self.mgrpage.click_remove_user_button()
|
||||
self.mgrpage.click_remove_user_success_button()
|
||||
except ValueError as e:
|
||||
self.log.error(e)
|
||||
|
||||
def create_tenant_user(
|
||||
self,
|
||||
|
@ -147,7 +150,7 @@ class UserAction(object):
|
|||
if __name__ == '__main__':
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
dr = pyselenium.PySelenium(globalparam.browser)
|
||||
dr.max_window()
|
|
@ -3,7 +3,7 @@
|
|||
# @Time : 2019/10/24 11:34
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : vdcAction.py
|
||||
# @File : vdcaction.py
|
||||
# @Software: PyCharm
|
||||
import allure
|
||||
from time import sleep
|
||||
|
@ -104,7 +104,7 @@ class VdcACction(object):
|
|||
if __name__ == '__main__':
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
dr = pyselenium.PySelenium(globalparam.browser)
|
||||
dr.max_window()
|
|
@ -1,20 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2019/11/1 21:40
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : Consts.py
|
||||
# @Software: PyCharm
|
||||
|
||||
"""
|
||||
接口全局变量
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
# 接口响应时间list,单位毫秒
|
||||
STRESS_LIST = []
|
||||
|
||||
# 接口执行结果list
|
||||
RESULT_LIST = []
|
|
@ -1,31 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2019/11/7 11:47
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : Screen.py
|
||||
# @Software: PyCharm
|
||||
from public.common import publicfunction
|
||||
from functools import wraps
|
||||
from public.common import log
|
||||
|
||||
class Screen(object):
|
||||
"""失败截图装饰器"""
|
||||
|
||||
def __init__(self, driver):
|
||||
self.driver = driver
|
||||
self.log = log.Log()
|
||||
|
||||
def __call__(self, func):
|
||||
@wraps(func)
|
||||
def inner(*args, **kwargs):
|
||||
try:
|
||||
result = func(*args, **kwargs)
|
||||
except:
|
||||
publicfunction.get_img(self.driver,func.__name__)
|
||||
else:
|
||||
self.log.info(" %s 脚本运行正常" %func.__name__)
|
||||
|
||||
return result
|
||||
|
||||
return inner
|
|
@ -1,83 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2019/11/1 21:38
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @Software: PyCharm
|
||||
|
||||
"""
|
||||
封装Assert方法
|
||||
|
||||
"""
|
||||
from public.common.log import Log
|
||||
from public.common import Consts
|
||||
import json
|
||||
|
||||
|
||||
class Assertions:
|
||||
def __init__(self):
|
||||
self.log = Log()
|
||||
|
||||
def assert_in_text(self, body, expected_msg):
|
||||
"""
|
||||
验证response body中是否包含预期字符串
|
||||
:param body:
|
||||
:param expected_msg:
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
text = json.dumps(body, ensure_ascii=False)
|
||||
# print(text)
|
||||
assert expected_msg in text
|
||||
return True
|
||||
|
||||
except BaseException:
|
||||
self.log.error(
|
||||
"Response body Does not contain expected_msg, expected_msg is %s" %
|
||||
expected_msg)
|
||||
Consts.RESULT_LIST.append('fail')
|
||||
|
||||
raise
|
||||
|
||||
def assert_text(self, body, expected_msg):
|
||||
"""
|
||||
验证response body中是否等于预期字符串
|
||||
:param body:
|
||||
:param expected_msg:
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
assert body == expected_msg
|
||||
return True
|
||||
|
||||
except BaseException:
|
||||
self.log.error(
|
||||
"Response body != expected_msg, expected_msg is %s, body is %s" %
|
||||
(expected_msg, body))
|
||||
Consts.RESULT_LIST.append('fail')
|
||||
|
||||
raise
|
||||
|
||||
def assert_Ture(self, flag, expected_time):
|
||||
"""
|
||||
验证response body响应时间小于预期最大响应时间,单位:毫秒
|
||||
:param body:
|
||||
:param expected_time:
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
assert flag is True
|
||||
return True
|
||||
|
||||
except BaseException:
|
||||
self.log.error(
|
||||
"Restimeponse > expected_time, expected_time is %s, time is %s" %
|
||||
(expected_time, time))
|
||||
Consts.RESULT_LIST.append('fail')
|
||||
|
||||
raise
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
AS = Assertions()
|
||||
AS.assert_code(203, 203)
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2019/11/1 21:38
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @Software: PyCharm
|
||||
|
||||
|
||||
class Page(object):
|
||||
"""
|
||||
This is a base page class for Page Object.
|
||||
"""
|
||||
|
||||
def __init__(self, selenium_driver):
|
||||
self.dr = selenium_driver
|
||||
|
||||
def menu_bar_hovers(self):
|
||||
self.dr.get_element("xpath->//i")
|
||||
|
||||
def click_res_node_mag(self):
|
||||
self.dr.click("xpath -> //li[contains(.,'资源节点管理')]")
|
|
@ -8,12 +8,11 @@
|
|||
import json
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
cookie_path = globalparam.cookie_path + "\\cookies.json"
|
||||
|
||||
|
||||
def get_cookie(username, password):
|
||||
|
||||
dr = pyselenium.PySelenium(globalparam.browser)
|
||||
dr.max_window()
|
||||
Login(dr).login(username, password)
|
||||
|
@ -40,4 +39,4 @@ def add_cookie(dr):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
get_cookie("上海管理员", "1qaz!QAZ")
|
||||
get_cookie("系统管理员", "123456")
|
||||
|
|
|
@ -33,8 +33,6 @@ def get_xls_to_dict(xlsname, sheetname):
|
|||
result = dict(zip(keys, result1))
|
||||
return result
|
||||
|
||||
|
||||
|
||||
def get_url_data(title):
|
||||
"""
|
||||
读取txt文件,转化成dict;读取url和导航栏的对应关系
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# @Time : 2019/11/2 13:00
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @File : initialize_Env.py
|
||||
# @File : initializeEnv.py
|
||||
# @Software: PyCharm
|
||||
|
||||
from public.common.log import Log
|
||||
|
@ -13,7 +13,6 @@ from config.confRelevance import ConfRelevance
|
|||
CONF_PATH = globalparam.config_file_path + "\\config.ini"
|
||||
ENV_PATH = globalparam.xml_report_path + "\\environment.xml"
|
||||
|
||||
|
||||
class Init_Env:
|
||||
"""初始化环境信息,更新xml文件"""
|
||||
|
|
@ -9,7 +9,7 @@ import allure
|
|||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.common.log import Log
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
from public.common import publicfunction
|
||||
|
||||
|
||||
|
@ -18,20 +18,32 @@ class MyTest():
|
|||
The base class is for all testcase.
|
||||
"""
|
||||
|
||||
def setup_class(self):
|
||||
self.logger = Log()
|
||||
self.imge_path = globalparam.img_path
|
||||
self.logger.info(
|
||||
def setup_module(module):
|
||||
""" setup any state specific to the execution of the given module."""
|
||||
print("123544444444444444444444444444444444")
|
||||
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
""" teardown any state that was previously setup with a setup_module
|
||||
method.
|
||||
"""
|
||||
print("123544444444444444444444444444444444")
|
||||
|
||||
def setup_class(cls):
|
||||
cls.logger = Log()
|
||||
cls.imge_path = globalparam.img_path
|
||||
cls.logger.info(
|
||||
'############################### START ###############################')
|
||||
self.dr = pyselenium.PySelenium(globalparam.browser)
|
||||
self.dr.max_window()
|
||||
self.login = Login(self.dr)
|
||||
cls.dr = pyselenium.PySelenium(globalparam.browser,globalparam.headless)
|
||||
cls.dr.max_window()
|
||||
cls.login = Login(cls.dr)
|
||||
|
||||
|
||||
|
||||
def teardown_class(self):
|
||||
self.dr.quit()
|
||||
self.logger.info(
|
||||
def teardown_class(cls):
|
||||
cls.dr.quit()
|
||||
cls.logger.info(
|
||||
'############################### End ###############################')
|
||||
|
||||
def _add_image(self,filename):
|
||||
|
|
|
@ -13,8 +13,8 @@ from config import globalparam
|
|||
|
||||
# 截图放到report下的img目录下
|
||||
def get_img(dr, filename):
|
||||
if not os.path.exists(globalparam.img_path ):
|
||||
os.makedirs(globalparam.img_path )
|
||||
if not os.path.exists(globalparam.img_path):
|
||||
os.makedirs(globalparam.img_path)
|
||||
path = globalparam.img_path + '\\' + filename + \
|
||||
'_' + time.strftime('%Y_%m_%d_%H_%M_%S') + '.png'
|
||||
# path = globalparam.img_path + '\\' + filename + '.png'
|
||||
|
@ -22,9 +22,10 @@ def get_img(dr, filename):
|
|||
|
||||
return path
|
||||
|
||||
def add_image(dr,filename):
|
||||
|
||||
def add_image(dr, filename):
|
||||
image_tmp = get_img(dr, filename)
|
||||
with open(image_tmp, mode='rb') as f:
|
||||
with open(image_tmp, mode='rb') as f:
|
||||
file = f.read()
|
||||
allure.attach(file, filename, allure.attachment_type.PNG)
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class PySelenium(object):
|
|||
making it easier to use.
|
||||
"""
|
||||
|
||||
def __init__(self, browser='ff', remoteAddress=None):
|
||||
def __init__(self, browser='ff', headless=False, remoteAddress=None):
|
||||
"""
|
||||
remote consle:
|
||||
dr = PySelenium('RChrome','127.0.0.1:8080')
|
||||
|
@ -41,15 +41,31 @@ class PySelenium(object):
|
|||
'version': '',
|
||||
'javascriptEnabled': True}
|
||||
dr = None
|
||||
#设置日志路径
|
||||
# 设置日志路径
|
||||
geckodriver_log_path = globalparam.log_path
|
||||
logname_geckodriver = os.path.join(geckodriver_log_path, 'geckodriver_' + '{0}.log'.format(
|
||||
time.strftime('%Y-%m-%d')))
|
||||
logname_geckodriver = os.path.join(
|
||||
geckodriver_log_path, 'geckodriver_' + '{0}.log'.format(
|
||||
time.strftime('%Y-%m-%d')))
|
||||
if remoteAddress is None:
|
||||
if browser == "firefox" or browser == "ff":
|
||||
dr = webdriver.Firefox(service_log_path= logname_geckodriver)
|
||||
if headless:
|
||||
firfox_option = webdriver.FirefoxOptions()
|
||||
firfox_option.add_argument("--headless") # 设置火狐为headless无界面模式
|
||||
firfox_option.add_argument("--disable-gpu")
|
||||
dr = webdriver.Firefox(
|
||||
service_log_path=logname_geckodriver,
|
||||
options=firfox_option)
|
||||
else:
|
||||
dr = webdriver.Firefox(
|
||||
service_log_path=logname_geckodriver)
|
||||
elif browser == "chrome" or browser == "Chrome":
|
||||
dr = webdriver.Chrome()
|
||||
if headless:
|
||||
chrome_options = webdriver.ChromeOptions()
|
||||
chrome_options.add_argument("--headless")# 设置chrome为headless无界面模式
|
||||
chrome_options.add_argument("--disable-gpu")
|
||||
dr = webdriver.Chrome(chrome_options=chrome_options)
|
||||
else:
|
||||
dr = webdriver.Chrome()
|
||||
elif browser == "internet explorer" or browser == "ie":
|
||||
dr = webdriver.Ie()
|
||||
elif browser == "opera":
|
||||
|
@ -452,13 +468,12 @@ class PySelenium(object):
|
|||
send esc key
|
||||
:return:
|
||||
"""
|
||||
t1 = time
|
||||
self.driver.send_keys(Keys.ESCAPE)
|
||||
t1 = time.time()
|
||||
ActionChains(self.driver).send_keys(Keys.ESCAPE).perform()
|
||||
self.my_print(
|
||||
"{0} send the key esc, Spend {1} seconds".format(
|
||||
success, time.time() - t1))
|
||||
|
||||
|
||||
def js(self, script):
|
||||
"""
|
||||
Execute JavaScript scripts.
|
||||
|
|
|
@ -5,50 +5,63 @@
|
|||
# @Site :
|
||||
# @File : authProjectPage.py
|
||||
# @Software: PyCharm
|
||||
from public.common import basepage
|
||||
from public.pages import basepage
|
||||
from config import globalparam
|
||||
|
||||
|
||||
class AuthProjectPage(basepage.Page):
|
||||
|
||||
def open_authproject(self):
|
||||
self.log.debug("打开项目管理页面")
|
||||
self.dr.open(
|
||||
globalparam.url +
|
||||
"/csdp/manage/#/manage-view/adminManage/auth/projects")
|
||||
|
||||
def click_new_create_buttun(self):
|
||||
self.log.debug("点击创建项目按钮")
|
||||
self.dr.click("xpath->//div[5]/button/i")
|
||||
|
||||
def click_select_tenant(self):
|
||||
self.log.debug("点击选择运营部门")
|
||||
self.dr.click("xpath->//span[contains(.,'请选择运营部门')]")
|
||||
|
||||
def input_and_select_tenant(self, value):
|
||||
self.log.debug("选择运营部门")
|
||||
self.dr.type_and_enter("xpath->(//input[@type='search'])[3]", value)
|
||||
|
||||
def click_select_zzjg(self):
|
||||
self.log.debug("点击选择组织机构按钮")
|
||||
self.dr.click("xpath->//div[3]/div/div/button[2]/i")
|
||||
|
||||
def input_project_name(self, value):
|
||||
self.log.debug("输入项目名称")
|
||||
self.dr.clear_type("name->projectName", value)
|
||||
|
||||
def input_project_desc(self, value):
|
||||
self.log.debug("输入项目描述")
|
||||
self.dr.clear_type("name->projectDescription", value)
|
||||
|
||||
def select_zzjg(self, value):
|
||||
self.log.debug("选择组织机构")
|
||||
self.dr.click("xpath->//a[contains(text(),'%s')]" % value)
|
||||
|
||||
def click_save_new_project(self):
|
||||
self.log.debug("点击保存项目按钮")
|
||||
self.dr.click("xpath->(//button[@type='button'])[10]")
|
||||
|
||||
def input_and_search_project(self, value):
|
||||
self.log.debug("搜索项目名称")
|
||||
self.dr.type_and_enter(
|
||||
"xpath->//div[@class='table-toolbar']/div/div//form/div/div/input", value)
|
||||
|
||||
def click_project_more_button(self):
|
||||
self.log.debug("点击更多按钮")
|
||||
self.dr.click("xpath->//span[contains(.,'更多')]")
|
||||
|
||||
def click_project_delete_button(self):
|
||||
self.log.debug("点击删除按钮")
|
||||
self.dr.click("xpath->//button[contains(.,'删除')]")
|
||||
|
||||
def click_project_delete_success_button(self):
|
||||
self.log.debug("点击确定按钮")
|
||||
self.dr.click("xpath->//a[contains(.,'确定')]")
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# @File : authTenantPage.py
|
||||
# @Software: PyCharm
|
||||
|
||||
from public.common import basepage
|
||||
from public.pages import basepage
|
||||
from config import globalparam
|
||||
|
||||
|
||||
|
@ -18,44 +18,58 @@ class AuthTenantPage(basepage.Page):
|
|||
"/csdp/manage/#/manage-view/adminManage/auth/tenant")
|
||||
|
||||
def click_create_tenant_button(self):
|
||||
self.log.debug("点击新建运营部门按钮")
|
||||
self.dr.click("xpath->//button[contains(.,'新建运营部门')]")
|
||||
|
||||
def input_tenant_name(self, value):
|
||||
self.log.debug("输入运营部门名称")
|
||||
self.dr.clear_type("name->tenantName", value)
|
||||
|
||||
def input_linkman_name(self, value):
|
||||
self.log.debug("输入联系人名称")
|
||||
self.dr.clear_type("name->contact", value)
|
||||
|
||||
def input_linkman_phoneno(self, value):
|
||||
self.log.debug("输入联系人电话")
|
||||
self.dr.clear_type("name->phoneNo", value)
|
||||
|
||||
def click_save_button(self):
|
||||
self.log.debug("点击保存按钮")
|
||||
self.dr.click("xpath->//button[@type='submit']")
|
||||
|
||||
def input_secrch_tenant(self, value):
|
||||
self.log.debug("搜素运营部门")
|
||||
self.dr.type_and_enter(
|
||||
"xpath->//div[@class='col-md-3 padding-0']/form/div/div/input", value)
|
||||
|
||||
def click_pull_down_button(self):
|
||||
self.log.debug("点击下拉按钮")
|
||||
self.dr.click("xpath->//div[@id='card']/div/div[2]/div/a[2]/i")
|
||||
|
||||
def click_tenant_delete_button(self):
|
||||
self.log.debug("点击删除按钮")
|
||||
self.dr.click("xpath->//a[contains(text(),'删除')]")
|
||||
|
||||
def click_tenant_delete_success_button(self):
|
||||
self.log.debug("点击确定按钮")
|
||||
self.dr.click("xpath->//a[contains(.,'确定')]")
|
||||
|
||||
def click_tenant_view_details_button(self):
|
||||
self.log.debug("点击查看详细按钮")
|
||||
self.dr.click("xpath->//a[contains(.,'查看详细')]")
|
||||
|
||||
def click_post_button(self):
|
||||
self.log.debug("点击岗位按钮")
|
||||
self.dr.click("xpath->//a[contains(text(),'岗位')]")
|
||||
|
||||
def click_user_num_button(self):
|
||||
self.log.debug("点击用户数量按钮")
|
||||
self.dr.click("xpath->//td[3]/div/a")
|
||||
|
||||
def click_remove_user_button(self):
|
||||
self.log.debug("点击移除按钮")
|
||||
self.dr.click("xpath->//button[contains(.,'移除')]")
|
||||
|
||||
def click_remove_user_success_button(self):
|
||||
self.log.debug("点击确定按钮")
|
||||
self.dr.click("xpath->//a[contains(.,'确定')]")
|
||||
|
|
|
@ -6,24 +6,28 @@
|
|||
# @File : authUserPage.py
|
||||
# @Software: PyCharm
|
||||
|
||||
from public.common import basepage
|
||||
from public.pages import basepage
|
||||
from config import globalparam
|
||||
|
||||
|
||||
class AuthUsertPage(basepage.Page):
|
||||
|
||||
def open_authuser(self):
|
||||
self.log.debug("打开用户管理页面")
|
||||
self.dr.open(
|
||||
globalparam.url +
|
||||
"/csdp/manage/#/manage-view/adminManage/auth/user")
|
||||
|
||||
def click_crate_user_button(self):
|
||||
self.log.debug("点击创建用户按钮")
|
||||
self.dr.click("xpath->(//button[@type='button'])[10]")
|
||||
|
||||
def click_selcet_tenant(self):
|
||||
self.log.debug("点击选择运营部门按钮")
|
||||
self.dr.click("xpath->//span/button/i")
|
||||
|
||||
def input_select_tenant(self, value):
|
||||
self.log.debug("输入并且选择运营部门")
|
||||
self.dr.type_and_enter(
|
||||
"xpath->//div[@id='selectClientModal']/div[2]/div/div/div/form/div/div/input",
|
||||
value)
|
||||
|
@ -32,42 +36,54 @@ class AuthUsertPage(basepage.Page):
|
|||
# ,value)
|
||||
|
||||
def click_radio_tenant_name(self):
|
||||
self.log.debug("点击运营部门单选框")
|
||||
self.dr.click(
|
||||
"xpath->//div[@id='selectClientModal']/div[@class='modal-body']/div[@class='box-body form']/"
|
||||
"table-component/div/table/tbody/tr/td[1]/div/span/input[@type='radio']")
|
||||
|
||||
def click_commit_button(self):
|
||||
self.log.debug("点击确定按钮")
|
||||
self.dr.click(
|
||||
"xpath->//div[@id='selectClientModal']/div[@class='modal-footer']/"
|
||||
"button[@class='btn btn-flat btn-primary']")
|
||||
|
||||
def input_username(self, value):
|
||||
self.log.debug("输入用户名")
|
||||
self.dr.clear_type("xpath->(//input[@name='username'])[2]", value)
|
||||
|
||||
def input_firstname(self, value):
|
||||
self.log.debug("输入真实姓名")
|
||||
self.dr.clear_type("xpath->(//input[@name='firstname'])[2]", value)
|
||||
|
||||
def input_password(self, value):
|
||||
self.log.debug("输入密码")
|
||||
self.dr.clear_type("xpath->(//input[@name='password'])[2]", value)
|
||||
|
||||
def input_repassword(self, value):
|
||||
self.log.debug("重复输入密码")
|
||||
self.dr.clear_type("xpath->(//input[@name='_repassword'])[2]", value)
|
||||
|
||||
def input_email(self, value):
|
||||
self.log.debug("输入电子邮件")
|
||||
self.dr.clear_type("xpath->(//input[@name='email'])[2]", value)
|
||||
|
||||
def click_new_user_save_button(self):
|
||||
self.log.debug("点击保存按钮")
|
||||
self.dr.click("xpath->//form/div[2]/div/div/button")
|
||||
|
||||
def input_select_user(self, value):
|
||||
self.log.debug("搜索用户名")
|
||||
self.dr.type_and_enter(
|
||||
"xpath->//div[@class='table-toolbar']/div/div//form/div/div/input", value)
|
||||
|
||||
def click_user_more_button(self):
|
||||
self.log.debug("点击更多按钮")
|
||||
self.dr.click("xpath->//span[contains(.,'更多')]")
|
||||
|
||||
def click_user_delete_button(self):
|
||||
self.log.debug("点击删除按钮")
|
||||
self.dr.click("xpath->//button[contains(.,'删除')]")
|
||||
|
||||
def click_user_delete_success_button(self):
|
||||
self.log.debug("点击确定按钮")
|
||||
self.dr.click("xpath->//a[contains(.,'确定')]")
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2019/11/1 21:38
|
||||
# @Author : mrwuzs
|
||||
# @Site :
|
||||
# @Software: PyCharm
|
||||
|
||||
from public.common import log
|
||||
from config import globalparam
|
||||
|
||||
class Page(object):
|
||||
"""
|
||||
This is a base page class for Page Object.
|
||||
"""
|
||||
|
||||
def __init__(self, selenium_driver):
|
||||
self.dr = selenium_driver
|
||||
self.log = log.Log()
|
||||
|
||||
def menu_bar_hovers(self):
|
||||
self.log.debug("点击菜单按钮")
|
||||
self.dr.click("xpath->//i")
|
||||
|
||||
def click_res_node_mag(self):
|
||||
self.log.debug("点击资源节点管理")
|
||||
self.dr.click("xpath -> //li[contains(.,'资源节点管理')]")
|
||||
|
||||
def open_resource_overview(self):
|
||||
self.log.debug("打开项目管理页面")
|
||||
self.dr.open(
|
||||
globalparam.url +
|
||||
"/csdp/portal/#/resourceOverview")
|
||||
|
||||
def move_to_el_icon_right(self):
|
||||
self.log.debug("鼠标悬停到下拉按钮")
|
||||
self.dr.move_to_element("xpath->//div[@id='app']/section/header/div/div/div[3]/div[3]/span/i")
|
||||
|
||||
def click_logout_button(self):
|
||||
self.log.debug("点击退出按钮")
|
||||
self.dr.click("xpath->//ul/li[text()='退出']")
|
|
@ -5,7 +5,7 @@
|
|||
# @Site :
|
||||
# @File : dataCenterPage.py
|
||||
# @Software: PyCharm
|
||||
from public.common import basepage
|
||||
from public.pages import basepage
|
||||
from config import globalparam
|
||||
|
||||
class DataCenterPage(basepage.Page):
|
||||
|
@ -100,9 +100,11 @@ class DataCenterPage(basepage.Page):
|
|||
|
||||
#保存
|
||||
def click_save_phy_net_button(self):
|
||||
self.log.debug("点击保存按钮")
|
||||
self.dr.click("xpath->(//button[@type='submit'])[2]")
|
||||
|
||||
#取消
|
||||
def click_cancel_phy_net_button(self):
|
||||
self.log.debug("点击确定取消")
|
||||
self.dr.click("xpath->//div[@id='net_modal']/form/div[3]/button[2]")
|
||||
|
||||
|
|
|
@ -1,21 +1,26 @@
|
|||
# coding=utf-8
|
||||
|
||||
from public.common import basepage
|
||||
import allure
|
||||
from public.pages import basepage
|
||||
from config import globalparam
|
||||
|
||||
|
||||
class LoginPage(basepage.Page):
|
||||
|
||||
@allure.step("打开CSDP登录页面")
|
||||
def into_cmp_page(self):
|
||||
"""打开CMP首页"""
|
||||
self.log.debug("打开CSDP登录页面")
|
||||
self.dr.open(globalparam.url)
|
||||
|
||||
def input_username(self, values):
|
||||
"""输入用户名"""
|
||||
self.log.debug("输入用户名")
|
||||
self.dr.clear_type("xpath -> //input[@name='username']", values)
|
||||
|
||||
def input_password(self, values):
|
||||
"""输入用户名"""
|
||||
"""输入密码"""
|
||||
self.log.debug("输入密码")
|
||||
self.dr.clear_type("xpath -> //input[@name='password']", values)
|
||||
|
||||
def input_code(self, valuses):
|
||||
|
@ -24,6 +29,7 @@ class LoginPage(basepage.Page):
|
|||
:param valuses:
|
||||
:return:
|
||||
"""
|
||||
self.log.debug("输入验证码")
|
||||
self.dr.clear_type("xpath -> //input[@name='captcha']", valuses)
|
||||
|
||||
def click_loginbutton(self):
|
||||
|
@ -31,16 +37,5 @@ class LoginPage(basepage.Page):
|
|||
点击登录按钮
|
||||
:return:
|
||||
'''''
|
||||
self.log.debug("点击登录按钮")
|
||||
self.dr.click("xpath -> //button[contains(.,'登录')]")
|
||||
|
||||
# def input_search_key(self, values):
|
||||
# """输入搜索关键词"""
|
||||
# self.dr.clear_type('id->kw', values)
|
||||
#
|
||||
# def click_search_button(self):
|
||||
# """点击搜索按钮"""
|
||||
# self.dr.click('id->su')
|
||||
#
|
||||
# def return_title(self):
|
||||
# """返回该页面的title"""
|
||||
# return self.dr.get_title()
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# @File : menuPage.py
|
||||
# @Software: PyCharm
|
||||
|
||||
from public.common import basepage
|
||||
from public.pages import basepage
|
||||
|
||||
|
||||
class MenuPage(basepage.Page):
|
||||
|
|
|
@ -7,26 +7,30 @@
|
|||
# @Software: PyCharm
|
||||
|
||||
|
||||
from public.common import basepage
|
||||
from public.pages import basepage
|
||||
from config import globalparam
|
||||
|
||||
|
||||
class ResSyncPage(basepage.Page):
|
||||
|
||||
def open_ressyncpage(self):
|
||||
self.log.debug("打开资源同步页面")
|
||||
self.dr.open(
|
||||
globalparam.url +
|
||||
"/csdp/manage/#/manage-view/resource/sys_ResourceSynchroniz/osphysicalsync")
|
||||
|
||||
def open_osphysicalsyncpage(self):
|
||||
self.log.debug("打开物理资源同步页面")
|
||||
self.dr.open(
|
||||
globalparam.url +
|
||||
"/csdp/manage/#/manage-view/resource/sys_ResourceSynchroniz/osphysicalsync")
|
||||
|
||||
def click_phy_res_sync(self):
|
||||
self.log.debug("点击物理资源同步到云管")
|
||||
self.dr.click("xpath->//span[contains(.,'物理资源同步到云管')]")
|
||||
|
||||
def click_select_region(self):
|
||||
self.log.debug("选择资源节点")
|
||||
self.dr.click("xpath->//div/div/div/div/div/div/span/span[2]/span")
|
||||
|
||||
def click_select_datacenter(self):
|
||||
|
@ -49,15 +53,19 @@ class ResSyncPage(basepage.Page):
|
|||
def click_commit_buttun(self):
|
||||
self.dr.click("xpath->//button[contains(.,'确定')]")
|
||||
# self.dr.click("css->.modal-footer:nth-child(3) > .btn-warning")
|
||||
|
||||
def commit_buttun_element(self):
|
||||
self.dr.get_element("xpath->//button[contains(.,'确定')]")
|
||||
|
||||
def is_exists_commit_buttun(self):
|
||||
self.dr.element_exist("xpath->//button[contains(.,'确定')]")
|
||||
self.log.debug("判断确定是否存在")
|
||||
return self.dr.element_exist("xpath->//button[contains(.,'确定')]")
|
||||
|
||||
def switch_commit_page(self):
|
||||
self.dr.switch_to_frame("id->syncModal")
|
||||
|
||||
def click_refresh_button(self):
|
||||
self.log.debug("点击刷新按钮")
|
||||
self.dr.click("xpath->//button[contains(.,' 刷新')]")
|
||||
|
||||
def get_text_status(self, value):
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# @File : sysMorgMgrPage.py
|
||||
# @Software: PyCharm
|
||||
|
||||
from public.common import basepage
|
||||
from public.pages import basepage
|
||||
from config import globalparam
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# @File : sysUorgMgrPage.py
|
||||
# @Software: PyCharm
|
||||
|
||||
from public.common import basepage
|
||||
from public.pages import basepage
|
||||
from config import globalparam
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# @File : sys_regionMgrPage.py
|
||||
# @Software: PyCharm
|
||||
|
||||
from public.common import basepage
|
||||
from public.pages import basepage
|
||||
from config import globalparam
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# @File : vdcPage.py
|
||||
# @Software: PyCharm
|
||||
|
||||
from public.common import basepage
|
||||
from public.pages import basepage
|
||||
from config import globalparam
|
||||
|
||||
|
||||
|
@ -18,70 +18,92 @@ class VdcPage(basepage.Page):
|
|||
"/csdp/manage/#/manage-view/adminManage/resVDCMgr")
|
||||
|
||||
def click_new_vdc_buttun(self):
|
||||
self.log.debug("点击新建vdc按钮")
|
||||
self.dr.click("xpath->//div[3]/button")
|
||||
|
||||
def input_vdc_name(self, value):
|
||||
self.log.debug("输入vdc名称")
|
||||
self.dr.clear_type("id->vdcName", value)
|
||||
|
||||
def click_save_buttun(self):
|
||||
self.log.debug("点击保存按钮")
|
||||
self.dr.click("css->.modal-footer:nth-child(3) > .btn-warning")
|
||||
|
||||
def search_vdc(self, value):
|
||||
self.log.debug("搜索vdc")
|
||||
self.dr.type_and_enter("xpath->(//input[@type='text'])[12]", value)
|
||||
|
||||
def click_az_buttun(self):
|
||||
self.log.debug("点击可用区按钮")
|
||||
self.dr.click("css->.btn-link:nth-child(1)")
|
||||
|
||||
def click_new_az_buttun(self):
|
||||
self.log.debug("点击新建可用区")
|
||||
self.dr.click("css->.mr-5")
|
||||
|
||||
def input_az_name(self, value):
|
||||
self.log.debug("输入可用区名称")
|
||||
self.dr.clear_type("id->vPoolName", value)
|
||||
|
||||
def click_resource_type(self):
|
||||
self.log.debug("点击资源类型")
|
||||
self.dr.click(
|
||||
"xpath->//*[@id='AddandEdit_form']/div/div[2]/div/div/div[1]/span/span[2]/span")
|
||||
|
||||
def inpurt_resource_type(self, value):
|
||||
self.log.debug("输入资源类型")
|
||||
self.dr.type_and_enter("css->.open > .form-control", value)
|
||||
|
||||
def click_type(self):
|
||||
self.log.debug("点击类型")
|
||||
self.dr.click(
|
||||
"xpath->//*[@id='AddandEdit_form']/div/div[5]/div/div/div[1]/span/span[2]/span")
|
||||
|
||||
def input_type(self, value):
|
||||
self.log.debug("输入类型")
|
||||
self.dr.type_and_enter("css->.open > .form-control", value)
|
||||
|
||||
def click_data_center(self):
|
||||
self.log.debug("点击数据中心")
|
||||
self.dr.click(
|
||||
"xpath->//*[@id='AddandEdit_form']/div/div[6]/div/div/div[1]/span/span[2]/span")
|
||||
|
||||
def input_date_center(self, value):
|
||||
self.log.debug("输入数据中心")
|
||||
self.dr.type_and_enter("css->.ng-pristine > .form-control", value)
|
||||
|
||||
def input_vPoolDesc(self, value):
|
||||
self.log.debug("输入可用区描述信息")
|
||||
self.dr.clear_type("id->vPoolDesc", value)
|
||||
|
||||
def click_save_az_buttun(self):
|
||||
self.log.debug("点击保存按钮")
|
||||
self.dr.click("xpath->//*[@id='AddandEdit']/div[3]/button[1]")
|
||||
|
||||
def search_vpool(self, value):
|
||||
self.log.debug("搜索可用区")
|
||||
self.dr.type_and_enter("xpath->(//input[@type='text'])[12]", value)
|
||||
|
||||
def click_vpool_more_button(self):
|
||||
self.log.debug("点击更多按钮")
|
||||
self.dr.click("xpath->//td[10]/div/a")
|
||||
|
||||
def click_delete_vpool_buttun(self):
|
||||
self.log.debug("点击删除vpool按钮")
|
||||
self.dr.click("xpath->(//button[@type='button'])[13]")
|
||||
|
||||
def click_vpool_delete_btn_success(self):
|
||||
self.log.debug("点击确定按钮")
|
||||
self.dr.click("xpath->//a[contains(.,'确定')]")
|
||||
|
||||
def click_vdc_delete_button(self):
|
||||
self.log.debug("点击删除按钮")
|
||||
self.dr.click("xpath->(//button[@type='button'])[14]")
|
||||
|
||||
def click_vdc_more_button(self):
|
||||
self.log.debug("点击更多按钮")
|
||||
self.dr.click("xpath->//td[5]/div/a")
|
||||
|
||||
def click_vdc_delete_btn_success(self):
|
||||
self.log.debug("点击确定按钮")
|
||||
self.dr.click("xpath->//a[contains(.,'确定')]")
|
||||
|
|
39
run.py
39
run.py
|
@ -8,23 +8,13 @@
|
|||
# @File : run.py
|
||||
# @Software: PyCharm
|
||||
|
||||
|
||||
"""
|
||||
运行用例集:
|
||||
python3 run.py
|
||||
|
||||
# '--allure_severities=critical, blocker'
|
||||
# '--allure_stories=测试模块_demo1, 测试模块_demo2'
|
||||
# '--allure_features=测试features'
|
||||
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from public.common import log
|
||||
from public.common import shell
|
||||
from public.common import initialize_Env
|
||||
from public.common import initializeEnv
|
||||
from config import globalparam
|
||||
from pyvirtualdisplay import Display
|
||||
|
||||
|
||||
failureException = AssertionError
|
||||
|
@ -32,33 +22,36 @@ failureException = AssertionError
|
|||
if __name__ == '__main__':
|
||||
|
||||
log = log.Log()
|
||||
|
||||
shell = shell.Shell()
|
||||
xml_report_path = globalparam.xml_report_path
|
||||
html_report_path = globalparam.html_report_path
|
||||
|
||||
# 初始化allure环境配置文件environment.xml
|
||||
initialize_Env.Init_Env().init()
|
||||
|
||||
initializeEnv.Init_Env().init()
|
||||
# 定义测试集
|
||||
args = ['-s', '-q', '--alluredir', xml_report_path]
|
||||
# pytest.main(args)
|
||||
cmd = 'allure generate %s -o %s ' % (
|
||||
pytest.main(args)
|
||||
cmd = 'allure generate %s -o %s --clean' % (
|
||||
xml_report_path, html_report_path)
|
||||
log.info("执行allure,生成测试报告")
|
||||
log.debug(cmd)
|
||||
try:
|
||||
log.info("执行allure")
|
||||
shell.invoke(cmd)
|
||||
except Exception:
|
||||
log.error('执行用例失败,请检查环境配置')
|
||||
raise
|
||||
#解决历史趋势中无数据问题
|
||||
report_history_path = html_report_path+"\\history"
|
||||
result_history_path = xml_report_path+"\\history"
|
||||
copy_cmd = 'xcopy %s %s /e /Y /I'%(report_history_path,result_history_path)
|
||||
# 解决历史趋势中无数据问题
|
||||
report_history_path = html_report_path + "\\history"
|
||||
result_history_path = xml_report_path + "\\history"
|
||||
copy_cmd = 'xcopy %s %s /e /Y /I' % (report_history_path,
|
||||
result_history_path)
|
||||
try:
|
||||
log.info("复制历史数据")
|
||||
shell.invoke(copy_cmd)
|
||||
except Exception:
|
||||
log.error('复制文件失败,请查看')
|
||||
log.error('复制文件失败,请查看失败原因')
|
||||
raise
|
||||
print("报告已生成,请查看")
|
||||
log.info("报告已生成,请查看")
|
||||
|
||||
|
||||
|
|
|
@ -5,57 +5,85 @@
|
|||
# @Site :
|
||||
# @File : conftest.py
|
||||
# @Software: PyCharm
|
||||
"""
|
||||
conftest.py 全局变量,主要实现以下功能:
|
||||
1、添加命令行参数broswer, 用于切换不用浏览器
|
||||
2、全局参数driver调用
|
||||
"""
|
||||
|
||||
|
||||
import time
|
||||
import pytest
|
||||
import allure
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.appModel import loginAction
|
||||
from public.common import datainfo
|
||||
from public.pages.loginPage import LoginPage
|
||||
from public.pages.authProjectPage import AuthProjectPage
|
||||
from public.pages.authTenantPage import AuthTenantPage
|
||||
from public.pages.authUserPage import AuthUsertPage
|
||||
from public.pages.dataCenterPage import DataCenterPage
|
||||
from public.pages.resSyncPage import ResSyncPage
|
||||
from public.pages.sysMorgMgrPage import SysMorgMgrPage
|
||||
from public.pages.sysUorgMgrPage import SysUorgMgrPage
|
||||
from public.pages.vdcPage import VdcPage
|
||||
from public.pages.sys_regionMgrPage import SysRegionMgrPage
|
||||
from public.appmodel import loginaction
|
||||
from config import globalparam
|
||||
from public.common import log
|
||||
|
||||
domain_administrators= datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
domain_data = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
user_data = datainfo.get_xls_to_dict("user.xlsx", "authuser")['创建运营部门用户']
|
||||
log = log.Log()
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def ini_pages(driver):
|
||||
login_page =LoginPage(driver)
|
||||
auth_project_page = AuthProjectPage(driver)
|
||||
yield driver, login_page
|
||||
|
||||
|
||||
|
||||
@allure.step("打开浏览器")
|
||||
@pytest.fixture(scope="session")
|
||||
def open_browser():
|
||||
dr = pyselenium.PySelenium(globalparam.browser)
|
||||
dr.max_window()
|
||||
return dr
|
||||
def driver(request):
|
||||
global driver
|
||||
'''只打开浏览器和关闭浏览器'''
|
||||
log.info("打开浏览器")
|
||||
driver = pyselenium.PySelenium(globalparam.browser)
|
||||
driver.max_window() # 最大化
|
||||
|
||||
def end():
|
||||
log.info("用例全部执行完毕,关闭浏览器")
|
||||
time.sleep(1)
|
||||
driver.quit()
|
||||
|
||||
request.addfinalizer(end)
|
||||
return driver
|
||||
|
||||
|
||||
@allure.step("关闭浏览器")
|
||||
@pytest.fixture(scope="session")
|
||||
def quit_browser(dr):
|
||||
dr.quit()
|
||||
@pytest.fixture()
|
||||
def login_admin(request, driver):
|
||||
"""系统管理员登录"""
|
||||
log.info("系统管理员登录")
|
||||
login = loginaction.Login(driver)
|
||||
login.login('系统管理员', '123456')
|
||||
|
||||
def end():
|
||||
log.info("测试用例执行完成,登出系统")
|
||||
driver.origin_driver.delete_all_cookies()
|
||||
|
||||
request.addfinalizer(end)
|
||||
return driver
|
||||
|
||||
|
||||
@allure.step("登录系统")
|
||||
@pytest.fixture(scope="module")
|
||||
def login_as_admin(dr, username, password):
|
||||
loginAction.Login(dr).login("系统管理员","123456")
|
||||
@pytest.fixture()
|
||||
def login_domain(request, driver):
|
||||
"""域管理员登录"""
|
||||
log.info("域管理员:%s登录" % domain_data["username"])
|
||||
login = loginaction.Login(driver)
|
||||
login.login(domain_data["username"], domain_data["password"])
|
||||
|
||||
def end():
|
||||
log.info("测试用例执行完成,登出系统")
|
||||
driver.origin_driver.delete_all_cookies()
|
||||
|
||||
request.addfinalizer(end)
|
||||
return driver
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def login_user(request, driver):
|
||||
"""用户登录"""
|
||||
|
||||
log.info("用户登录:%s登录" % domain_data["username"])
|
||||
login = loginaction.Login(driver)
|
||||
login.login(user_data["username"], user_data["password"])
|
||||
|
||||
def end():
|
||||
log.info("测试用例执行完成,登出系统")
|
||||
driver.origin_driver.delete_all_cookies()
|
||||
|
||||
request.addfinalizer(end)
|
||||
return driver
|
||||
|
||||
|
||||
@allure.step("登出系统")
|
||||
@pytest.fixture(scope="module")
|
||||
def logout():
|
||||
pass
|
||||
|
|
|
@ -6,32 +6,22 @@
|
|||
# @File : test_00_login.py
|
||||
# @Software: PyCharm
|
||||
import pytest
|
||||
import allure
|
||||
|
||||
from time import sleep
|
||||
from public.common import mytest
|
||||
from public.pages import loginPage
|
||||
from public.appModel import loginAction
|
||||
|
||||
|
||||
from public.common.publicfunction import *
|
||||
|
||||
#前置条件,打开浏览器,在这个测试套下全局有效,实现在conftest.py,每个测试测试套下只打开一次浏览器
|
||||
#此部分相当于setupclasss,每个测试类的setup
|
||||
@allure.feature("登录模块")
|
||||
class TestLoin(mytest.MyTest):
|
||||
class TestLoin():
|
||||
"""登录测试"""
|
||||
|
||||
@allure.story("系统管理员登录系统")
|
||||
@allure.severity(allure.severity_level.BLOCKER)
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_login(self):
|
||||
loginpj = loginPage.LoginPage(self.dr)
|
||||
login = loginAction.Login(self.dr)
|
||||
login.login("系统管理员","123456")
|
||||
sleep(0.5)
|
||||
loginpj.click_loginbutton()
|
||||
self.dr.wait(5)
|
||||
self._add_image("系统管理员登录系统后")
|
||||
flag = self.dr.element_exist("xpath->//div[3]/div[3]/span")
|
||||
def test_login(self,login_admin):
|
||||
dr = login_admin
|
||||
dr.wait(5)
|
||||
flag = dr.element_exist("xpath->//div[3]/div[3]/span")
|
||||
assert flag
|
||||
|
||||
add_image(dr,"系统管理员登录系统")
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["-s", "test_00_login.py"])
|
||||
|
|
|
@ -7,30 +7,21 @@
|
|||
# @Software: PyCharm
|
||||
|
||||
import pytest
|
||||
import allure
|
||||
|
||||
from time import sleep
|
||||
from public.common import mytest
|
||||
from public.common import datainfo
|
||||
from public.appModel import userAction
|
||||
from public.appmodel import useraction
|
||||
from public.pages import sysUorgMgrPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.common.publicfunction import *
|
||||
|
||||
@allure.feature("用户管理")
|
||||
class TestCreateUser(mytest.MyTest):
|
||||
class TestCreateUser():
|
||||
"""创建用户"""
|
||||
|
||||
@allure.story("创建用户")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_create_user(self):
|
||||
|
||||
login = Login(self.dr)
|
||||
login.login("系统管理员", '123456')
|
||||
|
||||
def test_create_user(self,login_admin):
|
||||
dr = login_admin
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
upage = sysUorgMgrPage.SysUorgMgrPage(self.dr)
|
||||
ua = userAction.UserAction(self.dr)
|
||||
|
||||
upage = sysUorgMgrPage.SysUorgMgrPage(dr)
|
||||
ua = useraction.UserAction(dr)
|
||||
ua.create_user(
|
||||
datas["mgrname"],
|
||||
datas["username"],
|
||||
|
@ -41,8 +32,8 @@ class TestCreateUser(mytest.MyTest):
|
|||
# upage.input_select_user(datas["username"])
|
||||
# 查看用户,进行校验
|
||||
upage.input_select_user(datas["username"])
|
||||
self._add_image("创建用户")
|
||||
assert self.dr.element_exist(
|
||||
add_image(dr, "创建用户")
|
||||
assert dr.element_exist(
|
||||
"xpath->//span[contains(.,'%s')]" %
|
||||
datas["username"])
|
||||
|
||||
|
|
|
@ -9,37 +9,32 @@ import pytest
|
|||
import allure
|
||||
|
||||
from time import sleep
|
||||
from public.common import mytest
|
||||
from public.common import datainfo
|
||||
from public.common import publicfunction
|
||||
from public.appModel import userAction
|
||||
from public.common.publicfunction import *
|
||||
from public.appmodel import useraction
|
||||
from public.pages import sysUorgMgrPage
|
||||
from public.appModel.loginAction import Login
|
||||
|
||||
|
||||
@allure.feature("域管理")
|
||||
class TestAllDomainAdmin(mytest.MyTest):
|
||||
class TestAllDomainAdmin():
|
||||
"""域添加域管理员"""
|
||||
|
||||
@allure.story("域添加域管理员")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_allocation_domain_admin(self):
|
||||
|
||||
login = Login(self.dr)
|
||||
login.login("系统管理员", '123456')
|
||||
def test_allocation_domain_admin(self,login_admin):
|
||||
dr = login_admin
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
upage = sysUorgMgrPage.SysUorgMgrPage(self.dr)
|
||||
ua = userAction.UserAction(self.dr)
|
||||
upage = sysUorgMgrPage.SysUorgMgrPage(dr)
|
||||
ua = useraction.UserAction(dr)
|
||||
ua.allocation_domain_administrator(datas["mgrname"], datas["username"])
|
||||
# 校验已分配域管理角色
|
||||
upage.open_uorgmgrpage()
|
||||
upage.input_select_user(datas["username"])
|
||||
sleep(2)
|
||||
character = self.dr.get_text(
|
||||
character = dr.get_text(
|
||||
"css->.ng-scope:nth-child(4) > .wordBreak")
|
||||
self._add_image("域添加域管理员")
|
||||
add_image(dr,"域添加域管理员")
|
||||
assert character == "1"
|
||||
# self.assertTrue(self.dr.element_exist(""]), "用户未创建成功,请查看日志")
|
||||
# self.assertTrue(dr.element_exist(""]), "用户未创建成功,请查看日志")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -10,29 +10,22 @@
|
|||
import time
|
||||
import pytest
|
||||
import allure
|
||||
from public.common import publicfunction
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import tenantAction
|
||||
from public.appmodel import tenantaction
|
||||
from public.pages import authTenantPage
|
||||
from public.appModel.loginAction import Login
|
||||
|
||||
|
||||
@allure.feature("运营部门管理")
|
||||
class TestTeant(mytest.MyTest):
|
||||
class TestTeant():
|
||||
"""创建运营部门"""
|
||||
|
||||
@allure.story("创建运营部门")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_create(self):
|
||||
|
||||
login = Login(self.dr)
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
def test_create(self,login_domain):
|
||||
dr = login_domain
|
||||
t_data = datainfo.get_xls_to_dict("tenantdata.xlsx", "Sheet1")["创建运营部门"]
|
||||
tpg = authTenantPage.AuthTenantPage(self.dr)
|
||||
ta = tenantAction.TenantAction(self.dr)
|
||||
# login.login("wuzs0001","1qaz!QAZ")
|
||||
login.login(datas["username"], datas["password"])
|
||||
tpg = authTenantPage.AuthTenantPage(dr)
|
||||
ta = tenantaction.TenantAction(dr)
|
||||
ta.create_tenant(
|
||||
t_data["tenantname"],
|
||||
t_data["linkmanname"],
|
||||
|
@ -42,8 +35,8 @@ class TestTeant(mytest.MyTest):
|
|||
time.sleep(2)
|
||||
tpg.input_secrch_tenant(t_data["tenantname"])
|
||||
time.sleep(1)
|
||||
a = self.dr.get_text("id->card")
|
||||
self._add_image("创建运营部门")
|
||||
a = dr.get_text("id->card")
|
||||
add_image(dr,"创建运营部门")
|
||||
assert t_data["tenantname"] in a, "%s不在预期结果%s中" % (
|
||||
t_data["tenantname"], a)
|
||||
assert t_data["linkmanname"]in a, "%s不在预期结果%s中" % (
|
||||
|
|
|
@ -8,28 +8,24 @@
|
|||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import userAction
|
||||
from public.appmodel import useraction
|
||||
from public.pages import authUserPage
|
||||
from public.appModel.loginAction import Login
|
||||
|
||||
|
||||
|
||||
@allure.feature("用户管理")
|
||||
class TestCreateUser(mytest.MyTest):
|
||||
class TestCreateUser():
|
||||
"""创建运营部门下的用户测试"""
|
||||
|
||||
@allure.story("创建运营部门下的用户")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_create_authuser(self):
|
||||
|
||||
login = Login(self.dr)
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
def test_create_authuser(self,login_domain):
|
||||
dr = login_domain
|
||||
data1s = datainfo.get_xls_to_dict("user.xlsx", "authuser")["创建运营部门用户"]
|
||||
aupg = authUserPage.AuthUsertPage(self.dr)
|
||||
ta = userAction.UserAction(self.dr)
|
||||
# t_data = datainfo.get_xls_to_dict("tenantdata.xlsx","Sheet1")[0]
|
||||
login.login(datas["username"], datas["password"])
|
||||
aupg = authUserPage.AuthUsertPage(dr)
|
||||
ta = useraction.UserAction(dr)
|
||||
ta.create_tenant_user(
|
||||
data1s["tenantname"],
|
||||
data1s["username"],
|
||||
|
@ -38,11 +34,10 @@ class TestCreateUser(mytest.MyTest):
|
|||
data1s["repassword"],
|
||||
data1s["email"])
|
||||
aupg.open_authuser()
|
||||
|
||||
aupg.input_select_user(data1s["username"])
|
||||
self.dr.wait(5)
|
||||
self._add_image("创建运营部门下的用户")
|
||||
text = self.dr.get_text(
|
||||
dr.wait(5)
|
||||
add_image(dr,"创建运营部门下的用户")
|
||||
text = dr.get_text(
|
||||
"xpath->//div[@class='box-body']/table-component/div/table/tbody")
|
||||
|
||||
assert data1s["username"] in text, "%s不在预期结果%s中" % (
|
||||
|
|
|
@ -6,41 +6,32 @@
|
|||
# @File : test_05_create_project.py
|
||||
# @Software: PyCharm
|
||||
import pytest
|
||||
import allure
|
||||
|
||||
from time import sleep
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import projectAction
|
||||
from public.appmodel import projectaction
|
||||
from public.pages import authProjectPage
|
||||
from public.appModel.loginAction import Login
|
||||
|
||||
|
||||
@allure.feature("项目管理")
|
||||
class TestProject(mytest.MyTest):
|
||||
class TestProject():
|
||||
"""测试创建项目"""
|
||||
|
||||
@allure.story("创建项目")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_create_project(self):
|
||||
|
||||
login = Login(self.dr)
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
def test_create_project(self,login_admin):
|
||||
dr = login_admin
|
||||
p_data = datainfo.get_xls_to_dict("projectdata.xlsx", "Sheet1")["创建项目"]
|
||||
ppg = authProjectPage.AuthProjectPage(self.dr)
|
||||
pac = projectAction.PojectAction(self.dr)
|
||||
# login.login("wuzs0001","1qaz!QAZ")
|
||||
login.login(datas["username"], datas["password"])
|
||||
# tenantname,projectname,projectdesc
|
||||
ppg = authProjectPage.AuthProjectPage(dr)
|
||||
pac = projectaction.PojectAction(dr)
|
||||
pac.create_project(
|
||||
p_data["tenantname"],
|
||||
p_data["projectname"],
|
||||
p_data["projectdesc"])
|
||||
ppg.open_authproject()
|
||||
ppg.input_and_search_project(p_data["projectname"])
|
||||
self.dr.wait(5)
|
||||
self._add_image("创建项目")
|
||||
text = self.dr.get_text(
|
||||
dr.wait(5)
|
||||
add_image(dr,"创建项目")
|
||||
text = dr.get_text(
|
||||
"xpath->//div[@class='box-body']/table-component/div/table/tbody")
|
||||
# 搜索项目
|
||||
assert p_data["projectname"] in text, "%s不在预期结果%s中" % (
|
||||
|
|
|
@ -10,30 +10,23 @@ import pytest
|
|||
import time
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import resNodeAction
|
||||
from public.appmodel import resnodeaction
|
||||
from public.pages import sys_regionMgrPage
|
||||
from public.appModel.loginAction import Login
|
||||
|
||||
|
||||
@allure.feature("资源节点管理")
|
||||
class TestCreateRegion(mytest.MyTest):
|
||||
class TestCreateRegion():
|
||||
"""测试添加资源节点"""
|
||||
|
||||
@allure.story("创建资源节点")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_create_region(self):
|
||||
|
||||
login = Login(self.dr)
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
def test_create_region(self,login_domain):
|
||||
dr = login_domain
|
||||
p_data = datainfo.get_xls_to_dict("res_node_data.xlsx", "region")["创建资源节点"]
|
||||
|
||||
arn = resNodeAction.Add_Res_Node(self.dr)
|
||||
srmpg = sys_regionMgrPage.SysRegionMgrPage(self.dr)
|
||||
# login.login("wuzs0001","1qaz!QAZ")
|
||||
login.login(datas["username"], datas["password"])
|
||||
|
||||
arn = resnodeaction.Add_Res_Node(dr)
|
||||
srmpg = sys_regionMgrPage.SysRegionMgrPage(dr)
|
||||
arn.add_res_node(
|
||||
p_data["regionname"],
|
||||
p_data["nodename"],
|
||||
|
@ -42,12 +35,11 @@ class TestCreateRegion(mytest.MyTest):
|
|||
virtual_type=p_data["virtual_type"],
|
||||
regDesc=p_data["regDesc"])
|
||||
|
||||
|
||||
srmpg.open_sys_regionMgr_page()
|
||||
time.sleep(1)
|
||||
self.dr.wait(5)
|
||||
self._add_image("创建资源节点")
|
||||
flag = self.dr.element_exist(
|
||||
dr.wait(5)
|
||||
add_image(dr,"创建资源节点")
|
||||
flag = dr.element_exist(
|
||||
"xpath->//a[contains(text(),'%s')]" %
|
||||
p_data["nodename"])
|
||||
assert flag, "未查询到资源节点%s" % p_data["nodename"]
|
||||
|
|
|
@ -6,40 +6,24 @@
|
|||
# @File : test_07_create_service.py
|
||||
# @Software: PyCharm
|
||||
|
||||
import time
|
||||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import resNodeAction
|
||||
from public.appmodel import resnodeaction
|
||||
from public.pages import sys_regionMgrPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.common.log import Log
|
||||
|
||||
|
||||
@allure.feature("资源节点管理")
|
||||
class TestCreateService(mytest.MyTest):
|
||||
class TestCreateService():
|
||||
"""测试添加service"""
|
||||
|
||||
def setup_class(self):
|
||||
"""重写方法"""
|
||||
self.logger = Log()
|
||||
self.logger.info(
|
||||
'############################### START ###############################')
|
||||
self.dr = pyselenium.PySelenium(globalparam.browser)
|
||||
self.dr.max_window()
|
||||
self.login = Login(self.dr)
|
||||
self.datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
self.login.login(self.datas["username"], self.datas["password"])
|
||||
self.arn = resNodeAction.Add_Res_Node(self.dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(self.dr)
|
||||
|
||||
@allure.story("创建VMware服务")
|
||||
@pytest.mark.flaky(reruns=5)
|
||||
def test_create_service_vmware(self):
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_create_service_vmware(self,login_domain):
|
||||
dr = login_domain
|
||||
self.arn = resnodeaction.Add_Res_Node(dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict(
|
||||
"res_node_data.xlsx",
|
||||
"vmwareapi")["创建service-vmware"]
|
||||
|
@ -51,22 +35,21 @@ class TestCreateService(mytest.MyTest):
|
|||
p_data["username"],
|
||||
p_data["passwrd"])
|
||||
# 校验
|
||||
self.dr.wait(5)
|
||||
self._add_image("创建VMware服务")
|
||||
dr.wait(5)
|
||||
add_image(dr,"创建VMware服务")
|
||||
self.srmpg.open_sys_regionMgr_page()
|
||||
# time.sleep(1)
|
||||
# self.srmpg.click_region_tree(p_data["regionname"])
|
||||
# self.srmpg.click_tree_res_node(p_data["nodename"])
|
||||
# self.srmpg.click_tree_res_node_i(p_data["nodename"])
|
||||
|
||||
flag = self.dr.element_exist(
|
||||
flag = dr.element_exist(
|
||||
"xpath->(//a[contains(text(),'%s')])" %
|
||||
p_data["servicename"])
|
||||
assert flag
|
||||
|
||||
@allure.story("创建opentack服务")
|
||||
@pytest.mark.flaky(reruns=5)
|
||||
def test_create_service_openstack(self):
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_create_service_openstack(self,login_domain):
|
||||
dr = login_domain
|
||||
self.arn = resnodeaction.Add_Res_Node(dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict(
|
||||
"res_node_data.xlsx", "openstackapi")["创建service-keystone"]
|
||||
self.arn.add_resource_service_node_vmware(
|
||||
|
@ -78,9 +61,9 @@ class TestCreateService(mytest.MyTest):
|
|||
p_data["passwrd"])
|
||||
# 校验
|
||||
self.srmpg.open_sys_regionMgr_page()
|
||||
self.dr.wait(5)
|
||||
self._add_image("创建opentack服务")
|
||||
flag = self.dr.element_exist(
|
||||
dr.wait(5)
|
||||
add_image(dr,"创建opentack服务")
|
||||
flag = dr.element_exist(
|
||||
"xpath->(//a[contains(text(),'%s')])" %
|
||||
p_data["servicename"])
|
||||
assert flag
|
||||
|
|
|
@ -5,46 +5,28 @@
|
|||
# @Site :
|
||||
# @File : test_08_create_endpoint.py
|
||||
# @Software: PyCharm
|
||||
import time
|
||||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import resNodeAction
|
||||
from public.appmodel import resnodeaction
|
||||
from public.pages import sys_regionMgrPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.common.log import Log
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("driver")
|
||||
@allure.feature("资源节点管理")
|
||||
class TestCreateEndpoint(mytest.MyTest):
|
||||
class TestCreateEndpoint():
|
||||
"""测试添加Endpoint"""
|
||||
|
||||
def setup_class(self):
|
||||
|
||||
self.logger = Log()
|
||||
self.logger.info(
|
||||
'############################### START ###############################')
|
||||
self.dr = pyselenium.PySelenium(globalparam.browser)
|
||||
self.dr.max_window()
|
||||
self.login = Login(self.dr)
|
||||
self.datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
self.login.login(self.datas["username"], self.datas["password"])
|
||||
self.arn = resNodeAction.Add_Res_Node(self.dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(self.dr)
|
||||
|
||||
@allure.story("VMware创建endpoint")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_vmware_endpoint(self):
|
||||
def test_vmware_endpoint(self,login_domain):
|
||||
"""
|
||||
测试添加vmware,endpoint
|
||||
依赖已添加vmware服务
|
||||
:return:
|
||||
"""
|
||||
|
||||
dr = login_domain
|
||||
self.arn = resnodeaction.Add_Res_Node(dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict("res_node_data.xlsx", "endpoint")[
|
||||
"创建vmware-endpoint"]
|
||||
self.arn.add_endpoint(
|
||||
|
@ -54,20 +36,24 @@ class TestCreateEndpoint(mytest.MyTest):
|
|||
p_data["url"])
|
||||
|
||||
time.sleep(0.5)
|
||||
self.dr.wait(5)
|
||||
self._add_image("VMware创建endpoint")
|
||||
text = self.dr.get_text(
|
||||
dr.wait(5)
|
||||
add_image(dr,"VMware创建endpoint")
|
||||
text = dr.get_text(
|
||||
"xpath->//table[@id='accessPoint']/tbody/tr[2]")
|
||||
assert p_data["url"] in text
|
||||
|
||||
|
||||
@allure.story("openstack创建endpoint")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_openstack_endpoint(self):
|
||||
def test_openstack_endpoint(self,login_domain):
|
||||
"""
|
||||
测试添加openstack,endpoint
|
||||
依赖已添加openstack服务
|
||||
:return:
|
||||
"""
|
||||
dr = login_domain
|
||||
self.arn = resnodeaction.Add_Res_Node(dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict(
|
||||
"res_node_data.xlsx", "endpoint")["创建os-l-endpoint"]
|
||||
self.arn.add_endpoint(
|
||||
|
@ -77,9 +63,9 @@ class TestCreateEndpoint(mytest.MyTest):
|
|||
p_data["url"])
|
||||
|
||||
time.sleep(0.5)
|
||||
self.dr.wait(5)
|
||||
self._add_image("openstack创建endpoint")
|
||||
text = self.dr.get_text(
|
||||
dr.wait(5)
|
||||
add_image(dr,"openstack创建endpoint")
|
||||
text = dr.get_text(
|
||||
"xpath->//table[@id='accessPoint']/tbody/tr[2]")
|
||||
assert p_data["url"] in text
|
||||
|
||||
|
|
|
@ -10,63 +10,57 @@ import time
|
|||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import resSyncAction
|
||||
from public.appmodel import ressyncaction
|
||||
from public.pages import resSyncPage
|
||||
|
||||
|
||||
@allure.feature("资源同步")
|
||||
class TestPhySunc(mytest.MyTest):
|
||||
class TestPhySunc():
|
||||
"""物理资源同步"""
|
||||
|
||||
@allure.story("同步物理资源")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_sync_phy_res(self):
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
def test_sync_phy_res(self,login_domain):
|
||||
dr = login_domain
|
||||
p_data = datainfo.get_xls_to_dict("phy_sync_data.xlsx", "Sheet1")["物理资源同步"]
|
||||
|
||||
self.login.login(datas["username"], datas["password"])
|
||||
sync_a = resSyncAction.ResSync(self.dr)
|
||||
sync_pg = resSyncPage.ResSyncPage(self.dr)
|
||||
sync_a = ressyncaction.ResSync(dr)
|
||||
sync_pg = resSyncPage.ResSyncPage(dr)
|
||||
sync_a.phy_res_sync(
|
||||
p_data["regionname"],
|
||||
p_data["nodename"],
|
||||
"DC1",
|
||||
"DC2")
|
||||
# sync_a.phy_res_sync("北京","")
|
||||
time.sleep(20)
|
||||
# 延时,等待同步完成
|
||||
# self.dr.F5()
|
||||
# sync_pg.open_osphysicalsyncpage()
|
||||
sync_pg.click_refresh_button()
|
||||
status1 = self.dr.get_text(
|
||||
status1 = dr.get_text(
|
||||
"xpath->//td[contains(.,'DC1')]/../td[3]").strip()
|
||||
count1 = 0
|
||||
while status1 == "执行中":
|
||||
time.sleep(10)
|
||||
sync_pg.click_refresh_button()
|
||||
status1 = self.dr.get_text(
|
||||
status1 = dr.get_text(
|
||||
"xpath->//td[contains(.,'DC1')]/../td[3]").strip()
|
||||
count1 += 1
|
||||
if count1 == 10:
|
||||
break
|
||||
self.dr.wait(5)
|
||||
self._add_image("同步物理资源-DC1")
|
||||
dr.wait(5)
|
||||
add_image(dr,"同步物理资源-DC1")
|
||||
assert status1 == "执行成功"
|
||||
status2 = self.dr.get_text(
|
||||
status2 = dr.get_text(
|
||||
"xpath->//td[contains(.,'DC2')]/../td[3]").strip()
|
||||
count2 = 0
|
||||
while status2 == "执行中":
|
||||
time.sleep(10)
|
||||
sync_pg.click_refresh_button()
|
||||
status2 = self.dr.get_text(
|
||||
status2 = dr.get_text(
|
||||
"xpath->//td[contains(.,'DC1')]/../td[3]").strip()
|
||||
count2 += 1
|
||||
if count2 == 10:
|
||||
break
|
||||
self.dr.wait(5)
|
||||
self._add_image("同步物理资源-DC2")
|
||||
dr.wait(5)
|
||||
add_image(dr,"同步物理资源-DC2")
|
||||
assert status2 == "执行成功"
|
||||
|
||||
|
||||
|
|
|
@ -9,33 +9,31 @@
|
|||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import vdcAction
|
||||
from public.appmodel import vdcaction
|
||||
from public.pages import vdcPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
|
||||
@allure.feature("VDC管理")
|
||||
class TestCreateVDC(mytest.MyTest):
|
||||
class TestCreateVDC():
|
||||
"""测试创建VDC"""
|
||||
|
||||
@allure.story("创建vdc")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_create_vdc(self):
|
||||
vdc_a = vdcAction.VdcACction(self.dr)
|
||||
vdc_pg = vdcPage.VdcPage(self.dr)
|
||||
login = Login(self.dr)
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
def test_create_vdc(self,login_domain):
|
||||
dr = login_domain
|
||||
vdc_a = vdcaction.VdcACction(dr)
|
||||
vdc_pg = vdcPage.VdcPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict("vdc_vpool.xlsx", "vdc")["创建vdc"]
|
||||
login.login(datas["username"], datas["password"])
|
||||
vdc_a.ceate_vdc(p_data["vdcname"])
|
||||
vdc_pg.open_vdc_page()
|
||||
vdc_pg.search_vdc(p_data["vdcname"])
|
||||
# 校验能查询到
|
||||
self.dr.wait(5)
|
||||
self._add_image("创建vdc")
|
||||
text = self.dr.get_text(
|
||||
dr.wait(5)
|
||||
add_image(dr,"创建vdc")
|
||||
text = dr.get_text(
|
||||
"xpath->//div[@class='box-body']/table-component/div/table/tbody")
|
||||
assert p_data["vdcname"] in text
|
||||
|
||||
|
|
|
@ -10,26 +10,24 @@ import time
|
|||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import vdcAction
|
||||
from public.appmodel import vdcaction
|
||||
from public.pages import vdcPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
|
||||
@allure.feature("VPOOL管理")
|
||||
class TestCreateVpool(mytest.MyTest):
|
||||
class TestCreateVpool():
|
||||
"""测试创建vpool"""
|
||||
|
||||
@allure.story("创建VPOOL")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_create_vpool(self):
|
||||
vdc_a = vdcAction.VdcACction(self.dr)
|
||||
vdc_pg = vdcPage.VdcPage(self.dr)
|
||||
login = Login(self.dr)
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
def test_create_vpool(self,login_domain):
|
||||
dr = login_domain
|
||||
vdc_a = vdcaction.VdcACction(dr)
|
||||
vdc_pg = vdcPage.VdcPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict("vdc_vpool.xlsx", "vpool")["创建vpool"]
|
||||
login.login(datas["username"], datas["password"])
|
||||
vdc_a.create_vpool(
|
||||
p_data["vdcname"],
|
||||
p_data["vpoolname"],
|
||||
|
@ -46,9 +44,9 @@ class TestCreateVpool(mytest.MyTest):
|
|||
time.sleep(1)
|
||||
vdc_pg.search_vpool(p_data["vpoolname"])
|
||||
# 校验能查询到
|
||||
self.dr.wait(5)
|
||||
self._add_image("创建VPOOL")
|
||||
text = self.dr.get_text("xpath->//td")
|
||||
dr.wait(5)
|
||||
add_image(dr,"创建VPOOL")
|
||||
text = dr.get_text("xpath->//td")
|
||||
assert p_data["vpoolname"] in text
|
||||
|
||||
|
||||
|
|
|
@ -10,23 +10,23 @@ import time
|
|||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.appModel import vdcAction
|
||||
from public.common.publicfunction import *
|
||||
from public.appmodel import vdcaction
|
||||
from public.pages import vdcPage
|
||||
from public.common import datainfo
|
||||
|
||||
|
||||
@allure.feature("VPOOL管理")
|
||||
class Test_Vpool_Delete(mytest.MyTest):
|
||||
class Test_Vpool_Delete():
|
||||
"""测试删除vpool"""
|
||||
|
||||
|
||||
@allure.story("删除VPOOL")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_vpool(self):
|
||||
vdc_a = vdcAction.VdcACction(self.dr)
|
||||
vdc_pg = vdcPage.VdcPage(self.dr)
|
||||
def test_delete_vpool(self,login_domain):
|
||||
dr = login_domain
|
||||
vdc_a = vdcaction.VdcACction(dr)
|
||||
vdc_pg = vdcPage.VdcPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict("vdc_vpool.xlsx", "vpool")["创建vpool"]
|
||||
self.login.login("系统管理员", "123456")
|
||||
vdc_a.delete_vpool(p_data["vdcname"], p_data["vpoolname"])
|
||||
vdc_pg.open_vdc_page()
|
||||
time.sleep(1)
|
||||
|
@ -35,11 +35,10 @@ class Test_Vpool_Delete(mytest.MyTest):
|
|||
time.sleep(1)
|
||||
vdc_pg.search_vpool(p_data["vpoolname"])
|
||||
# 校验能查询到
|
||||
self.dr.wait(5)
|
||||
self._add_image("删除VPOOL")
|
||||
flag = self.dr.element_exist("xpath->//td")
|
||||
dr.wait(5)
|
||||
add_image(dr,"删除VPOOL")
|
||||
flag = dr.element_exist("xpath->//td")
|
||||
assert flag is False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["-s", "test_12_delete_vpool.py"])
|
||||
|
|
|
@ -6,38 +6,33 @@
|
|||
# @File : test_13_delete_vdc.py
|
||||
# @Software: PyCharm
|
||||
|
||||
import time
|
||||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.appModel import vdcAction
|
||||
from public.common.publicfunction import *
|
||||
from public.appmodel import vdcaction
|
||||
from public.pages import vdcPage
|
||||
from public.common import datainfo
|
||||
|
||||
|
||||
@allure.feature("VDC管理")
|
||||
class Test_Vpool_Vdc(mytest.MyTest):
|
||||
class Test_Vpool_Vdc():
|
||||
"""测试删除VDC"""
|
||||
|
||||
@allure.story("删除VDC")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_vdc(self):
|
||||
vdc_a = vdcAction.VdcACction(self.dr)
|
||||
vdc_pg = vdcPage.VdcPage(self.dr)
|
||||
|
||||
def test_delete_vdc(self,login_domain):
|
||||
dr = login_domain
|
||||
vdc_a = vdcaction.VdcACction(dr)
|
||||
vdc_pg = vdcPage.VdcPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict("vdc_vpool.xlsx", "vdc")["创建vdc"]
|
||||
|
||||
self.login.login("系统管理员", "123456")
|
||||
vdc_a.delete_vdc(p_data["vdcname"])
|
||||
vdc_pg.open_vdc_page()
|
||||
time.sleep(1)
|
||||
vdc_pg.search_vdc(p_data["vdcname"])
|
||||
|
||||
# # 校验能查询到
|
||||
self.dr.wait(5)
|
||||
self._add_image("删除VDC")
|
||||
flag = self.dr.element_exist("xpath->//td")
|
||||
dr.wait(5)
|
||||
add_image(dr,"删除VDC")
|
||||
flag = dr.element_exist("xpath->//td")
|
||||
assert flag is False
|
||||
|
||||
|
||||
|
|
|
@ -8,41 +8,32 @@
|
|||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import userAction
|
||||
from public.appmodel import useraction
|
||||
from public.pages import authUserPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
|
||||
@allure.feature("用户管理")
|
||||
class TestDeleteUser(mytest.MyTest):
|
||||
class TestDeleteUser():
|
||||
"""删除运营部门下的用户测试"""
|
||||
|
||||
@allure.story("删除运营部门下的用户")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_tenant_user(self):
|
||||
|
||||
login = Login(self.dr)
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
def test_delete_tenant_user(self,login_domain):
|
||||
dr = login_domain
|
||||
data1s = datainfo.get_xls_to_dict("user.xlsx", "authuser")["创建运营部门用户"]
|
||||
aupg = authUserPage.AuthUsertPage(self.dr)
|
||||
ta = userAction.UserAction(self.dr)
|
||||
# t_data = datainfo.get_xls_to_dict("tenantdata.xlsx","Sheet1")[0]
|
||||
login.login(datas["username"], datas["password"])
|
||||
# ta.create_tenant_user(data1s["tenantname"],data1s["username"],data1s["firstname"],data1s["password"],data1s["repassword"],data1s["email"])
|
||||
aupg = authUserPage.AuthUsertPage(dr)
|
||||
ta = useraction.UserAction(dr)
|
||||
ta.delete_tenant_user(data1s["username"])
|
||||
aupg.open_authuser()
|
||||
|
||||
aupg.input_select_user(data1s["username"])
|
||||
self.dr.wait(5)
|
||||
self._add_image("删除运营部门下的用户")
|
||||
flag = self.dr.element_exist("xpath->//td")
|
||||
dr.wait(5)
|
||||
add_image(dr,"删除运营部门下的用户")
|
||||
flag = dr.element_exist("xpath->//td")
|
||||
assert flag is False
|
||||
|
||||
# text = self.dr.get_text("xpath->//div[@class='box-body']/table-component/div/table/tbody")
|
||||
# print(text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["-s", "test_14_delete_tenant_user.py"])
|
||||
|
|
|
@ -8,37 +8,31 @@
|
|||
import pytest
|
||||
import allure
|
||||
from time import sleep
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import projectAction
|
||||
from public.appmodel import projectaction
|
||||
from public.pages import authProjectPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
|
||||
@allure.feature("项目管理")
|
||||
class TestProjectDelete(mytest.MyTest):
|
||||
class TestProjectDelete():
|
||||
"""删除项目测试"""
|
||||
|
||||
@allure.story("删除项目")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_project(self):
|
||||
|
||||
login = Login(self.dr)
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
def test_delete_project(self,login_domain):
|
||||
dr = login_domain
|
||||
p_data = datainfo.get_xls_to_dict("projectdata.xlsx", "Sheet1")["创建项目"]
|
||||
|
||||
ppg = authProjectPage.AuthProjectPage(self.dr)
|
||||
pac = projectAction.PojectAction(self.dr)
|
||||
# login.login("wuzs0001","1qaz!QAZ")
|
||||
login.login(datas["username"], datas["password"])
|
||||
# tenantname,projectname,projectdesc
|
||||
ppg = authProjectPage.AuthProjectPage(dr)
|
||||
pac = projectaction.PojectAction(dr)
|
||||
pac.delete_project(p_data["projectname"])
|
||||
ppg.open_authproject()
|
||||
ppg.input_and_search_project(p_data["projectname"])
|
||||
sleep(1)
|
||||
self.dr.wait(5)
|
||||
self._add_image("删除项目")
|
||||
flag = self.dr.element_exist("xpath->//td")
|
||||
dr.wait(5)
|
||||
add_image(dr,"删除项目")
|
||||
flag = dr.element_exist("xpath->//td")
|
||||
assert flag is False
|
||||
|
||||
|
||||
|
|
|
@ -5,43 +5,36 @@
|
|||
# @Site :
|
||||
# @File : test_16_delete_tenant.py
|
||||
# @Software: PyCharm
|
||||
import time
|
||||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import tenantAction
|
||||
from public.appmodel import tenantaction
|
||||
from public.pages import authTenantPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
|
||||
@allure.feature("运营部门管理")
|
||||
class TestTenantDelete(mytest.MyTest):
|
||||
class TestTenantDelete():
|
||||
"""删除运营部门测试"""
|
||||
@allure.story("删除运营部门")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_tenant(self):
|
||||
login = Login(self.dr)
|
||||
def test_delete_tenant(self,login_admin):
|
||||
dr = login_admin
|
||||
t_data = datainfo.get_xls_to_dict("tenantdata.xlsx", "Sheet1")["创建运营部门"]
|
||||
tpg = authTenantPage.AuthTenantPage(self.dr)
|
||||
ta = tenantAction.TenantAction(self.dr)
|
||||
# login.login("wuzs0001","1qaz!QAZ")
|
||||
login.login("系统管理员", "123456")
|
||||
|
||||
tpg = authTenantPage.AuthTenantPage(dr)
|
||||
ta = tenantaction.TenantAction(dr)
|
||||
try:
|
||||
ta.remove_post(t_data["tenantname"])
|
||||
except BaseException:
|
||||
self.logger.error("移除用户失败,请确认是否该岗位未关联用户")
|
||||
ta.delete_tenant(t_data["tenantname"])
|
||||
|
||||
tpg.open_authtenant()
|
||||
# 搜索运营部门
|
||||
tpg.input_secrch_tenant(t_data["tenantname"])
|
||||
time.sleep(2)
|
||||
self.dr.wait(5)
|
||||
self._add_image("删除运营部门")
|
||||
flag = self.dr.element_exist("id->card")
|
||||
dr.wait(5)
|
||||
add_image(dr,"删除运营部门")
|
||||
flag = dr.element_exist("id->card")
|
||||
assert flag is False
|
||||
|
||||
|
||||
|
|
|
@ -10,92 +10,63 @@ import pytest
|
|||
import allure
|
||||
import time
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import resNodeAction
|
||||
from public.appmodel import resnodeaction
|
||||
from public.pages import sys_regionMgrPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.common.log import Log
|
||||
|
||||
|
||||
@allure.feature("资源节点管理")
|
||||
class TestDeleteEndpoint(mytest.MyTest):
|
||||
class TestDeleteEndpoint():
|
||||
"""测试删除Endpoint"""
|
||||
|
||||
def setup_class(self):
|
||||
"""重写类级setup"""
|
||||
self.logger = Log()
|
||||
self.logger.info(
|
||||
'############################### START ###############################')
|
||||
self.dr = pyselenium.PySelenium(globalparam.browser)
|
||||
self.dr.max_window()
|
||||
self.login = Login(self.dr)
|
||||
self.datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
self.login.login(self.datas["username"], self.datas["password"])
|
||||
self.arn = resNodeAction.Add_Res_Node(self.dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(self.dr)
|
||||
|
||||
@allure.story("VMware删除endpint")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_vmware_endpoint(self):
|
||||
def test_delete_vmware_endpoint(self,login_domain):
|
||||
"""
|
||||
测试删除vmware,endpoint
|
||||
:return:
|
||||
"""
|
||||
dr = login_domain
|
||||
self.arn = resnodeaction.Add_Res_Node(dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict("res_node_data.xlsx", "endpoint")[
|
||||
"创建vmware-endpoint"]
|
||||
# self.arn.add_endpoint(p_data["regionname"],p_data["nodename"],p_data["servicename"],p_data["url"])
|
||||
self.arn.delete_endpoint(
|
||||
p_data["regionname"],
|
||||
p_data["nodename"],
|
||||
p_data["servicename"])
|
||||
|
||||
# self.srmpg.open_sys_regionMgr_page()
|
||||
#
|
||||
# self.srmpg.click_region_tree(p_data["regionname"])
|
||||
# time.sleep(5)
|
||||
# # self.srmpg.click_tree_res_node(p_data["nodename"])
|
||||
# self.srmpg.click_tree_res_node_i(p_data["nodename"])
|
||||
# time.sleep(0.5)
|
||||
# self.srmpg.click_tree_res_service(p_data["servicename"])
|
||||
# time.sleep(0.5)
|
||||
time.sleep(1)
|
||||
self.dr.wait(5)
|
||||
self._add_image("VMware删除endpint")
|
||||
flag = self.dr.element_exist(
|
||||
dr.wait(5)
|
||||
add_image(dr,"VMware删除endpint")
|
||||
flag = dr.element_exist(
|
||||
"xpath->//table[@id='accessPoint']/tbody/tr[2]")
|
||||
assert flag is False
|
||||
|
||||
@allure.story("openstack删除endpoint")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_openstack_endpoint(self):
|
||||
def test_delete_openstack_endpoint(self,login_domain):
|
||||
"""
|
||||
测试删除openstack,endpoint
|
||||
:return:
|
||||
"""
|
||||
|
||||
dr = login_domain
|
||||
self.arn = resnodeaction.Add_Res_Node(dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict(
|
||||
"res_node_data.xlsx", "endpoint")["创建os-l-endpoint"]
|
||||
# self.arn.add_endpoint(p_data["regionname"], p_data["nodename"], p_data["servicename"], p_data["url"])
|
||||
self.arn.delete_endpoint(
|
||||
p_data["regionname"],
|
||||
p_data["nodename"],
|
||||
p_data["servicename"])
|
||||
|
||||
# self.srmpg.open_sys_regionMgr_page()
|
||||
# self.srmpg.click_region_tree(p_data["regionname"])
|
||||
# time.sleep(3)
|
||||
# # self.srmpg.click_tree_res_node(p_data["nodename"])
|
||||
# self.srmpg.click_tree_res_node_i(p_data["nodename"])
|
||||
# time.sleep(0.5)
|
||||
# self.srmpg.click_tree_res_service(p_data["servicename"])
|
||||
# time.sleep(0.5)
|
||||
time.sleep(1)
|
||||
self.dr.wait(5)
|
||||
self._add_image("openstack删除endpoint")
|
||||
flag = self.dr.element_exist(
|
||||
dr.wait(5)
|
||||
add_image(dr,"openstack删除endpoint")
|
||||
flag = dr.element_exist(
|
||||
"xpath->//table[@id='accessPoint']/tbody/tr[2]")
|
||||
assert flag is False
|
||||
|
||||
|
|
|
@ -10,36 +10,25 @@ import time
|
|||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import resNodeAction
|
||||
from public.appmodel import resnodeaction
|
||||
from public.pages import sys_regionMgrPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
from public.common import pyselenium
|
||||
from config import globalparam
|
||||
from public.common.log import Log
|
||||
|
||||
|
||||
@allure.feature("资源节点管理")
|
||||
class TestDeleteService(mytest.MyTest):
|
||||
class TestDeleteService():
|
||||
"""测试删除service"""
|
||||
|
||||
def setup_class(self):
|
||||
"""重写类setup"""
|
||||
self.logger = Log()
|
||||
self.logger.info(
|
||||
'############################### START ###############################')
|
||||
self.dr = pyselenium.PySelenium(globalparam.browser)
|
||||
self.dr.max_window()
|
||||
self.login = Login(self.dr)
|
||||
self.datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
self.login.login(self.datas["username"], self.datas["password"])
|
||||
self.arn = resNodeAction.Add_Res_Node(self.dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(self.dr)
|
||||
|
||||
@allure.story("删除VMware服务")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_service_vmware(self):
|
||||
def test_delete_service_vmware(self,login_domain):
|
||||
dr = login_domain
|
||||
self.arn = resnodeaction.Add_Res_Node(dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict(
|
||||
"res_node_data.xlsx",
|
||||
"vmwareapi")["创建service-vmware"]
|
||||
|
@ -49,35 +38,31 @@ class TestDeleteService(mytest.MyTest):
|
|||
p_data["servicename"])
|
||||
# 校验
|
||||
self.srmpg.open_sys_regionMgr_page()
|
||||
# time.sleep(1)
|
||||
# self.srmpg.click_region_tree(p_data["regionname"])
|
||||
# self.srmpg.click_tree_res_node(p_data["nodename"])
|
||||
# self.srmpg.click_tree_res_node_i(p_data["nodename"])
|
||||
self.dr.wait(5)
|
||||
self._add_image("删除VMware服务")
|
||||
flag = self.dr.element_exist(
|
||||
dr.wait(5)
|
||||
add_image(dr,"删除VMware服务")
|
||||
flag = dr.element_exist(
|
||||
"xpath->(//a[contains(text(),'%s')])" %
|
||||
p_data["servicename"])
|
||||
assert flag is False
|
||||
|
||||
@allure.story("删除openstack服务")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_service_openstack(self):
|
||||
def test_delete_service_openstack(self,login_domain):
|
||||
dr = login_domain
|
||||
self.arn = resnodeaction.Add_Res_Node(dr)
|
||||
self.srmpg = sys_regionMgrPage.SysRegionMgrPage(dr)
|
||||
p_data = datainfo.get_xls_to_dict(
|
||||
"res_node_data.xlsx", "openstackapi")["创建service-keystone"]
|
||||
self.arn.delete_service(
|
||||
p_data["regionname"],
|
||||
p_data["nodename"],
|
||||
p_data["servicename"])
|
||||
|
||||
self.srmpg.open_sys_regionMgr_page()
|
||||
self.dr.wait(5)
|
||||
self._add_image("删除openstack服务")
|
||||
flag = self.dr.element_exist(
|
||||
dr.wait(5)
|
||||
add_image(dr,"删除openstack服务")
|
||||
flag = dr.element_exist(
|
||||
"xpath->(//a[contains(text(),'%s')])" %
|
||||
p_data["servicename"])
|
||||
assert flag is False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["-s", "test_21_delete_user.py"])
|
||||
pytest.main(["-s", "test_18_delete_service.py"])
|
||||
|
|
|
@ -10,40 +10,34 @@ import time
|
|||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import resNodeAction
|
||||
from public.appmodel import resnodeaction
|
||||
from public.pages import sys_regionMgrPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
|
||||
@allure.feature("资源节点管理")
|
||||
class TestDeleteRegion(mytest.MyTest):
|
||||
class TestDeleteRegion():
|
||||
"""测试添加资源节点"""
|
||||
|
||||
@allure.story("删除资源节点")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_region(self):
|
||||
|
||||
login = Login(self.dr)
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
def test_delete_region(self,login_domain):
|
||||
dr = login_domain
|
||||
p_data = datainfo.get_xls_to_dict("res_node_data.xlsx", "region")["创建资源节点"]
|
||||
|
||||
arn = resNodeAction.Add_Res_Node(self.dr)
|
||||
srmpg = sys_regionMgrPage.SysRegionMgrPage(self.dr)
|
||||
# login.login("wuzs0001","1qaz!QAZ")
|
||||
login.login(datas["username"], datas["password"])
|
||||
arn = resnodeaction.Add_Res_Node(dr)
|
||||
srmpg = sys_regionMgrPage.SysRegionMgrPage(dr)
|
||||
arn.delete_res_node(p_data["regionname"], p_data["nodename"])
|
||||
# text = self.dr.get_text("xpath->//div[@class='box-body']/table-component/div/table/tbody")
|
||||
# 搜索项目
|
||||
self.dr.wait(5)
|
||||
self._add_image("删除资源节点")
|
||||
dr.wait(5)
|
||||
add_image(dr,"删除资源节点")
|
||||
srmpg.open_sys_regionMgr_page()
|
||||
flag = self.dr.element_exist(
|
||||
flag = dr.element_exist(
|
||||
"xpath->//a[contains(text(),'%s')]" %
|
||||
p_data["nodename"])
|
||||
assert flag is False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["-s", "test_21_delete_user.py"])
|
||||
pytest.main(["-s", "test_19_delete_region.py"])
|
||||
|
|
|
@ -9,37 +9,38 @@ import pytest
|
|||
import allure
|
||||
|
||||
from time import sleep
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import userAction
|
||||
from public.appmodel import useraction
|
||||
from public.pages import sysUorgMgrPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("driver")
|
||||
@pytest.mark.usefixtures('login_admin')
|
||||
@allure.feature("域管理")
|
||||
class TestRemoveDomainAdmin(mytest.MyTest):
|
||||
class TestRemoveDomainAdmin():
|
||||
"""移除域管理员"""
|
||||
|
||||
@allure.story("移除域管理员")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_remove_domain_admin(self):
|
||||
def test_remove_domain_admin(self,login_admin):
|
||||
|
||||
login = Login(self.dr)
|
||||
login.login("系统管理员", '123456')
|
||||
dr = login_admin
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
upage = sysUorgMgrPage.SysUorgMgrPage(self.dr)
|
||||
ua = userAction.UserAction(self.dr)
|
||||
upage = sysUorgMgrPage.SysUorgMgrPage(dr)
|
||||
ua = useraction.UserAction(dr)
|
||||
ua.remove_domain_administrator(datas["mgrname"], datas["username"])
|
||||
# 校验已分配域管理角色
|
||||
upage.open_uorgmgrpage()
|
||||
upage.input_select_user(datas["username"])
|
||||
sleep(2)
|
||||
self.dr.wait(5)
|
||||
self._add_image("移除域管理员")
|
||||
character = self.dr.get_text(
|
||||
dr.wait(5)
|
||||
add_image(dr,"移除域管理员")
|
||||
character = dr.get_text(
|
||||
"css->.ng-scope:nth-child(4) > .wordBreak")
|
||||
assert character == "0"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["-s", "test_21_delete_user.py"])
|
||||
pytest.main(["-s", "test_20_remove_domain_admin.py"])
|
||||
|
|
|
@ -8,36 +8,32 @@
|
|||
import pytest
|
||||
import allure
|
||||
|
||||
from public.common import mytest
|
||||
from public.common.publicfunction import *
|
||||
from public.common import datainfo
|
||||
from public.appModel import userAction
|
||||
from public.appmodel import useraction
|
||||
from public.pages import sysUorgMgrPage
|
||||
from public.appModel.loginAction import Login
|
||||
from public.appmodel.loginaction import Login
|
||||
from public.common import publicfunction
|
||||
|
||||
|
||||
@allure.feature("用户管理")
|
||||
class TestDeleteUser(mytest.MyTest):
|
||||
|
||||
|
||||
class TestDeleteUser():
|
||||
|
||||
"""测试删除域管理员"""
|
||||
@allure.story("删除域用户")
|
||||
@pytest.mark.flaky(reruns=3)
|
||||
def test_delete_user(self):
|
||||
|
||||
login = Login(self.dr)
|
||||
login.login("系统管理员", '123456')
|
||||
|
||||
def test_delete_user(self,login_admin):
|
||||
dr = login_admin
|
||||
datas = datainfo.get_xls_to_dict("user.xlsx", "Sheet1")["创建域管理员"]
|
||||
upage = sysUorgMgrPage.SysUorgMgrPage(self.dr)
|
||||
ua = userAction.UserAction(self.dr)
|
||||
upage = sysUorgMgrPage.SysUorgMgrPage(dr)
|
||||
ua = useraction.UserAction(dr)
|
||||
ua.delete_user(datas["username"])
|
||||
# ua.delete_user(datas["username"])
|
||||
# upage.input_select_user(datas["username"])
|
||||
# 查看用户,进行校验
|
||||
upage.input_select_user(datas["username"])
|
||||
self.dr.wait(5)
|
||||
self._add_image("移除域管理员")
|
||||
flag = self.dr.element_exist(
|
||||
dr.wait(5)
|
||||
add_image(dr,"移除域管理员")
|
||||
flag = dr.element_exist(
|
||||
"xpath->//span[contains(.,'%s')]" %
|
||||
datas["username"])
|
||||
assert flag is flag, "用户删除成功,请查看日志"
|
||||
|
|
Loading…
Reference in New Issue