1
0
Fork 0
EnglishPal/app/test/test_reset_password_with_sp...

36 lines
1.1 KiB
Python

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()