过程测试开发

selenium_页面(status code)状态码校验

2016-08-09  本文已影响1420人  古佛青灯度流年

代码中:

@classmethod      
def get_status_code(cls, modules_path=None):
    u'''获取到当前页面链接,校验返回状态码:若成功或者重定向,返回True,否则False'''    
 now_url = cls.driver.current_url       
 r = requests.get(now_url+modules_path).status_code    
 code = {        400,        401,        402,        403,        404,        405,        406,        407,        408,        409,        410,        411,        412,        413,        414,        415,        416,        417,        418,        422,        423,        424,        425,        426,        428,        429,        431,        449,        450,        500,        501,        502,        503,        504,        505,        507,        508,        509,        510,        511    }    
 for f in code:        
    if f != r:
        return True
    else:
        return False
@classmethod
def Processing_page_state(cls, msg):
u'''    处理页面返回状态码,若状态码=True,则通过,否则抛出异常
:param msg:
:return:    '''
if Operation.get_status_code(modules_path=None):
    pass
else:
    raise customError(msg)
上一篇 下一篇

猜你喜欢

热点阅读