Beispiel #1
0
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
Beispiel #2
0
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