2024-04-12 20:19:51 +08:00
|
|
|
from selenium.webdriver.common.action_chains import ActionChains
|
|
|
|
import time
|
2024-05-19 18:27:54 +08:00
|
|
|
from helper import signup
|
|
|
|
|
|
|
|
def test_highlight(driver, URL):
|
|
|
|
try:
|
|
|
|
# 打开网页
|
|
|
|
driver.maximize_window()
|
|
|
|
driver.get(URL)
|
|
|
|
|
|
|
|
# 注册
|
|
|
|
time.sleep(1)
|
|
|
|
signup(URL, driver)
|
|
|
|
time.sleep(2)
|
|
|
|
|
|
|
|
# 选中单词(移动鼠标到起点位置、按下鼠标左键、拖动鼠标到结束位置、释放鼠标左键、执行操作链)
|
|
|
|
article = driver.find_element_by_id("article")
|
|
|
|
actions = ActionChains(driver)
|
|
|
|
actions.move_to_element(article).click_and_hold().move_by_offset(450,60).release().perform()
|
2024-05-20 23:45:03 +08:00
|
|
|
time.sleep(1)
|
2024-05-19 18:27:54 +08:00
|
|
|
|
|
|
|
# 判断所有高亮单词是否有间隔
|
|
|
|
marks = driver.find_elements_by_tag_name("mark")
|
|
|
|
for mark in marks:
|
|
|
|
assert mark.value_of_css_property("padding") == '0px'
|
2024-05-20 23:45:03 +08:00
|
|
|
time.sleep(5)
|
2024-05-19 18:27:54 +08:00
|
|
|
finally:
|
|
|
|
# 测试结束后关闭浏览器
|
|
|
|
driver.quit()
|
|
|
|
|