def test_LoginYMS(self): l = LoginPage.Login_start(self.driver, Globalvar.config_path) #step1 登录内网Outbound账号================================================ l.login_YMS(Globalvar.YMS_account, Globalvar.YMS_password, Globalvar.YMS_server, Globalvar.YMS_outbound) pp = ParseRepository.ParseRepositoryConfig(Globalvar.config_path) # self.driver.implicitly_wait(5) #点击展开设置页,验证账号信息 ObjectMap.getElement(self.driver, 'id', pp.getOptionValue('设置页相关', '账号头像')).click() obj = ObjectMap.getElement(self.driver, "id", pp.getOptionValue('设置页相关', '账号信息')) assert getattr( obj, 'text') == Globalvar.YMS_account, ('账号显示错误' + (getattr(obj, 'text'))) #退出账号 out = Logout.Logout(self.driver) out.logout() #step2 登录外网Outbound账号================================================ l.login_YMS(Globalvar.YMS_account, Globalvar.YMS_password, Globalvar.YMS_server, outbound='183.251.103.228') pp = ParseRepository.ParseRepositoryConfig(Globalvar.config_path) # self.driver.implicitly_wait(5) # 点击展开设置页,验证账号信息 ObjectMap.getElement(self.driver, 'id', pp.getOptionValue('设置页相关', '账号头像')).click() obj = ObjectMap.getElement(self.driver, "id", pp.getOptionValue('设置页相关', '账号信息')) assert getattr( obj, 'text') == Globalvar.YMS_account, ('账号显示错误' + (getattr(obj, 'text'))) # 退出账号 out = Logout.Logout(self.driver) out.logout() #step3 登录无Outbound账号================================================== l.login_YMS(Globalvar.YMS_account, Globalvar.YMS_password, Globalvar.YMS_server, outbound=' ') pp = ParseRepository.ParseRepositoryConfig(Globalvar.config_path) # self.driver.implicitly_wait(5) # 点击展开设置页,验证账号信息 ObjectMap.getElement(self.driver, 'id', pp.getOptionValue('设置页相关', '账号头像')).click() obj = ObjectMap.getElement(self.driver, "id", pp.getOptionValue('设置页相关', '账号信息')) assert getattr( obj, 'text') == Globalvar.YMS_account, ('账号显示错误' + (getattr(obj, 'text'))) # 退出账号 out = Logout.Logout(self.driver) out.logout()
def test_LoginCloud(self): l = LoginPage.Login_start(self.driver,Globalvar.config_path) l.login_Cloud(Globalvar.Cloud_account,Globalvar.Cloud_password,Globalvar.Cloud_server) pp = ParseRepository.ParseRepositoryConfig(Globalvar.config_path) self.driver.implicitly_wait(5) ObjectMap.getElement(self.driver,'id',pp.getOptionValue('设置页相关','账号头像')).click() obj = ObjectMap.getElement(self.driver,"id",pp.getOptionValue('设置页相关','账号信息')) # print(getattr(obj,'text')) # print(is_loginsucess) # assert getattr(obj, 'text') == '1200', '账号显示错误'+getattr(obj,'text') assert getattr(obj,'text')==Globalvar.Cloud_account,('账号显示错误'+(getattr(obj,'text')))
def allcase(): pp = ParseRepository.ParseRepositoryConfig('Config/config.ini') case_dir = pp.getOptionValue('测试用例路径', '用例路径') testcase = unittest.TestSuite() discover = unittest.defaultTestLoader.discover(case_dir, pattern='*.py', top_level_dir=None) # testcase.addTest(discover) #discover方法筛选出来的用例,循环添加到测试套件中 for test_suite in discover: for test_case in test_suite: #添加用例到testcase testcase.addTest(test_case) return testcase
#_*_coding:utf-8_*_ #作者 :wangmf #创建时间 :2018/8/28 20:21 #修改时间 :2018/8/28 #文件 :Logout.py from Config import Globalvar from Util import ObjectMap from Public import ParseRepository,OpenApp pp = ParseRepository.ParseRepositoryConfig(Globalvar.config_path) class Logout: def __init__(self,driver): self.driver = driver def logout(self): #主界面退出账号 ObjectMap.getElement(self.driver,'id',pp.getOptionValue('设置页相关','账号头像')).click() ObjectMap.getElement(self.driver,'id',pp.getOptionValue('设置页相关','云账号')).click() ObjectMap.getElement(self.driver,"id",pp.getOptionValue('云账号界面','注销')).click() ObjectMap.getElement(self.driver, "id", pp.getOptionValue('云账号界面', '确定退出')).click() if __name__ == '__main__': op = OpenApp.OpenVCM() driver = op.Open1() lout = Logout(driver) lout.logout()
def getElement(driver, locateType, locateExpression): try: element = WebDriverWait(driver, 10).until( lambda x: x.find_element(by=locateType, value=locateExpression)) return element except Exception as e: raise e def getElements(driver, locateType, locateExpression): try: elements = WebDriverWait(driver, 10).until( lambda x: x.find_elements(by=locateType, value=locateExpression)) return elements except Exception as e: raise e if __name__ == '__main__': #测试代码 from Public import ParseRepository from Public import OpenApp open = OpenApp.OpenVCM() driver = open.Open1() pp = ParseRepository.ParseRepositoryConfig('../Config/config.ini') search = getElement(driver, "id", pp.getOptionValue('启动页选项', 'YMS服务器')) search.click() search1 = getElement(driver, "id", pp.getOptionValue('YMS_Account', '登录')) search1.send_keys("000055")
def __init__(self, driver, config_path): self.driver = driver self.pp = ParseRepository.ParseRepositoryConfig(config_path)