diff --git a/EnglishPal b/EnglishPal new file mode 160000 index 0000000..8cbc7c9 --- /dev/null +++ b/EnglishPal @@ -0,0 +1 @@ +Subproject commit 8cbc7c9a0ce543db48f80a743c4168ca847ca500 diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index 57461c1..88cfdd6 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -232,6 +232,7 @@ update(data['today_article']); check_pre(data['visited_articles']); check_next(data['result_of_generate_article']); + toggleHighlighting(); } } }); @@ -245,6 +246,7 @@ if(data['today_article']){ update(data['today_article']); check_pre(data['visited_articles']); + toggleHighlighting(); } } }); diff --git a/app/test/conftest.py b/app/test/conftest.py index ed4186c..aefb718 100644 --- a/app/test/conftest.py +++ b/app/test/conftest.py @@ -12,24 +12,5 @@ def URL(): @pytest.fixture def driver(): - return webdriver.Edge() # follow the "End-to-end testing" section in README.md to install the web driver executable - - -@pytest.fixture -def restore_sqlite_database(): - ''' - Automatically restore SQLite database file app/db/wordfreqapp.db - using SQL statements from app/static/wordfreqapp.sql - ''' - con = sqlite3.connect('../db/wordfreqapp.db') - with con: - con.executescript('DROP TABLE IF EXISTS user;') - con.executescript('DROP TABLE IF EXISTS article;') - con.executescript(open('../static/wordfreqapp.sql', encoding='utf8').read()) - con.close() - - -@pytest.fixture(autouse=True) -def restart_englishpal(restore_sqlite_database): - (Path(__file__).parent / '../main.py').touch() - time.sleep(1) + my_driver = webdriver.Chrome() + return my_driver diff --git a/app/test/test_bug555_fangchen.py b/app/test/test_bug555_fangchen.py new file mode 100644 index 0000000..d1edfb5 --- /dev/null +++ b/app/test/test_bug555_fangchen.py @@ -0,0 +1,43 @@ +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 diff --git a/mintty.2024-06-04_11-12-32.png b/mintty.2024-06-04_11-12-32.png new file mode 100644 index 0000000..72ccafe Binary files /dev/null and b/mintty.2024-06-04_11-12-32.png differ