Commit d3e5547e authored by libin's avatar libin
Browse files

20190723

parent 3471aba5
This diff is collapsed.
......@@ -14,7 +14,6 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import urllib
import logging
from src.common import com_module
from selenium.common.exceptions import NoSuchElementException, TimeoutException
......@@ -23,8 +22,6 @@ from datetime import datetime
class WebClient():
__driver = None
logging.basicConfig(level=logging.INFO)
def __init__(self, url):
self.url = url
self.timeout = 2
......@@ -256,7 +253,7 @@ class WebClient():
try:
self.wait_unit_elem(element_selector, find_by)
txtmsg = self.get_element(element_selector, find_by).text
logging.info("==> expected text:" + msg+ ",extual text:" + txtmsg)
print("expected text:" + msg+ ",actual text:" + txtmsg)
assert msg in txtmsg
# try:
# assert msg in txtmsg
......@@ -271,7 +268,7 @@ class WebClient():
def assert_multiple_mark_msg(self,elements_selector,msg,find_by=By.XPATH):
self.wait_unit_elem(elements_selector, find_by)
txtmsgs = self.get_elements(elements_selector, find_by)
logging.info("==> expected text:" + msg+ ",extual text:" + txtmsgs)
print("expected text:" + msg+ ",actual text:" + txtmsgs)
for txtmsg in txtmsgs:
txt = txtmsg.text
assert msg in txt
......@@ -299,7 +296,7 @@ class WebClient():
def assert_attribute_msg(self, element_selector, attr, msg, find_by=By.XPATH):
self.wait_unit_elem(element_selector, find_by)
attrmsg = self.get_element(element_selector, find_by).get_attribute(attr)
logging.info("extual attribute:" + attrmsg)
print("actual attribute:" + attrmsg)
assert msg in attrmsg
# try:
# assert msg in attrmsg
......@@ -312,9 +309,10 @@ class WebClient():
def assert_multiple_attribute_msg(self,element_selector,attr,msg,find_by=By.XPATH):
self.wait_unit_elem(element_selector, find_by)
attributes = self.get_elements(element_selector, find_by)
logging.info("extual attributes:" + attributes)
print("actual attributes:")
for attribute in attributes:
attribute_msg = attribute.get_attribute(attr)
print(" " + attribute_msg)
assert msg in attribute_msg
# try:
# assert msg in attribute_msg
......
......@@ -761,12 +761,12 @@ class HTMLTestRunner(Template_mixin):
tmpl = has_output and self.REPORT_TEST_WITH_OUTPUT_TMPL or self.REPORT_TEST_NO_OUTPUT_TMPL
# o and e should be byte string because they are collected from stdout and stderr?
if isinstance(o,str):
# if isinstance(o,str):
# TODO: some problem with 'string_escape': it escape \n and mess up formating
# uo = unicode(o.encode('string_escape'))
uo = e
else:
uo = o
# uo = e
# else:
uo = o
if isinstance(e,str):
# TODO: some problem with 'string_escape': it escape \n and mess up formating
# ue = unicode(e.encode('string_escape'))
......
......@@ -54,4 +54,4 @@ ADMINISTRATOR_FLIP_2 = ".//li[@title='2']"
ADMINISTRATOR_FLIP_3 = ".//li[@title='3']"
ADMINISTRATOR_FLIP_NEXT = ".ant-pagination-next"
ADMINISTRATOR_FLIP_PREVIOUS = ".ant-pagination-prev"
ADMINISTRATOR_PAGE_BTN = '//*[@id="main"]/div/div[2]/div[2]/div/div/ul'
\ No newline at end of file
ADMINISTRATOR_PAGE_BTN = '//*[@id="main"]/div/div[2]/div[2]/div/div/ul/li[last()-1]'
\ No newline at end of file
......@@ -25,6 +25,8 @@ COMPANYADMIN_GWWH_ZWCX = ".//a[@href='/main/station/search']"
COMPANYADMIN_GWWH_GWSC = ".//a[@href='/main/station/space']"
COMPANYADMIN_DTGL = '//*[@id="workstationIndex"]/div/div/div[1]/div/ul/li[6]/div'
COMPANYADMIN_DTGL_DTWH = '//*[@id="sub5$Menu"]/li[1]'
COMPANYADMIN_DTGL_KJSC = '//*[@id="sub5$Menu"]/li[2]'
'''工位管理'''
COMPANYADMIN_XTPZ = '//*[@id="workstationIndex"]/div/div/div[1]/div/ul/li[4]/div/span/span'
COMPANYADMIN_XTPZ_YQGL = '//*[@id="sub3$Menu"]/li[1]/a'
......
......@@ -10,9 +10,7 @@ def assert_select_result(select_sql,msg):
sql_obj.connectdb()
sql_obj.executeSQL(select_sql)
result = sql_obj.result[0][0]
print(result)
logging.info("info----")
logging.error("error-----")
print("expected result:" + msg + ",actual result:" + result)
sql_obj.commitSQL()
sql_obj.close_connect()
if isinstance(result, str):
......
......@@ -25,7 +25,8 @@ class EditCompany(unittest.TestCase):
self.object.sendkeys_to_element(administrator.ADMINISTRATOR_CREATECOMPANY_COMPANYNAME, self.COMPANY_NAME,By.CSS_SELECTOR)
self.object.sendkeys_to_element(administrator.ADMINISTRATOR_CREATECOMPANY_COMPANYURL, self.COMPANY_URL,By.CSS_SELECTOR)
self.object.click_element(administrator.ADMINISTRATOR_CREATECOMPANY_DETERMINE, By.CSS_SELECTOR)
self.object.to_last_page(administrator.ADMINISTRATOR_PAGE_BTN)
self.object.scroll_to_bottom()
self.object.click_element(administrator.ADMINISTRATOR_PAGE_BTN)
'''编辑企业域,直接点确定'''
def test_edit_company_001(self):
......@@ -130,7 +131,7 @@ class EditCompany(unittest.TestCase):
def tearDown(self):
# 删除企业域
deal_sql = "delete from `domain` where domainName = 'qweqweqwe' and domainStatus = '0' "
deal_sql = "delete from `domain` where domainName = 'qweqweqwe'"
deal_db_data.execute_sql(deal_sql)
self.object.exit_all_browsers()
......
......@@ -13,8 +13,8 @@ from src.elementlib import companyadmin,xtpz_jsgl
class DeleteRole(unittest.TestCase):
def setUp(self):
insert_role = '''INSERT INTO `role`(domainId,menu,roleName,roleType,roleFlag,scopes,defaultRole,speReser)
VALUES({di},'{"backMenu":"1","webMenu":"30,31,32,33,34"}','VIP用户',0,0,'{"scopes":[{"scopeType":-1,"tableIds":0}]}',1,1),
({di},'{"backMenu":"1","webMenu":"30,31,32,33,34"}','VIP用户01',0,0,'{"scopes":[{"scopeType":-1,"tableIds":0}]}',1,1);''' \
VALUES({di},'{{"backMenu":"1","webMenu":"30,31,32,33,34"}}','VIP用户',0,0,'{{"scopes":[{{"scopeType":-1,"tableIds":0}}]}',1,1),
({di},'{{"backMenu":"1","webMenu":"30,31,32,33,34"}}','VIP用户01',0,0,'{{"scopes":[{{"scopeType":-1,"tableIds":0}}]}',1,1);''' \
.format(di = test_data.COMPANY_ID)
deal_db_data.execute_sql(insert_role)
self.browser = web_client.WebClient(test_data.MANAGE_URL)
......
......@@ -42,7 +42,7 @@ class EditStation(unittest.TestCase):
deal_db_data.execute_sql(insert_user)
#插入工位数据
insert_station = '''INSERT INTO `mobilestation`(id,domainId,floorAreaId,floorAreaNum,floorId,floorNum,officeBuildingId,officeBuildingName,orgId,parkName,qrCodeDir,qrCodeUrl,stationNum,stationState,stationType,userId,userName,parkId)
VALUES(2450,{di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'/ReserveStation/pub/encoderImg/135/135_109_99_Pre_Floor_3_Pre_Part_A_PM001_2450.png','http://vchat.virsical.cn/wx/qrcode?domainId=135&stationId=2450','PM001',3,1,NULL,NULL,{pi}),
VALUES(2450,{di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'/ReserveStation/pub/encoderImg/135/135_109_99_Pre_Floor_3_Pre_Part_A_PM001_2450.png','http://vchat.virsical.cn/wx/qrcode?domainId=135&stationId=2450','PM001',3,1,0,NULL,{pi}),
(2451,{di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'/ReserveStation/pub/encoderImg/135/135_109_99_Pre_Floor_3_Pre_Part_A_PF002_2451.png','http://vchat.virsical.cn/wx/qrcode?domainId=135&stationId=2451','PF002',3,2,{ui},'{un}',{pi});
'''.format(di = test_data.COMPANY_ID, ai = test_data.PRE_AREA_ID, an = test_data.PRE_AREA_NAME, fi = test_data.PRE_FLOOR_ID, fn = test_data.PRE_FLOOR_NAME, bi = test_data.PRE_BUILD_ID, bn = test_data.PRE_BUILD_NAME, oi = test_data.PRE_DEPARTMENT_ID, pn = test_data.PRE_PARK_NAME, pi = test_data.PRE_PARK_ID, ui = test_data.PRE_USER_ID, un = test_data.PRE_USER_NAME)
deal_db_data.execute_sql(insert_station)
......
......@@ -57,9 +57,9 @@ class SearchStation(unittest.TestCase):
deal_db_data.execute_sql(insert_user)
#插入“工位”数据
insert_station = '''INSERT INTO `mobilestation`(domainId,floorAreaId,floorAreaNum,floorId,floorNum,officeBuildingId,officeBuildingName,orgId,parkName,stationNum,stationState,stationType,userId,userName,parkId)
VALUES({di},(SELECT id FROM `floorarea` WHERE domainId={di} AND floorAreaNum='A1'),'A1',(SELECT id FROM floor WHERE domainId={di} AND floorNum='F1'),'F1',(SELECT id FROM `officebuilding` WHERE domainId={di} AND officeBuildingName='A座'),'A座',(SELECT id FROM `organization` WHERE domainId={di} AND orgName='在线教育研发部'),'中关村','S1',3,2,NULL,NULL,(SELECT id FROM `park` WHERE domainId={di} AND parkName='中关村')),
({di},(SELECT id FROM `floorarea` WHERE domainId={di} AND floorAreaNum='A2'),'A2',(SELECT id FROM floor WHERE domainId={di} AND floorNum='F3'),'F3',(SELECT id FROM `officebuilding` WHERE domainId={di} AND officeBuildingName='C座'),'C座',(SELECT id FROM `organization` WHERE domainId={di} AND orgName='运维部'),'阿里','S2',3,1,NULL,NULL,(SELECT id FROM `park` WHERE domainId={di} AND parkName='阿里')),
({di},(SELECT id FROM `floorarea` WHERE domainId={di} AND floorAreaNum='A1'),'A1',(SELECT id FROM floor WHERE domainId={di} AND floorNum='F1'),'F1',(SELECT id FROM `officebuilding` WHERE domainId={di} AND officeBuildingName='A座'),'A座',(SELECT id FROM `organization` WHERE domainId={di} AND orgName='测试部门'),'中关村','S3',3,1,NULL,NULL,(SELECT id FROM `park` WHERE domainId={di} AND parkName='中关村')),
VALUES({di},(SELECT id FROM `floorarea` WHERE domainId={di} AND floorAreaNum='A1'),'A1',(SELECT id FROM floor WHERE domainId={di} AND floorNum='F1'),'F1',(SELECT id FROM `officebuilding` WHERE domainId={di} AND officeBuildingName='A座'),'A座',(SELECT id FROM `organization` WHERE domainId={di} AND orgName='在线教育研发部'),'中关村','S1',3,2,0,NULL,(SELECT id FROM `park` WHERE domainId={di} AND parkName='中关村')),
({di},(SELECT id FROM `floorarea` WHERE domainId={di} AND floorAreaNum='A2'),'A2',(SELECT id FROM floor WHERE domainId={di} AND floorNum='F3'),'F3',(SELECT id FROM `officebuilding` WHERE domainId={di} AND officeBuildingName='C座'),'C座',(SELECT id FROM `organization` WHERE domainId={di} AND orgName='运维部'),'阿里','S2',3,1,0,NULL,(SELECT id FROM `park` WHERE domainId={di} AND parkName='阿里')),
({di},(SELECT id FROM `floorarea` WHERE domainId={di} AND floorAreaNum='A1'),'A1',(SELECT id FROM floor WHERE domainId={di} AND floorNum='F1'),'F1',(SELECT id FROM `officebuilding` WHERE domainId={di} AND officeBuildingName='A座'),'A座',(SELECT id FROM `organization` WHERE domainId={di} AND orgName='测试部门'),'中关村','S3',3,1,0,NULL,(SELECT id FROM `park` WHERE domainId={di} AND parkName='中关村')),
({di},(SELECT id FROM `floorarea` WHERE domainId={di} AND floorAreaNum='A2'),'A2',(SELECT id FROM floor WHERE domainId={di} AND floorNum='F3'),'F3',(SELECT id FROM `officebuilding` WHERE domainId={di} AND officeBuildingName='C座'),'C座',(SELECT id FROM `organization` WHERE domainId={di} AND orgName='在线教育研发部'),'阿里','S4',3,2,(SELECT id FROM `userinfo` WHERE domainId={di} AND employeeName='cyq'),'cyq',(SELECT id FROM `park` WHERE domainId={di} AND parkName='阿里'));
'''.format(di = test_data.COMPANY_ID)
deal_db_data.execute_sql(insert_station)
......
......@@ -18,18 +18,18 @@ class DeleteStation(unittest.TestCase):
deal_db_data.clear_station()
#插入工位,作为预置数据
insert_station = '''INSERT INTO `mobilestation`(domainId,floorAreaId,floorAreaNum,floorId,floorNum,officeBuildingId,officeBuildingName,orgId,parkName,stationNum,stationState,stationType,userId,userName,parkId)
VALUES({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S001',3,1,NULL,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S002',3,1,NULL,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S003',3,1,NULL,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S004',3,1,NULL,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S005',3,1,NULL,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S006',3,1,NULL,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S007',3,1,NULL,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S008',3,1,NULL,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S009',3,1,NULL,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S010',3,1,NULL,NULL,{pi}),
VALUES({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S001',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S002',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S003',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S004',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S005',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S006',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S007',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S008',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S009',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S010',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S011',3,2,(SELECT id FROM `userinfo` WHERE domainId={di} AND employeeName='cyq'),'cyq',{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S012',3,1,NULL,NULL,{pi});''' \
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S012',3,1,0,NULL,{pi});''' \
.format(di = test_data.COMPANY_ID, ai = test_data.PRE_AREA_ID, an = test_data.PRE_AREA_NAME, fi = test_data.PRE_FLOOR_ID, fn = test_data.PRE_FLOOR_NAME, bi = test_data.PRE_BUILD_ID, bn = test_data.PRE_BUILD_NAME, oi = test_data.PRE_DEPARTMENT_ID, pn = test_data.PRE_PARK_NAME, pi = test_data.PRE_PARK_ID)
deal_db_data.execute_sql(insert_station)
login_swp.login01(self.browser, test_data.COMPANYADMIN_NAME, test_data.COMPANYADMIN_PW) #登录
......
......@@ -20,8 +20,8 @@ class EditStationMap(unittest.TestCase):
delete_sql = "DELETE FROM `stationelement` WHERE floorAreaId=" + test_data.PRE_AREA_ID
deal_db_data.execute_sql(delete_sql)
login_swp.login01(self.browser, test_data.COMPANYADMIN_NAME, test_data.COMPANYADMIN_PW) #登录
self.browser.click_element(companyadmin.COMPANYADMIN_GWWH) #点击侧边栏中的“工位维护
self.browser.click_element(companyadmin.COMPANYADMIN_GWWH_GWDT) #点击侧边栏中的“工位地图”
self.browser.click_element(companyadmin.COMPANYADMIN_DTGL) #点击侧边栏中的“资源管理
self.browser.click_element(companyadmin.COMPANYADMIN_DTGL_DTWH) #点击侧边栏中的“地图维护
sub_page = self.browser.get_current_page_handle() #获取当前浏览页面的句柄
self.browser.click_element(gwwh_gwdt.EDIT_STATION_MAP_BTN, By.NAME) #点击“编辑工位地图”按钮
all_pages = self.browser.get_all_pages_handles() #获取打开的所有浏览页面的句柄
......
......@@ -24,7 +24,7 @@ class StationSeatManagement(unittest.TestCase):
self.browser = web_client.WebClient(test_data.MANAGE_URL)
#插入工位信息
insert_station = '''INSERT INTO `mobilestation`(domainId,floorAreaId,floorAreaNum,floorId,floorNum,officeBuildingId,officeBuildingName,orgId,parkName,stationNum,stationState,stationType,userId,userName,parkId)
VALUES({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S001',3,1,NULL,NULL,{pi}),
VALUES({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S001',3,1,0,NULL,{pi}),
({di},{ai},'{an}',{fi},'{fn}',{bi},'{bn}',{oi},"{pn}",'S011',3,2,{ui},'{un}',{pi});
'''.format(di =test_data.COMPANY_ID, ai = test_data.PRE_AREA_ID, an = test_data.PRE_AREA_NAME, fi = test_data.PRE_FLOOR_ID, fn = test_data.PRE_FLOOR_NAME, bi = test_data.PRE_BUILD_ID, bn = test_data.PRE_BUILD_NAME, oi = test_data.PRE_DEPARTMENT_ID, pn = test_data.PRE_PARK_NAME, ui = test_data.PRE_USER_ID, un = test_data.PRE_USER_NAME, pi = test_data.PRE_USER_ID)
deal_db_data.execute_sql(insert_station)
......
......@@ -13,8 +13,8 @@ class spaceMaterial(unittest.TestCase):
delte_test_data = "delete from `stationsvg` WHERE svgName ='xkj'"
deal_db_data.execute_sql(delte_test_data)
login_swp.login01(self.browser, test_data.COMPANYADMIN_NAME, test_data.COMPANYADMIN_PW) #登录
self.browser.click_element(companyadmin.COMPANYADMIN_GWWH) #点击侧边栏中的“工位维护
self.browser.click_element(companyadmin.COMPANYADMIN_GWWH_GWSC) #点击“工位维护”下的“工位素材”
self.browser.click_element(companyadmin.COMPANYADMIN_DTGL) #点击侧边栏中的“地图管理
self.browser.click_element(companyadmin.COMPANYADMIN_DTGL_KJSC) #点击“地图管理”下的“空间素材”
logging.basicConfig(level = logging.INFO)
self.browser.assert_mark_msg(gwwh_kjsc.SPACE_MATERIAL, test_data.STATION_SPACE_MATERIAL, By.CSS_SELECTOR)
......
......@@ -12,8 +12,8 @@ class editSpaceMaterial(unittest.TestCase):
def setUp(self):
self.browser = web_client.WebClient(test_data.MANAGE_URL)
login_swp.login01(self.browser, test_data.COMPANYADMIN_NAME, test_data.COMPANYADMIN_PW) #登录
self.browser.click_element(companyadmin.COMPANYADMIN_GWWH) #点击侧边栏中的“工位维护”
self.browser.click_element(companyadmin.COMPANYADMIN_GWWH_GWSC) #点击“工位维护”下的“工位素材”
self.browser.click_element(companyadmin.COMPANYADMIN_DTGL) #点击侧边栏中的“工位维护”
self.browser.click_element(companyadmin.COMPANYADMIN_DTGL_KJSC) #点击“工位维护”下的“工位素材”
logging.basicConfig(level = logging.INFO)
self.browser.assert_mark_msg(gwwh_kjsc.SPACE_MATERIAL, test_data.STATION_SPACE_MATERIAL, By.CSS_SELECTOR)
self.browser.click_element(gwwh_kjsc.UPLOAD_MATERIAL, By.CSS_SELECTOR)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment