From 97ddee0ccff466569a23cde628f2a2826a7aaf35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E4=B9=90=E6=B6=9B?= <1215891603@qq.com> Date: Tue, 4 Jun 2024 16:01:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3te?= =?UTF-8?q?st?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前的pytest文件上传位置错误,现在更改上传到test文件夹中 --- app/test/test_bug536_QianLetao.py | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/test/test_bug536_QianLetao.py diff --git a/app/test/test_bug536_QianLetao.py b/app/test/test_bug536_QianLetao.py new file mode 100644 index 0000000..cce0fe6 --- /dev/null +++ b/app/test/test_bug536_QianLetao.py @@ -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://127.0.0.1:5000/signup") + + # 输入用户名 + username_elem = driver.find_element_by_name('username') + username_elem.send_keys("阿萨德") + + # 输入包含空格的密码 + password_elem = driver.find_element_by_name('password') + password_elem.send_keys("阿萨德阿萨德") + + # 再次输入密码 + password2_elem = driver.find_element_by_name('password2') + password2_elem.send_keys("阿萨德阿萨德") + + # 提交注册表单 + password2_elem.send_keys(Keys.RETURN) + + # 等待一段时间确保页面加载完成 + time.sleep(2) + + # 检查是否弹出警告框 + alert = driver.switch_to.alert + assert "用户名和密码只能包含英文字母和数字!" in alert.text + finally: + driver.quit()