signup in unit test
parent
4fe96cfc9c
commit
498639a753
|
@ -15,16 +15,6 @@ def driver():
|
|||
return webdriver.Edge() # uncomment this line if you wish to run the test on your laptop
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def UNAME():
|
||||
return 'lanhui'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def PASSWORD():
|
||||
return 'l0ve1t'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def restore_sqlite_database():
|
||||
'''
|
||||
|
|
|
@ -4,6 +4,8 @@ from selenium.webdriver.common.by import By
|
|||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
|
||||
from app.test.helper import signup
|
||||
|
||||
|
||||
def has_punctuation(s):
|
||||
return any(c in string.punctuation for c in s)
|
||||
|
@ -27,9 +29,9 @@ def select_valid_word(driver):
|
|||
return valid_word
|
||||
|
||||
|
||||
def test_save_selected_word(driver, URL, UNAME, PASSWORD):
|
||||
def test_save_selected_word(driver, URL):
|
||||
try:
|
||||
login(driver, URL, UNAME, PASSWORD)
|
||||
username, password = signup(URL, driver)
|
||||
word = select_valid_word(driver)
|
||||
stored_words = driver.execute_script('return localStorage.getItem("selectedWords");')
|
||||
assert word == stored_words, "Selected word not saved to localStorage correctly"
|
||||
|
@ -44,12 +46,8 @@ def test_save_selected_word(driver, URL, UNAME, PASSWORD):
|
|||
driver.execute_script("window.open('');")
|
||||
driver.switch_to.window(driver.window_handles[-1]) # 切换到新打开的标签页
|
||||
|
||||
login(driver, URL, UNAME, PASSWORD)
|
||||
login(driver, URL, username, password)
|
||||
textarea_content = driver.find_element(By.ID, 'selected-words').get_attribute('value')
|
||||
assert word == textarea_content, "Selected word not preserved after re-login"
|
||||
finally:
|
||||
driver.quit()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_save_selected_word(driver, URL, UNAME, PASSWORD) # noqa: F821
|
||||
|
|
Loading…
Reference in New Issue