上传文件至 app/test
parent
d3d7b87e62
commit
024a1dbb61
|
@ -1,35 +1,15 @@
|
||||||
import pytest
|
|
||||||
from selenium import webdriver
|
|
||||||
from selenium.webdriver.common.action_chains import ActionChains
|
from selenium.webdriver.common.action_chains import ActionChains
|
||||||
import time
|
from helper import signup
|
||||||
from webdriver_manager.chrome import ChromeDriverManager
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def driver():
|
def test_highlight(driver, URL):
|
||||||
# 初始化浏览器驱动
|
try:
|
||||||
driver = webdriver.Chrome(ChromeDriverManager().install())
|
# 打开网页
|
||||||
|
driver.get(URL)
|
||||||
driver.maximize_window()
|
driver.maximize_window()
|
||||||
|
|
||||||
yield driver
|
# 注册
|
||||||
# 测试结束后关闭浏览器
|
signup(URL, driver)
|
||||||
driver.quit()
|
|
||||||
|
|
||||||
def test_highlight(driver):
|
|
||||||
# 打开网页
|
|
||||||
driver.get("http://127.0.0.1:5000/")
|
|
||||||
|
|
||||||
# login
|
|
||||||
elem = driver.find_element_by_link_text('登录')
|
|
||||||
elem.click()
|
|
||||||
uname = 'lxf'
|
|
||||||
password = 'kklo567'
|
|
||||||
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_class_name('btn') # 找到登录按钮
|
|
||||||
elem.click()
|
|
||||||
|
|
||||||
# 取消勾选“划词入库按钮”
|
# 取消勾选“划词入库按钮”
|
||||||
highlight_checkbox = driver.find_element_by_id("test1")
|
highlight_checkbox = driver.find_element_by_id("test1")
|
||||||
|
@ -51,4 +31,9 @@ def test_highlight(driver):
|
||||||
actions.release()
|
actions.release()
|
||||||
# 执行操作链
|
# 执行操作链
|
||||||
actions.perform()
|
actions.perform()
|
||||||
time.sleep(10)
|
# time.sleep(10)
|
||||||
|
|
||||||
|
assert driver.find_element_by_tag_name("mark") is not None
|
||||||
|
finally:
|
||||||
|
# 测试结束后关闭浏览器
|
||||||
|
driver.quit()
|
Loading…
Reference in New Issue