Compare commits

..

2 Commits

1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
from selenium.webdriver.common.action_chains import ActionChains
import time
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()
time.sleep(1)
# 判断所有高亮单词是否有间隔
highlighteds = driver.find_elements_by_class_name("highlighted")
for highlighted in highlighteds:
assert highlighted.value_of_css_property("padding") == '0px'
time.sleep(5)
finally:
# 测试结束后关闭浏览器
driver.quit()