class Robot_system(unittest.TestCase): def setUp(self) -> None: # 前置条件 #Clear_environment() # 清理web环境 self.br = SeleniumFramework('ge') self.br.Open_url(Robot_url) def tearDown(self) -> None: # 还原测试环境 self.br.Out() def test_login_001(self): # 测试用例 '''这里写测试用例标题 测试输入正确的用户名密码登录'''
def setUp(self) -> None: # 前置条件 self.br = SeleniumFramework() self.br.Open_url(Robot_url) # 登录 self.br.Write('css=input[placeholder="用户名"]', 'admin') self.br.Write('css=input[placeholder="密码"]', 'adminadmin') self.br.Click('xpath=//button[contains(.,"登录")]') # 展开菜单 self.br.Click('xpath=/html/body/div[1]/header/button[2]') self.br.Click('xpath=//li[contains(.," 系统管理")]') self.br.Click('css=a[href="#/sys/officeConfig"]')
class Robot_system(unittest.TestCase): def setUp(self) -> None: # 前置条件 # Clear_environment() # 清理web环境 print(Data) self.br = SeleniumFramework() self.br.Open_url(Robot_url) def tearDown(self) -> None: # 还原测试环境 self.br.Out() @data(*Data) def test_login_001(self,value): # 测试用例 print(value[1],value[2])
class Ranzhi(unittest.TestCase): def setUp(self) -> None: # 前置条件 Clear_environment() #清理web环境 self.br = SeleniumFramework('ge') self.br.Open_url(QQ_url) def tearDown(self) -> None: # 还原测试环境 self.br.Out() def test_login_001(self): # 测试用例 '''这里写测试用例标题 测试输入正确的用户名密码登录''' # 操作步骤 self.br.Switch_to('login_frame') self.br.Write('id=u', User) self.br.Write('id=p', password) self.br.Click('id=login_button') self.br.Default_content() time.sleep(2) #self.br.Switch_to('actionFrame') try: result = self.br.Text_up('css=span[title="关联其他QQ邮箱"]') #提取结果 print(result) except: result = '' self.assertEqual(result, '*****@*****.**', "对比结果不一致") #断言函数,对比两个是否一致
class Robot_system(unittest.TestCase): def setUp(self) -> None: # 前置条件 # Clear_environment() # 清理web环境 self.br = SeleniumFramework() self.br.Open_url(url) def tearDown(self) -> None: # 还原测试环境 self.br.Out() def Login(self, DataTable, CaseId): self.br.Write('css=input[placeholder="用户名"]', DataTable['test_case' + str(CaseId)][1]) self.br.Write('css=input[placeholder="密码"]', DataTable['test_case' + str(CaseId)][2]) self.br.Click('xpath=//button[contains(.,"登录")]') #展开菜单 self.br.Click('xpath=//button[contains(.,"☰")]') def Asser(self, DataTable, CaseId, result): try: result = self.br.Text_up('xpath=//span[contains(.,"%s")]' % str(result)) # 提取结果 print('实际结果:' + result) except: result = None print('预期结果:' + DataTable['test_case' + str(CaseId)][3]) self.assertEqual(result, DataTable['test_case' + str(CaseId)][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_test(self): CaseId = '1' # print('测试标题:' + DataTable['test_case' + str(CaseId)][0]) self.Login(DataTable, CaseId) time.sleep(10)
def test_login_001(self): # 测试用例 '''第一次登录上传位置''' # login driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) driver.find_element_by_id( "com.example.administrator.websc:id/et_login_account").send_keys( "robot01") driver.find_element_by_id( "com.example.administrator.websc:id/et_login_password").send_keys( "123456") driver.find_element_by_id( "com.example.administrator.websc:id/btn_login").click() ExpectedResult = time.time() #获取当前时间戳 # #后台查询 br = SeleniumFramework() br.Open_url(url) # #login br.Write('css=input[placeholder="用户名"]', user) br.Write('css=input[placeholder="密码"]', psw) br.Click('css=button[class="btn btn-primary px-4"]') # #展开菜单-->机器人管理-->位置管理 br.Click( 'css=button[class="navbar-toggler sidebar-toggler d-md-down-none"]' ) br.Click('xpath=//li[contains(.," 机器人管理")]') br.Click('css=a[href="#/device/robotPosition"]') # #点击机构 # br.Click('xpath=//li[contains(.,u"MIR医院D")]') # #获取时间 ActualResult = br.Text_up( 'xpath=/html/body/div[1]/div/main/div/div/div[1]/div[2]/div/div[2]/table/tbody/tr[1]/td[7]/span' ) print(ActualResult) if int(TimeTranslate(ActualResult)) - int(ExpectedResult) < 30: self.assertEqual(1, 1, '对比结果不一致') else: self.assertEqual(1, 2, '对比结果不一致')
def robot(): data = ReadExcel("RobotCodeData.xls").ReadRowsTable("name=Sheet1") print(data) br = SeleniumFramework() br.Open_url('https://www.baidu.com/') for i in data: elestring = i[0] staing = i[1] action = i[2] if action == 'write': br.Write(elestring, staing) elif action == 'click': br.Click(elestring) elif action == 'clear': br.Clear(elestring) elif action == 'text_up': br.Text_up(elestring) else: print("其他行为暂时没有做出来,敬请期待!!!") br.Out()
def setUp(self) -> None: # 前置条件 # Clear_environment() # 清理web环境 print(Data) self.br = SeleniumFramework() self.br.Open_url(Robot_url)
class Robot_system(unittest.TestCase): # @classmethod # def setUpClass(self) -> None: # self.br= SeleniumFramework() def setUp(self) -> None: # 前置条件 self.br = SeleniumFramework() self.br.Open_url(Robot_url) # 登录 self.br.Write('css=input[placeholder="用户名"]', 'admin') self.br.Write('css=input[placeholder="密码"]', 'adminadmin') self.br.Click('xpath=//button[contains(.,"登录")]') # 展开菜单 self.br.Click('xpath=/html/body/div[1]/header/button[2]') self.br.Click('xpath=//li[contains(.," 系统管理")]') self.br.Click('css=a[href="#/sys/officeConfig"]') # @classmethod # def tearDownClass(self) -> None: # self.br.Out() def tearDown(self) -> None: # 还原测试环境 self.br.Out() @data(*DataLowPower) def test_LowPower_001(self, Data): '''机构配置设置低电量99%''' print('测试标题:' + Data[0]) OrganizationName = Data[1] # 机构名称从excel里面读取 Power = Data[2] Mode = Data[3] ExpectedResult = Data[4] print('预期结果:' + ExpectedResult) self.br.Click('xpath=//span[contains(.,"%s")]' % OrganizationName) self.br.Click('css=a[href="javascript:"]') self.br.Write('css=input[placeholder="输入电量低去充电设置(默认30%)"]', Power) self.br.Click('xpath=//label[contains(.,"运行模式")]/../div/div') self.br.Click('xpath=//li[contains(.,"%s")]' % Mode) self.br.Click('xpath=//span[contains(.,"提交" )]') try: ActualResult = self.br.Text_up( 'xpath=/html/body/div[1]/div/main/div/div/div[1]/div[1]/div/div[1]/div' ) except: ActualResult = '' print('实际结果:' + ActualResult) self.assertEqual(ActualResult, ExpectedResult, '对比结果不一致') @data(*DataFreePower) def test_LowPower_002(self, Data): '''机构配置设置低电量99%''' print('测试标题:' + Data[0]) OrganizationName = Data[1] # 机构名称从excel里面读取 Power = Data[2] Time = Data[3] Mode = Data[4] ExpectedResult = Data[5] print('预期结果:' + ExpectedResult) self.br.Click('xpath=//span[contains(.,"%s")]' % OrganizationName) self.br.Click('css=a[href="javascript:"]') self.br.Write('css=input[placeholder="输入闲时充电时间(秒)"]', Time) self.br.Write('css=input[placeholder="输入闲时充电电量(%)"]', Power) self.br.Click('xpath=//label[contains(.,"运行模式")]/../div/div') self.br.Click('xpath=//li[contains(.,"%s")]' % Mode) self.br.Click('xpath=//span[contains(.,"提交" )]') try: ActualResult = self.br.Text_up( 'xpath=/html/body/div[1]/div/main/div/div/div[1]/div[1]/div/div[1]/div' ) except: ActualResult = '' print('实际结果:' + ActualResult) self.assertEqual(ActualResult, ExpectedResult, '对比结果不一致')
password = '******' #后台管理 Robot_url = 'http://logistics-admin-test.epsit.cn:6066/#/auth/login?redirect=%2Fdashboard' #测试环境 #添加用户 Institutions = '图片测试' RobotUserName = '******' RobotUserPassword = '******' RobotUserNickname = 'QWER' if __name__ == '__main__': from Auto_testing_comm_platform.Comm.SeleniumFramework import * from Auto_testing_comm_platform.Comm.Appium import * from Auto_testing_comm_platform.Comm.Base import * # #后台查询 br = SeleniumFramework() br.Open_url( 'http://logistics-admin-test.epsit.cn:6066/#/auth/login?redirect=%2Fdashboard' ) # #login br.Write('css=input[placeholder="用户名"]', 'admin') br.Write('css=input[placeholder="密码"]', 'adminadmin') br.Click('css=button[class="btn btn-primary px-4"]') # #展开菜单-->机器人管理-->位置管理 br.Click( 'css=button[class="navbar-toggler sidebar-toggler d-md-down-none"]') br.Click('xpath=//li[contains(.," 机器人管理")]') br.Click('css=a[href="#/device/robotPosition"]') # #点击机构 # br.Click('xpath=//li[contains(.,u"MIR医院D")]') # #获取时间
class Robot_system(unittest.TestCase): def setUp(self) -> None: # 前置条件 # Clear_environment() # 清理web环境 self.br = SeleniumFramework() self.br.Open_url(Robot_url) def tearDown(self) -> None: # 还原测试环境 self.br.Out() def test_login_001(self): # 测试用例 '''输入正确的用户名''' print('测试标题:' + DataTable['test_case1'][0]) self.br.Write('css=input[placeholder="用户名"]', DataTable['test_case1'][1]) self.br.Write('css=input[placeholder="密码"]', DataTable['test_case1'][2]) self.br.Click('css=button[class="btn btn-primary px-4"]') try: result = self.br.Text_up( 'xpath=//a[contains(.,"易普森医院物流机器人管理系统")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case1'][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_002(self): # 测试用例 '''输入错误的用户名''' print('测试标题:' + DataTable['test_case2'][0]) self.br.Write('css=input[placeholder="用户名"]', DataTable['test_case2'][1]) self.br.Write('css=input[placeholder="密码"]', DataTable['test_case2'][2]) self.br.Click('css=button[class="btn btn-primary px-4"]') try: result = self.br.Text_up('xpath=//p[contains(.,"登入你的账户")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case2'][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_003(self): # 测试用例 '''输入错误的密码''' print('测试标题:' + DataTable['test_case3'][0]) self.br.Write('css=input[placeholder="用户名"]', DataTable['test_case3'][1]) self.br.Write('css=input[placeholder="密码"]', DataTable['test_case3'][2]) self.br.Click('css=button[class="btn btn-primary px-4"]') try: result = self.br.Text_up('xpath=//p[contains(.,"登入你的账户")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case3'][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_004(self): # 测试用例 '''用户名密码都不输入''' print('测试标题:' + DataTable['test_case4'][0]) self.br.Write('css=input[placeholder="用户名"]', DataTable['test_case4'][1]) self.br.Write('css=input[placeholder="密码"]', DataTable['test_case4'][2]) self.br.Click('css=button[class="btn btn-primary px-4"]') try: result = self.br.Text_up('xpath=//p[contains(.,"登入你的账户")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case4'][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_005(self): # 测试用例 '''不输入用户名''' print('测试标题:' + DataTable['test_case5'][0]) self.br.Write('css=input[placeholder="用户名"]', DataTable['test_case5'][1]) self.br.Write('css=input[placeholder="密码"]', DataTable['test_case5'][2]) self.br.Click('css=button[class="btn btn-primary px-4"]') try: result = self.br.Text_up('xpath=//p[contains(.,"登入你的账户")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case5'][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_006(self): # 测试用例 '''不输入密码''' print('测试标题:' + DataTable['test_case6'][0]) self.br.Write('css=input[placeholder="用户名"]', DataTable['test_case6'][1]) self.br.Write('css=input[placeholder="密码"]', DataTable['test_case6'][2]) self.br.Click('css=button[class="btn btn-primary px-4"]') try: result = self.br.Text_up('xpath=//p[contains(.,"登入你的账户")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case6'][3], "对比结果不一致") # 断言函数,对比两个是否一致 def Login(self, DataTable, CaseId): '''登录函数''' self.br.Write('css=input[placeholder="用户名"]', DataTable['test_case' + str(CaseId)][1]) self.br.Write('css=input[placeholder="密码"]', DataTable['test_case' + str(CaseId)][2]) self.br.Click('xpath=//button[contains(.,"登录")]') # 展开菜单 self.br.Click('xpath=//button[contains(.,"☰")]') def Asser(self, DataTable, CaseId, result): '''断言函数''' try: result = self.br.Text_up('xpath=//span[contains(.,"%s")]' % str(result)) # 提取结果 print('实际结果:' + result) except: result = None print('预期结果:' + DataTable['test_case' + str(CaseId)][3]) self.assertEqual(result, DataTable['test_case' + str(CaseId)][3], "对比结果不一致") # 断言函数,对比两个是否一致
import unittest from Auto_testing_comm_platform.Comm.SeleniumFramework import * from Auto_testing_comm_platform.Comm.Base import * from ddt import ddt, unpack, data # DataPath = u'E:\PyCharm\location\Auto_testing_comm_platform\Testcase\LogisticsAdminTest\EpsBackData.xls' Data = Excel(DataPath).DataUp(u'调试')['data'][0] OrganizationName = Data[0] # 机构名称从excel里面读取 Power =Data[1] Mode =Data[3] br = SeleniumFramework() br.Open_url(Robot_url) # 登录 br.Write('css=input[placeholder="用户名"]', 'admin') br.Write('css=input[placeholder="密码"]', 'adminadmin') br.Click('xpath=//button[contains(.,"登录")]') # 展开菜单 br.Click('xpath=/html/body/div[1]/header/button[2]') br.Click('xpath=//li[contains(.," 系统管理")]') br.Click('css=a[href="#/sys/officeConfig"]') br.Click('xpath=//span[contains(.,"%s")]' % OrganizationName) br.Click('css=a[href="javascript:"]') br.Write('xpath=/html/body/div[1]/div/main/div/div/div[2]/div[2]/form/div[7]/div/div/input','') br.Write('xpath=/html/body/div[1]/div/main/div/div/div[2]/div[2]/form/div[8]/div/div/input', '60') # time.sleep(5) # br.Click('xpath=//label[contains(.,"运行模式")]/../div/div') # br.Click('xpath=//li[contains(.,"%s")]' % Mode)
import os, time from Auto_testing_comm_platform.Comm.SeleniumFramework import * from Auto_testing_comm_platform.Config.test_epsit import * # 登录 br = SeleniumFramework('ge') br.Open_url(Robot_url) br.Write('css=input[placeholder="用户名"]', Robot_user) br.Write('css=input[placeholder="密码"]', Robot_password) br.Click('css=button[class="btn btn-primary px-4"]') # 点击首页 br.Click('css=a[href="#/"]') # 点击菜单 br.Click('css=button[class="navbar-toggler sidebar-toggler d-md-down-none"]') # 进入系统管理--》机构配置管理 br.Click('xpath=//li[contains(.," 系统管理")]') br.Click('css=a[href="#/sys/officeConfig"]') # 选择云迹Y1医院D1 br.Click('xpath=//span[contains(.,"云迹Y1医院D1")]') # 点击修改 br.Click('css=[class="fa fa-pencil-square-o text-primary"]') # 找到运行模式 br.Click('xpath=//label[contains(.,"运行模式")]/../div/div') br.Click('xpath=//label[contains(.,"运行模式")]/../div/div/div[2]/ul[2]/li[2]') time.sleep(0.5) # 配置安全距离和危险距离 br.Write('css=input[placeholder="输入安全距离 "]', '4') br.Write('css=input[placeholder="输入危险距离"]', '3') time.sleep(0.5) # 点击提交 br.Click('css=button[class="ivu-btn ivu-btn-info"]')
from Auto_testing_comm_platform.Comm.SeleniumFramework import * br = SeleniumFramework(br_name='ge') br.Open_url('http://logistics-admin-test.epsit.cn:6066/#/auth/login') # 登录 br.Write('css=input[placeholder="用户名"]', 'admin') br.Write('css=input[placeholder="密码"]', 'adminadmin') br.Click('xpath=//button[contains(.,"登录")]') # 展开菜单 br.Click('xpath=/html/body/div[1]/header/button[2]') br.Click('xpath=//li[contains(.," 调度管理")]') br.Click('css=a[href="#/schedule/robotPositionMapping"]') # 添加配置 for i in range(2, 3): br.Click('css=button[class="ivu-btn ivu-btn-success"][title="增加"]') br.Click('xpath=//label[text()="所属机构"]/../div/div/div/span') br.Click('xpath=//label[text()="所属机构"]/../div/div/div[2]/ul[2]/li[5]') time.sleep(0.5) br.Click('xpath=//label[text()="选择机器人类型(默认为MIR)"]/../div/div') br.Click( 'xpath=//label[text()="选择机器人类型(默认为MIR)"]/../div/div/div[2]/ul[2]/li[2]' ) # Y1(云际) time.sleep(0.5) br.Click('xpath=//label[text()="机器人任务位置"]/../div/div') br.Click('xpath=//label[text()="机器人任务位置"]/../div/div/div[2]/ul[2]/li[%s]' % i) # 1楼保安亭 time.sleep(0.5)
class Robot_system(unittest.TestCase): def setUp(self) -> None: # 前置条件 # Clear_environment() # 清理web环境 self.br = SeleniumFramework('wap', 'ge') self.br.Open_url(url) def tearDown(self) -> None: # 还原测试环境 self.br.Out() def Login(self, DataTable, CaseId): print('测试标题:' + DataTable['test_case' + str(CaseId)][0]) self.br.Write('css=input[placeholder="Your name"]', DataTable['test_case' + str(CaseId)][1]) self.br.Write('css=input[type="password"]', DataTable['test_case' + str(CaseId)][2]) self.br.Click('xpath=//button[contains(.,"登录")]') def Asser(self, DataTable, CaseId, result): try: result = self.br.Text_up('xpath=//span[contains(.,"%s")]' % str(result)) # 提取结果 print('实际结果:' + result) except: result = None print('预期结果:' + DataTable['test_case' + str(CaseId)][3]) self.assertEqual(result, DataTable['test_case' + str(CaseId)][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_test(self): CaseId = '7' result = '立即呼叫' self.Login(DataTable, CaseId) self.Asser(DataTable, CaseId, result) def test_login_001(self): # 测试用例 '''输入正确的用户名''' print('测试标题:' + DataTable['test_case1'][0]) self.br.Write('css=input[placeholder="Your name"]', DataTable['test_case1'][1]) self.br.Write('css=input[type="password"]', DataTable['test_case1'][2]) self.br.Click('xpath=//button[contains(.,"登录")]') try: result = self.br.Text_up( 'xpath=//span[contains(.,"立即呼叫")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case1'][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_002(self): # 测试用例 i = '2' print('测试标题:' + DataTable['test_case' + str(i)][0]) self.br.Write('css=input[placeholder="Your name"]', DataTable['test_case' + str(i)][1]) self.br.Write('css=input[type="password"]', DataTable['test_case' + str(i)][2]) self.br.Click('xpath=//button[contains(.,"登录")]') try: result = self.br.Text_up( 'xpath=//span[contains(.,"机器人用户不存在")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case' + str(i)][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_003(self): # 测试用例 i = '3' print('测试标题:' + DataTable['test_case' + str(i)][0]) self.br.Write('css=input[placeholder="Your name"]', DataTable['test_case' + str(i)][1]) self.br.Write('css=input[type="password"]', DataTable['test_case' + str(i)][2]) self.br.Click('xpath=//button[contains(.,"登录")]') try: result = self.br.Text_up( 'xpath=//span[contains(.,"密码错误")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case' + str(i)][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_004(self): # 测试用例 i = '4' print('测试标题:' + DataTable['test_case' + str(i)][0]) self.br.Write('css=input[placeholder="Your name"]', DataTable['test_case' + str(i)][1]) self.br.Write('css=input[type="password"]', DataTable['test_case' + str(i)][2]) self.br.Click('xpath=//button[contains(.,"登录")]') try: result = self.br.Text_up( 'xpath=//span[contains(.,"密码不能为空!")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case' + str(i)][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_005(self): # 测试用例 print('测试标题:' + DataTable['test_case5'][0]) self.br.Write('css=input[placeholder="Your name"]', DataTable['test_case5'][1]) self.br.Write('css=input[type="password"]', DataTable['test_case5'][2]) self.br.Click('xpath=//button[contains(.,"登录")]') try: result = self.br.Text_up( 'xpath=//span[contains(.,"账号不能为空!")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case5'][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_login_006(self): # 测试用例 i = '6' print('测试标题:' + DataTable['test_case' + str(i)][0]) self.br.Write('css=input[placeholder="Your name"]', DataTable['test_case' + str(i)][1]) self.br.Write('css=input[type="password"]', DataTable['test_case' + str(i)][2]) self.br.Click('xpath=//button[contains(.,"登录")]') try: result = self.br.Text_up( 'xpath=//span[contains(.,"密码不能为空!")]') # 提取结果 print('实际结果:' + result) except: result = None self.assertEqual(result, DataTable['test_case' + str(i)][3], "对比结果不一致") # 断言函数,对比两个是否一致
import time from Auto_testing_comm_platform.Comm.SeleniumFramework import * br = SeleniumFramework(br_name='ge') br.Open_url('http://logistics-admin-test.epsit.cn:6066/#/auth/login') # 登录 br.Write('css=input[placeholder="用户名"]', 'admin') br.Write('css=input[placeholder="密码"]', 'adminadmin') br.Click('xpath=//button[contains(.,"登录")]') # 展开菜单 br.Click('xpath=/html/body/div[1]/header/button[2]') br.Click('xpath=//li[contains(.," 运行监控管理")]') br.Click('css=a[href="#/run/monitorStatus"]') # 添加配置 for i in range(1, 28): br.Click('css=button[class="ivu-btn ivu-btn-success"][title="增加"]') br.Click('xpath=//label[text()="所属机构"]/../div/div/div/span') br.Click('xpath=//label[text()="所属机构"]/../div/div/div[2]/ul[2]/li[14]') time.sleep(0.5) br.Click('xpath=//span[contains(.,"输入机器人状态")]') status = br.Text_up( 'xpath=//label[text()="机器人状态"]/../div/div/div[2]/ul[2]/li[%s]' % i) br.Click('xpath=//label[text()="机器人状态"]/../div/div/div[2]/ul[2]/li[%s]' % i) print(status) br.Write('css=input[placeholder="输入异常状态时间间隔"]', '60') br.Write('css=input[placeholder="输入异常推送次数"]', '1') br.Click('xpath=//span[text()="选择预警级别"]') br.Click('xpath=//li[text()="高"]')
def setUp(self) -> None: # 前置条件 # Clear_environment() # 清理web环境 self.br = SeleniumFramework('wap', 'ge') self.br.Open_url(url)
class Robot_system(unittest.TestCase): def setUp(self) -> None: # 前置条件 # Clear_environment() # 清理web环境 self.br = SeleniumFramework() self.br.Open_url(Robot_url) #登录 self.br.Write('css=input[placeholder="用户名"]', 'admin') self.br.Write('css=input[placeholder="密码"]', 'adminadmin') self.br.Click('xpath=//button[contains(.,"登录")]') # 展开菜单 self.br.Click('xpath=/html/body/div[1]/header/button[2]') self.br.Click('xpath=//li[contains(.," 系统管理")]') self.br.Click('css=a[href="#/sys/officeConfig"]') def tearDown(self) -> None: # 还原测试环境 self.br.Out() def Login(self, DataTable, CaseId): '''登录函数''' self.br.Write('css=input[placeholder="用户名"]', DataTable['test_case' + str(CaseId)][1]) self.br.Write('css=input[placeholder="密码"]', DataTable['test_case' + str(CaseId)][2]) self.br.Click('xpath=//button[contains(.,"登录")]') # 展开菜单 self.br.Click('xpath=/html/body/div[1]/header/button[2]') def Asser(self, DataTable, CaseId, string_ele): '''断言函数''' try: result = self.br.Text_up(string_ele) # 提取结果 print('实际结果:' + result) except: result = None print('预期结果:' + DataTable['test_case' + str(CaseId)][3]) self.assertEqual(result, DataTable['test_case' + str(CaseId)][3], "对比结果不一致") # 断言函数,对比两个是否一致 def test_TimedCharging_001(self): # self.br.Click('css=button[title="增加"]') CaseId = '1' self.br.Click('xpath=//span[text()="%s"]' % DataTable['test_case' + str(CaseId)][1]) self.br.Click('css=a[title="修改"]') self.br.Write(DataTable['test_case' + str(CaseId)][2], Time) self.br.Click('xpath=//span[text()="提交"]') try: result = self.br.Text_up( 'css=div[class="ivu-loading-bar-inner ivu-loading-bar-inner-color-primary"][style="width: 0%; height: 2px;"]' ) # 提取结果 except: result = None print('实际结果:' + result) print('预期结果:' + DataTable['test_case' + str(CaseId)][3]) self.assertEqual(result, '机构配置信息', "对比结果不一致") # 断言函数,对比两个是否一致