我将tangxinyuan小组的测试文件改了一下,只是改了一下点击按钮的方法,将点击退出按钮,使用ActionChains去点击,因为我测试的时候,用driver去点击大部分会报出'退出'的按钮被浏览器拦截的错误,
parent
64a82bee22
commit
101c359596
|
@ -1,5 +1,8 @@
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
import time
|
||||||
|
|
||||||
|
from selenium.webdriver import ActionChains
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
@ -36,7 +39,8 @@ def test_save_selected_word(driver, URL):
|
||||||
stored_words = driver.execute_script('return localStorage.getItem("selectedWords");')
|
stored_words = driver.execute_script('return localStorage.getItem("selectedWords");')
|
||||||
assert word == stored_words, "Selected word not saved to localStorage correctly"
|
assert word == stored_words, "Selected word not saved to localStorage correctly"
|
||||||
# 退出并重新登录以检查存储的单词
|
# 退出并重新登录以检查存储的单词
|
||||||
driver.find_element(By.LINK_TEXT, '退出').click()
|
action_chains = ActionChains(driver)
|
||||||
|
action_chains.click(driver.find_element(By.LINK_TEXT, '退出')).perform()
|
||||||
driver.execute_script("window.open('');window.close();")
|
driver.execute_script("window.open('');window.close();")
|
||||||
|
|
||||||
# 等待一会儿,让浏览器有足够的时间关闭标签页
|
# 等待一会儿,让浏览器有足够的时间关闭标签页
|
||||||
|
|
Loading…
Reference in New Issue