forked from mrlan/EnglishPal
Compare commits
2 Commits
Bug546-Lix
...
Bug562-Wuy
Author | SHA1 | Date |
---|---|---|
heyang | 6a0f52e214 | |
李思楠 | 8cbc7c9a0c |
|
@ -1,5 +1,6 @@
|
|||
from flask import *
|
||||
from Login import check_username_availability, verify_user, add_user, get_expiry_date, change_password, WarningMessage
|
||||
from markupsafe import escape
|
||||
|
||||
|
||||
# 初始化蓝图
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# Copyright 2019 (C) Hui Lan <hui.lan@cantab.net>
|
||||
# Written permission must be obtained from the author for commercial uses.
|
||||
###########################################################################
|
||||
from flask import escape
|
||||
from markupsafe import escape
|
||||
from Login import *
|
||||
from Article import *
|
||||
import Yaml
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
''' 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)
|
|
@ -1,6 +1,7 @@
|
|||
from datetime import datetime
|
||||
from admin_service import ADMIN_NAME
|
||||
from flask import *
|
||||
from markupsafe import escape
|
||||
|
||||
# from app import Yaml
|
||||
# from app.Article import get_today_article, load_freq_history
|
||||
|
|
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
Flask==1.1.2
|
||||
Flask==3.0.0
|
||||
selenium==3.141.0
|
||||
PyYAML~=6.0
|
||||
pony==0.7.16
|
||||
|
|
Loading…
Reference in New Issue