From d2d383f21aab311985c6b63262709490c69efc29 Mon Sep 17 00:00:00 2001 From: xiongjiaming <3190186054@qq.com> Date: Mon, 3 Jun 2024 14:03:27 +0800 Subject: [PATCH] Fix bug 540 --- app/test/test_next_article.py | 85 ----------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 app/test/test_next_article.py diff --git a/app/test/test_next_article.py b/app/test/test_next_article.py deleted file mode 100644 index 3e470de..0000000 --- a/app/test/test_next_article.py +++ /dev/null @@ -1,85 +0,0 @@ -''' Contributed by Lin Junhong et al. 2023-06.''' - -from selenium import webdriver -from selenium.webdriver.common.desired_capabilities import DesiredCapabilities - -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC -from selenium.common.exceptions import UnexpectedAlertPresentException, NoAlertPresentException -import random, time -import string - -# 初始化webdriver -# driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.CHROME) -# driver.implicitly_wait(10) -driver = webdriver.Chrome("C:\\Users\\12993\AppData\Local\Programs\Python\Python38\\chromedriver.exe") - - -def test_next_article(): - try: - driver.get("http://118.25.96.118:90") - assert 'English Pal -' in driver.page_source - # login - elem = driver.find_element_by_link_text('登录') - elem.click() - - uname = 'abcdefg' - password = 'abcdefg' - elem = driver.find_element_by_id('username') - elem.send_keys(uname) - - elem = driver.find_element_by_id('password') - elem.send_keys(password) - elem = driver.find_element_by_xpath('/html/body/div/button') # 找到登录按钮 - elem.click() - - time.sleep(0.5) - assert 'EnglishPal Study Room for ' + uname in driver.title - for i in range(50): - time.sleep(0.1) - # 找到固定按钮 - elem = driver.find_element_by_xpath('//*[@id="load_next_article"]') - elem.click() - except Exception as e: - print(e) - - -def test_local_next_article(): - try: - driver.get("http://127.0.0.1:5000") - assert 'English Pal -' in driver.page_source - # login - elem = driver.find_element_by_link_text('注册') - elem.click() - - uname = 'abcdefg' - password = 'abcdefg' - elem = driver.find_element_by_id('username') - elem.send_keys(uname) - - elem = driver.find_element_by_id('password') - elem.send_keys(password) - - elem = driver.find_element_by_id('password2') - elem.send_keys(password) - - time.sleep(0.5) - - elem = driver.find_element_by_class_name('btn') # 找到提交按钮 - elem.click() - time.sleep(0.5) - try: - WebDriverWait(driver, 1).until(EC.alert_is_present()) - driver.switch_to.alert.accept() - except (UnexpectedAlertPresentException, NoAlertPresentException): - pass - - time.sleep(0.5) - assert 'EnglishPal Study Room for ' + uname in driver.title - for i in range(50): - time.sleep(0.1) - # 找到固定按钮 - elem = driver.find_element_by_xpath('//*[@id="load_next_article"]') - elem.click() - except Exception as e: - print(e)