From 4b185df84fe756032f3c5c8cd0f1fd10f82b6472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 00:53:26 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=87=B3=20app/test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化了一下方晨同学的测试代码 --- app/test/test_bug555_chenshiying.py | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/test/test_bug555_chenshiying.py diff --git a/app/test/test_bug555_chenshiying.py b/app/test/test_bug555_chenshiying.py new file mode 100644 index 0000000..c7187f7 --- /dev/null +++ b/app/test/test_bug555_chenshiying.py @@ -0,0 +1,34 @@ +import pytest +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.common.action_chains import ActionChains + +@pytest.fixture() +def driver(): + # 初始化Chrome WebDriver + driver = webdriver.Chrome() + driver.maximize_window() + yield driver + # 测试结束后关闭浏览器 + driver.quit() + +def test_bug555(driver): + base_url = "http://127.0.0.1:5000" + driver.get(base_url) + + # 定位文章元素并对其执行操作 + article = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'article'))) + ActionChains(driver).move_to_element(article).click_and_hold().move_by_offset(450, 200).release().perform() + print("Performed actions on article.") + + # 导航到下一篇文章 + next_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_next_article'))) + next_button.click() + print("Clicked next article button.") + + # 返回上一篇文章 + prev_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_pre_article'))) + prev_button.click() + print("Clicked previous article button.") \ No newline at end of file -- 2.17.1 From d414eaa14454bca90e4b42efa8017fa3683752d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 00:59:11 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E5=88=A0=E9=99=A4=20app/test/test=5Fbug5?= =?UTF-8?q?55=5Fchenshiying.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/test/test_bug555_chenshiying.py | 34 ----------------------------- 1 file changed, 34 deletions(-) delete mode 100644 app/test/test_bug555_chenshiying.py diff --git a/app/test/test_bug555_chenshiying.py b/app/test/test_bug555_chenshiying.py deleted file mode 100644 index c7187f7..0000000 --- a/app/test/test_bug555_chenshiying.py +++ /dev/null @@ -1,34 +0,0 @@ -import pytest -from selenium import webdriver -from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.common.action_chains import ActionChains - -@pytest.fixture() -def driver(): - # 初始化Chrome WebDriver - driver = webdriver.Chrome() - driver.maximize_window() - yield driver - # 测试结束后关闭浏览器 - driver.quit() - -def test_bug555(driver): - base_url = "http://127.0.0.1:5000" - driver.get(base_url) - - # 定位文章元素并对其执行操作 - article = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'article'))) - ActionChains(driver).move_to_element(article).click_and_hold().move_by_offset(450, 200).release().perform() - print("Performed actions on article.") - - # 导航到下一篇文章 - next_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_next_article'))) - next_button.click() - print("Clicked next article button.") - - # 返回上一篇文章 - prev_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_pre_article'))) - prev_button.click() - print("Clicked previous article button.") \ No newline at end of file -- 2.17.1 From bb838ad51adb808b2d63f798a86da1380e9b6f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 00:59:50 +0800 Subject: [PATCH 03/12] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化了一下方晨同学的测试代码 --- app/test/test_bug555_chenshiying.py | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/test/test_bug555_chenshiying.py diff --git a/app/test/test_bug555_chenshiying.py b/app/test/test_bug555_chenshiying.py new file mode 100644 index 0000000..c7187f7 --- /dev/null +++ b/app/test/test_bug555_chenshiying.py @@ -0,0 +1,34 @@ +import pytest +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.common.action_chains import ActionChains + +@pytest.fixture() +def driver(): + # 初始化Chrome WebDriver + driver = webdriver.Chrome() + driver.maximize_window() + yield driver + # 测试结束后关闭浏览器 + driver.quit() + +def test_bug555(driver): + base_url = "http://127.0.0.1:5000" + driver.get(base_url) + + # 定位文章元素并对其执行操作 + article = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'article'))) + ActionChains(driver).move_to_element(article).click_and_hold().move_by_offset(450, 200).release().perform() + print("Performed actions on article.") + + # 导航到下一篇文章 + next_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_next_article'))) + next_button.click() + print("Clicked next article button.") + + # 返回上一篇文章 + prev_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_pre_article'))) + prev_button.click() + print("Clicked previous article button.") \ No newline at end of file -- 2.17.1 From aa8d8b75e0f108b685b511a448c656a154b6b9c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 01:57:59 +0800 Subject: [PATCH 04/12] fix --- app/test/test_bug555_chenshiying.py | 77 ++++++++++++++++------------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/app/test/test_bug555_chenshiying.py b/app/test/test_bug555_chenshiying.py index c7187f7..d1edfb5 100644 --- a/app/test/test_bug555_chenshiying.py +++ b/app/test/test_bug555_chenshiying.py @@ -1,34 +1,43 @@ -import pytest -from selenium import webdriver -from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.common.action_chains import ActionChains - -@pytest.fixture() -def driver(): - # 初始化Chrome WebDriver - driver = webdriver.Chrome() - driver.maximize_window() - yield driver - # 测试结束后关闭浏览器 - driver.quit() - -def test_bug555(driver): - base_url = "http://127.0.0.1:5000" - driver.get(base_url) - - # 定位文章元素并对其执行操作 - article = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'article'))) - ActionChains(driver).move_to_element(article).click_and_hold().move_by_offset(450, 200).release().perform() - print("Performed actions on article.") - - # 导航到下一篇文章 - next_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_next_article'))) - next_button.click() - print("Clicked next article button.") - - # 返回上一篇文章 - prev_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_pre_article'))) - prev_button.click() - print("Clicked previous article button.") \ No newline at end of file +import time +import pytest +import uuid +from selenium import webdriver +from selenium.webdriver import ActionChains +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from selenium.common.exceptions import UnexpectedAlertPresentException, NoAlertPresentException, NoSuchElementException, \ + TimeoutException +from conftest import URL +driver = webdriver.Chrome() +def test_bug555(): + try: + driver.maximize_window() + base_url = "http://127.0.0.1:5000" + driver.get(base_url) + article = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'article'))) + perform_actions_on_article(driver, article) + + next_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_next_article'))) + next_button.click() + print("Clicked next article button.") + + prev_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_pre_article'))) + prev_button.click() + print("Clicked previous article button.") + + except (TimeoutException, NoSuchElementException) as e: + print(f"An error occurred: {e}") + + finally: + driver.quit() + print("Driver closed.") + +def perform_actions_on_article(driver, article): + actions = ActionChains(driver) + actions.move_to_element(article) + actions.click_and_hold() + actions.move_by_offset(450, 200) + actions.release() + actions.perform() + print("Performed actions on article.") \ No newline at end of file -- 2.17.1 From 29627ec87a7d10eecfc7f24294ef3cf8b1af3042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 01:58:26 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20app/test/conftest.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/test/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/test/conftest.py b/app/test/conftest.py index 29f6431..8050f9a 100644 --- a/app/test/conftest.py +++ b/app/test/conftest.py @@ -9,5 +9,6 @@ def URL(): @pytest.fixture def driver(): - my_driver = webdriver.Edge() # uncomment this line if you wish to run the test on your laptop + my_driver = webdriver.Chrome() return my_driver + -- 2.17.1 From a56c16cc6b960996b7797fdf3653a41e16522609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 01:58:48 +0800 Subject: [PATCH 06/12] update --- app/test/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/test/conftest.py b/app/test/conftest.py index 8050f9a..418ced7 100644 --- a/app/test/conftest.py +++ b/app/test/conftest.py @@ -12,3 +12,4 @@ def driver(): my_driver = webdriver.Chrome() return my_driver + -- 2.17.1 From 7fbccd554a3ee2255a7eed0206dd1f76e431587e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 01:59:59 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20app/test/=5F=5Fpycac?= =?UTF-8?q?he=5F=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/test/__pycache__ | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/test/__pycache__ diff --git a/app/test/__pycache__ b/app/test/__pycache__ new file mode 100644 index 0000000..e69de29 -- 2.17.1 From 7b74a970c7db977e17ce198963c88a8155c67534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 02:02:00 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E5=88=A0=E9=99=A4=20app/test/=5F=5Fpycac?= =?UTF-8?q?he=5F=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/test/__pycache__ | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/test/__pycache__ diff --git a/app/test/__pycache__ b/app/test/__pycache__ deleted file mode 100644 index e69de29..0000000 -- 2.17.1 From b518dab6c93b07d9174921445f1f7d375afd17d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 02:03:25 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20app/test/=5F=5Fpycac?= =?UTF-8?q?he=5F=5F/1.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/test/__pycache__/1.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 app/test/__pycache__/1.txt diff --git a/app/test/__pycache__/1.txt b/app/test/__pycache__/1.txt new file mode 100644 index 0000000..ae99406 --- /dev/null +++ b/app/test/__pycache__/1.txt @@ -0,0 +1 @@ +czxcx \ No newline at end of file -- 2.17.1 From 3bde0b01560abcf8779b530907d30270718b2a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 02:03:50 +0800 Subject: [PATCH 10/12] fix --- app/test/__pycache__/conftest.cpython-310.pyc | Bin 0 -> 554 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/test/__pycache__/conftest.cpython-310.pyc diff --git a/app/test/__pycache__/conftest.cpython-310.pyc b/app/test/__pycache__/conftest.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ee4f40d88eccf45953a8eaf45f70b44daab89136 GIT binary patch literal 554 zcmY*VO-sWt7=DvxT{pH}#DCzyUb;>YVTcIbQFc&dC+0$s|Qr-;yVJn()5Q^JM*g7i8Ujl&fO|@To|%3`s8K5(+3#6oapJ9HRvL7^$-n z8wv3V0tR<2N@(i^o{?{AX41B1ZHjKdw!UN+nA)i7Y}u0X=$>&&4kk=QoKbI)FP2dp z6%iAmdf6BHf=DDv@eI666VT=|X0r>^V116Pms@O|WsgPCAl1cL5p z989up8fObCf-p;01rvpnmz6QQzG|rvSOUS^l-oZYN`t!7I(qU@z$gPC7PB Date: Tue, 25 Jun 2024 02:04:04 +0800 Subject: [PATCH 11/12] fix --- app/test/__pycache__/1.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 app/test/__pycache__/1.txt diff --git a/app/test/__pycache__/1.txt b/app/test/__pycache__/1.txt deleted file mode 100644 index ae99406..0000000 --- a/app/test/__pycache__/1.txt +++ /dev/null @@ -1 +0,0 @@ -czxcx \ No newline at end of file -- 2.17.1 From 6733ed9f86ccc7899447d5dec98fee840fe3a583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E8=A9=A9=E7=A9=8E?= <1325912020@qq.com> Date: Tue, 25 Jun 2024 02:34:59 +0800 Subject: [PATCH 12/12] fix --- app/templates/userpage_get.html | 124 ++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 54 deletions(-) diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index 0488aea..e75b036 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -108,7 +108,7 @@

{{ today_article['question'] }}


- - - + \ No newline at end of file -- 2.17.1