Fix bug 528
parent
292972c0ce
commit
85a3faaa9f
|
@ -15,8 +15,7 @@
|
||||||
alert('输入不能为空!');
|
alert('输入不能为空!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let reg = /^\S*$/; // 正则表达式,用于匹配不包含空格的字符串
|
if (password.includes(' ')) {
|
||||||
if (!reg.test(password)) {
|
|
||||||
alert('输入不能包含空格!');
|
alert('输入不能包含空格!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
alert('输入不能为空!');
|
alert('输入不能为空!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let reg = /^\S*$/; // 正则表达式,用于匹配不包含空格的字符串
|
if (old_password.includes(' ') || new_password.includes(' ')) {
|
||||||
if (!reg.test(old_password) || !reg.test(new_password)) {
|
|
||||||
alert('输入不能包含空格!');
|
alert('输入不能包含空格!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@ You're logged in already! <a href="/logout">Logout</a>.
|
||||||
alert('输入不能为空!');
|
alert('输入不能为空!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let reg = /^\S*$/; // 正则表达式,用于匹配不包含空格的字符串
|
if (password.includes(' ') || password2.includes(' ')) {
|
||||||
if (!reg.test(password) || !reg.test(password2)) {
|
|
||||||
alert('输入不能包含空格!');
|
alert('输入不能包含空格!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||||
|
from selenium.webdriver.common.keys import Keys
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
# 初始化WebDriver
|
||||||
|
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||||
|
driver.implicitly_wait(10)
|
||||||
|
|
||||||
|
|
||||||
|
# 测试登录页面输入密码包含空格的情况
|
||||||
|
def test_login_password_with_space():
|
||||||
|
try:
|
||||||
|
driver.get("http://121.4.94.30:91/login")
|
||||||
|
|
||||||
|
# 输入用户名
|
||||||
|
username_elem = driver.find_element_by_name('username')
|
||||||
|
username_elem.send_keys("test_user")
|
||||||
|
|
||||||
|
# 输入包含空格的密码
|
||||||
|
password_elem = driver.find_element_by_name('password')
|
||||||
|
password_elem.send_keys("password with space")
|
||||||
|
|
||||||
|
# 提交登录表单
|
||||||
|
password_elem.send_keys(Keys.RETURN)
|
||||||
|
|
||||||
|
# 等待一段时间确保页面加载完成
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
# 检查是否弹出警告框
|
||||||
|
alert = driver.switch_to.alert
|
||||||
|
assert "输入不能包含空格!" in alert.text
|
||||||
|
finally:
|
||||||
|
driver.quit()
|
|
@ -0,0 +1,35 @@
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||||
|
from selenium.webdriver.common.keys import Keys
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
# 初始化WebDriver
|
||||||
|
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||||
|
driver.implicitly_wait(10)
|
||||||
|
|
||||||
|
|
||||||
|
# 测试重设密码页面输入旧密码或新密码包含空格的情况
|
||||||
|
def test_reset_password_with_space():
|
||||||
|
try:
|
||||||
|
driver.get("http://121.4.94.30:91/reset")
|
||||||
|
|
||||||
|
# 输入旧密码
|
||||||
|
old_password_elem = driver.find_element_by_name('old_password')
|
||||||
|
old_password_elem.send_keys("old password with space")
|
||||||
|
|
||||||
|
# 输入新密码
|
||||||
|
new_password_elem = driver.find_element_by_name('new_password')
|
||||||
|
new_password_elem.send_keys("new password with space")
|
||||||
|
|
||||||
|
# 提交重设密码表单
|
||||||
|
new_password_elem.send_keys(Keys.RETURN)
|
||||||
|
|
||||||
|
# 等待一段时间确保页面加载完成
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
# 检查是否弹出警告框
|
||||||
|
alert = driver.switch_to.alert
|
||||||
|
assert "输入不能包含空格!" in alert.text
|
||||||
|
finally:
|
||||||
|
driver.quit()
|
|
@ -0,0 +1,39 @@
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||||
|
from selenium.webdriver.common.keys import Keys
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
# 初始化WebDriver
|
||||||
|
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||||
|
driver.implicitly_wait(10)
|
||||||
|
|
||||||
|
|
||||||
|
# 测试注册页面输入密码包含空格的情况
|
||||||
|
def test_signup_password_with_space():
|
||||||
|
try:
|
||||||
|
driver.get("http://121.4.94.30:91/signup")
|
||||||
|
|
||||||
|
# 输入用户名
|
||||||
|
username_elem = driver.find_element_by_name('username')
|
||||||
|
username_elem.send_keys("new_user")
|
||||||
|
|
||||||
|
# 输入包含空格的密码
|
||||||
|
password_elem = driver.find_element_by_name('password')
|
||||||
|
password_elem.send_keys("password with space")
|
||||||
|
|
||||||
|
# 再次输入密码
|
||||||
|
password2_elem = driver.find_element_by_name('password2')
|
||||||
|
password2_elem.send_keys("password with space")
|
||||||
|
|
||||||
|
# 提交注册表单
|
||||||
|
password2_elem.send_keys(Keys.RETURN)
|
||||||
|
|
||||||
|
# 等待一段时间确保页面加载完成
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
# 检查是否弹出警告框
|
||||||
|
alert = driver.switch_to.alert
|
||||||
|
assert "输入不能包含空格!" in alert.text
|
||||||
|
finally:
|
||||||
|
driver.quit()
|
Loading…
Reference in New Issue