我有一些必须通过 Selenium 测试的 jQuery 验证代码。但是,每次我运行测试时,不同的失败和不同的通过。例如,在一次测试中,密码太短会失败,密码太长会通过。但是,如果我重新运行测试,可能会发生相反的情况!
这是正则表达式:
var password = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*(_|[-+_!@#$%^&*.,?])).{6,20}$/;
这是jQuery:
if($('#password').val() ==""){
$('#passwordErrorMsg').text("Your password must be between 6 and 20 characters. It must contain a mixture of upper and lower case letters, and at least one number or symbol.");
}
else if(password.test($('#password').val())){
$('#passwordErrorMsg').text("OK");
}
else($('#passwordErrorMsg').text("Your password must be between 6 and 20 characters. It must contain a mixture of upper and lower case letters, and at least one number or symbol."));
});
通过 Selenium 测试的任何帮助都会有所帮助和感激,谢谢。