def exec_script(driver, testpage, teststep, testdata): #定义测试用例执行函数状态标志位 exec_script = True try: #登录功能测试 if testpage == '登录': url = driver.current_url login = LoginPage(driver, url) if teststep == '用户名': login.input_user(testdata) # logger.info('输入用户名{}'.format(testdata)) if teststep == '密码': login.input_pwd(testdata) # logger.info('输入密码{}'.format(testdata)) if teststep == '登录': login.login() time.sleep(3) if testpage == '注册': pass if testpage == '主页': time.sleep(2) url = driver.current_url mainpage = MainPage(driver, url) if teststep == '退出': mainpage.exit_sys() time.sleep(2) if testpage == '其他主页': pass except: exec_script = False return exec_script
def exec_script(driver,testpage,teststep,testdata): # 定义测试用例执行函数状态标志位 exec_script = True try: # 登录功能测试 if testpage == "登录": url = driver.current_url url = GetUrl(url)+'login' if driver.current_url != url: driver.get(url) login = LoginPage(driver,testdata) if teststep == '用户名': login.input_username(testdata) if teststep == '密码': login.input_password(testdata) if teststep == '登录': login.click_submit() time.sleep(5) if testpage == "主页": time.sleep(3) url = driver.current_url major = MainPage(driver,url) if teststep == '退出': userid = major.show_userid() major.exit_sys(driver) time.sleep(3) if testpage == "其他主页": pass except: exec_script =False url = GetUrl(driver.current_url) driver.get(url) return exec_script
def exec_script(driver, testpage, teststep, testdata): #定义测试用例执行函数状态标志位 exec_script = True try: #登陆功能测试 if testpage == '登录': url = driver.current_url url = geturl(url) + 'user.php' if driver.current_url != url: driver.get(url) login = LoginPage(driver, testdata) if teststep == '用户名': login.input_username(testdata) if teststep == '密码': login.input_password(testdata) if teststep == '登录': login.click_submit() time.sleep(5) #注册功能测试 if testpage == '注册': url = driver.current_url url = geturl(url) + 'user.php?act=register' if driver.current_url != url: driver.get(url) userreg = RegistePage(driver, testdata) if teststep == '用户名': userreg.input_username(testdata) if teststep == 'email': userreg.input_email(testdata) if teststep == '密码': userreg.input_password(testdata) if teststep == '确认密码': userreg.input_comfirpwd(testdata) time.sleep(8) if teststep == '注册': userreg.click_submit() time.sleep(5) if testpage == '主页': time.sleep(3) url = driver.current_url mainpage = MainPage(driver, url) if teststep == '退出': mainpage.exit_sys() time.sleep(3) if testpage == '其他主页': pass except: exec_script = False url = geturl(driver.current_url) driver.get(url) return exec_script