1
0
Fork 0
EnglishPal/app/test/test_bug547_fanwenqi.py

29 lines
1.1 KiB
Python

from webdriver_helper import get_webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = get_webdriver()
driver.get('http://127.0.0.1:5000')
uname = "jxt"
password = "123456"
# def login(uname, password):
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, '登录'))).click()
driver.find_element(By.ID, 'username').send_keys(uname)
driver.find_element(By.ID, 'password').send_keys(password)
driver.find_element(By.XPATH, '//button[text()="登录"]').click()
WebDriverWait(driver, 10).until(EC.title_is(f"EnglishPal Study Room for {uname}"))
article = driver.find_element('xpath','//*[@id="article"]')
range_input = driver.find_element('xpath','//*[@id="rangeComponent"]')
# 使用 ActionChains 类来拖动 range input 元素
action_chains = ActionChains(driver)
action_chains.click_and_hold(article).move_by_offset(500, 0).release().perform()
action_chains.click_and_hold(range_input).move_by_offset(50, 0).release().perform()
input()