Compare commits

..

23 Commits

Author SHA1 Message Date
丁晟晔 d8e4fbbb2d Merge pull request 'Bug551-DingZeYu' (#114) from Bug551-DingZeYu into Alpha-snapshot20230621
Reviewed-on: #114
2024-05-20 16:12:25 +08:00
Lan Hui a4db1edffb Close the web browswer after finishing each test case 2024-05-20 13:28:23 +08:00
丁晟晔 49ead93bcb 更新 app/test/test_bug551_DingZeYu.py 2024-05-20 08:24:36 +08:00
丁晟晔 9afd38a09a 更新 app/test/test_bug551_DingZeYu.py 2024-05-20 08:21:02 +08:00
丁晟晔 d97743649a 更新 app/test/test_bug551_DingZeYu.py 2024-05-19 22:51:32 +08:00
丁晟晔 9f6a007426 更新 app/test/test_bug551_DingZeYu.py 2024-05-19 21:21:25 +08:00
丁晟晔 7fe3feae9a 更新 app/test/test_bug551_DingZeYu.py 2024-05-18 09:23:36 +08:00
丁晟晔 b2a53a0e40 更新 app/test/test_bug551_DingZeYu.py 2024-05-18 09:18:22 +08:00
丁晟晔 0301c39cf0 更新 app/test/test_bug551_DingZeYu.py 2024-05-18 09:14:05 +08:00
丁晟晔 5857395251 更新 app/test/test_bug551_DingZeYu.py 2024-05-18 09:08:10 +08:00
丁晟晔 77ed63441b 更新 app/static/css/bootstrap.css 2024-05-14 23:26:53 +08:00
丁晟晔 b19eabd225 更新 app/static/config.yml 2024-05-14 23:26:11 +08:00
丁晟晔 b9d0ad4a15 上传文件至 app/static/css 2024-05-14 23:24:26 +08:00
丁晟晔 aca827a912 更新 app/static/css/bootstrap.css 2024-05-14 23:24:06 +08:00
丁晟晔 23f0dfd8ca 更新 app/test/test_bug551_DingZeYu.py
我这边好像没有helper文件所以我直接判断有没有这个账号,如果没有就注册一个来进行测试。这样子可以吗
2024-05-12 13:39:14 +08:00
丁晟晔 6ee94d1610 上传文件至 app/test 2024-05-06 11:48:19 +08:00
丁晟晔 416f40222e 删除 app/test/test_bug551_DingZeYu.py 2024-05-06 11:46:39 +08:00
丁晟晔 66f5c28ead 上传文件至 app/test 2024-05-06 11:46:15 +08:00
丁晟晔 c9c0ef60d8 Merge branch 'Alpha-snapshot20230621' into Bug551-DingZeYu 2024-05-06 11:34:44 +08:00
丁晟晔 393264a6fe 更新 app/static/js/highlight.js 2024-04-19 10:51:18 +08:00
丁晟晔 d5c76674da 更新 app/static/css/bootstrap.css 2024-04-19 10:50:43 +08:00
丁晟晔 b8222c951b revert 4120e7e54b
revert Fix bug 551
2024-04-19 10:49:41 +08:00
dingchengye 4120e7e54b Fix bug 551 2024-04-19 10:06:48 +08:00
4 changed files with 46 additions and 3 deletions

View File

@ -2,7 +2,7 @@
css: css:
item: item:
- ../static/css/bootstrap.css - ../static/css/bootstrap.css
- ../static/css/highlighted.css
# 全局引入的js文件地址 # 全局引入的js文件地址
js: js:
head: # 在页面加载之前加载 head: # 在页面加载之前加载

View File

@ -0,0 +1,5 @@
.highlighted {
color: red;
font-weight: normal;
}

View File

@ -43,11 +43,12 @@ function highLight() {
// 删除所有的mark标签,防止标签发生嵌套 // 删除所有的mark标签,防止标签发生嵌套
articleContent = articleContent.replace(/<(mark)[^>]*>/gi, ""); articleContent = articleContent.replace(/<(mark)[^>]*>/gi, "");
articleContent = articleContent.replace(/<(\/mark)[^>]*>/gi, ""); articleContent = articleContent.replace(/<(\/mark)[^>]*>/gi, "");
// 将文章中所有出现该单词word的地方改为"<mark>" + word + "<mark>"。 // 将文章中所有出现该单词word的地方改为"<span class='highlighted'>" + word + "</span>"。
for (let word of totalSet) { for (let word of totalSet) {
articleContent = articleContent.replace(new RegExp("\\b" + word + "\\b", "g"), "<mark>" + word + "</mark>"); articleContent = articleContent.replace(new RegExp("\\b" + word + "\\b", "g"), "<span class='highlighted'>" + word + "</span>");
} }
document.getElementById("article").innerHTML = articleContent; document.getElementById("article").innerHTML = articleContent;
} }
function cancelHighlighting() { function cancelHighlighting() {

View File

@ -0,0 +1,37 @@
import time
import pytest
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from helper import signup
def test_bug551(driver, URL):
driver.maximize_window()
driver.get(URL)
username, password = signup(URL, driver)
article = driver.find_element(By.ID, 'article')
actions = ActionChains(driver)
actions.move_to_element(article)
actions.click_and_hold()
actions.move_by_offset(450, 200)
actions.release()
actions.perform()
# 获取选中高亮部分的单词的元素
highlighted_words = driver.find_elements(By.CLASS_NAME, 'highlighted')
# 验证选中部分的单词是否同时应用了需求样式
expected_font_weight = "400"
for word in highlighted_words:
font_weight = word.value_of_css_property("font-weight")
assert font_weight == expected_font_weight, f"选中部分的单词的字体样式错误"
time.sleep(5)
driver.quit()