From ecefeb69b8561f05408ec7fb1de8cfc68fd9f110 Mon Sep 17 00:00:00 2001 From: aya Date: Sun, 16 Jun 2024 17:09:14 +0800 Subject: [PATCH] test script and helper function --- .../conftest.cpython-312-pytest-8.1.1.pyc | Bin 0 -> 886 bytes app/test/__pycache__/helper.cpython-312.pyc | Bin 0 -> 2645 bytes ...test_add_word.cpython-312-pytest-8.1.1.pyc | Bin 0 -> 5747 bytes ...st_bug543_aya.cpython-312-pytest-8.1.1.pyc | Bin 0 -> 6211 bytes ...t_delete_word.cpython-312-pytest-8.1.1.pyc | Bin 0 -> 4663 bytes app/test/conftest.py | 2 +- app/test/helper.py | 48 +++++++++ app/test/test_bug543_aya.py | 93 ++++++++++++++++++ 8 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 app/test/__pycache__/conftest.cpython-312-pytest-8.1.1.pyc create mode 100644 app/test/__pycache__/helper.cpython-312.pyc create mode 100644 app/test/__pycache__/test_add_word.cpython-312-pytest-8.1.1.pyc create mode 100644 app/test/__pycache__/test_bug543_aya.cpython-312-pytest-8.1.1.pyc create mode 100644 app/test/__pycache__/test_delete_word.cpython-312-pytest-8.1.1.pyc create mode 100644 app/test/helper.py create mode 100644 app/test/test_bug543_aya.py diff --git a/app/test/__pycache__/conftest.cpython-312-pytest-8.1.1.pyc b/app/test/__pycache__/conftest.cpython-312-pytest-8.1.1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e12907f0ce8793a697747aed637a424cb5c83b64 GIT binary patch literal 886 zcmZ`%PiqrF6rb5mHk-650b3ylL#U^Kq-jBgAXp*sdr< zEcy}h0ra5wQM~x)pez&%dhsBnRiIBccs2CrQtx zojO1tPE}*^KR)RTKKT$=wBI74S;0|uk92M7JRua6OZNzKD6tz>V09hW;SOQF^Q&T{ zf|#d(O%Y^Lnom~-oCo!_we^jg)f#;3_3O1-?LDHJ@DxEOj~aDzhY`w5D}>M74$F*> zZAfpn%Qwt+Yujwm(UA1GdADniU31IdbsaWnS*~dXfyoKuW^d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ogJF9 zV?MHwm`mIX6rBCjwiOPCtJAo;Wv+hB$eOBGdB>gR8FztiD)Oacb`{(EG zrN&vTY0_$%iZyLoP22Rq3Sa%<(0fC-{c9Ykvfr`iZSFkh{_AlCs6M*fIhePddju#` z_0N3O8iVI2kIjHT@CeYXbCt8?s~Tr~Gu?S>%QDxxYI8hUW3gdF>BIN;{ed$_&US(y zSl|A$F0f>0@M6hjJL_eZ+G!$pP(=2Y^qr=`eaup?b+}~m!?7>SySqk|Y!1bc2UqI!3&~qQ0`W1xkgZ6cUhjPN> G*!njfY)?M` literal 0 HcmV?d00001 diff --git a/app/test/__pycache__/test_add_word.cpython-312-pytest-8.1.1.pyc b/app/test/__pycache__/test_add_word.cpython-312-pytest-8.1.1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0ca6104d2ca601c6dc4eaeb7a180d097dcab4843 GIT binary patch literal 5747 zcmdTITWlN0agQ(E@pZH*(V}fRl&wUf9g&hHKcrTM<;ZT*LXI27t*b~NPTZ4t5?|dr zS|UpVMvww>pujSaKsM^4Y0(cC{z(fI2wD^dZtO~>R8-0}vR+=*Fe{dp$L-J_Fd!;H!;iZhr< z7exXc|ClICM8q!$Sz$&>N{S@Pg}n(y$qq-O$xK{GCNi=zJP1#85l0ibnS0b%g+Ps@ z|8Rd~Ffue48R#1x>W{{2Drkz>p|!&A!3Aj6P!WxxD@@!nhvJs$T?mz!BBN-8w3)A& zS04c6B9fVvK#{p>Sqa*JtHjKqg<}X!0M2OrMHFVvhApZ?R*00IQ(f6yIp>&(8E_>7@j&Wi$tCh^6)n`o)5`N4uio{6QQG16X(XK&XLT#7+0o7XK*e# zbviwll;p%YAvq;vvr~#FD_Rp1Fpe!|2##d)DxVPKm}ynwhShxVlY5}Kgtm6I|H(DD z+IemC$AQhxfpX`-?Y#qUj^1_+zHceJhSzPw{{~!Uf%v<-x^3ULb=%^A*Pj-^G$+0d zeqTczGP#V7H#~|SugDY)Ov%jUXkdXZYy~PZ7g5Plw8%eK;0#os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@iXkZhIb6JgP&SD zItTz zS%Wz4k=&!;G${Jyk`!|?cZ|Z$yn?8(uY}-z&Xjb*wa1PgqWB)5#-T|kq{PXmd~bM@ z!r&T)00B{b^rV33RL?{y1x9$@QyYZ|k0^V*fh-_w&?OQL3@T(j}Lqc=}oKNa0|C{}ZL+B{#nGoDiIwzB>lW&p zKqlW8;!XBgy*n@(Y;)LVLY1ka+I@M2HMS^RRxuzL?!m>@aY@2h* zmK|}f8&+c|e$(`t>5ZaqruE6fvWQUsVIS!$Cx0z3>)W8URwTga1q9;$sX4^`E5El#E%6}&-#s%TF}x^1`+ zj7(LqsseqTs81lO*e`Rtd;xe47J8@)n9%1GcL2GkWfd^lKw%hvR literal 0 HcmV?d00001 diff --git a/app/test/__pycache__/test_delete_word.cpython-312-pytest-8.1.1.pyc b/app/test/__pycache__/test_delete_word.cpython-312-pytest-8.1.1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..128a278f8d5c2e78beea590eb4d76f4fde3784b0 GIT binary patch literal 4663 zcmdTITWs6bmDH1zWJ!)=C30d%-WDuO7RmA}wbv92GN)^|q;7(Ao1%cAMcSr9k=!L^ zSsDcdML!&%LsMWwP#_=s*vE?e^ke(kFkoN%*^gCwQ@~}|fVBwn7a+qP`P#Xpu1LFD z6AVFt(K63D_nvd^d0t-f_d`Q53a;CC)YX4SDe7;SAXlh|JoyD6cPNn(X@x4$4h+klELZvW`X97y37A-{`Jg6`=w!}I(t;9+(M|VgdN+~H-og||k6vOvumx47TrC~Ap4plnPq&emh9=^oUHrtR^L?mxW2#AqyN`{Oi z@w}i5E3zV+vShT5uA8R5SSTo3MNrl?!(5z&tI!Y&>-CjKI7+QdkEJ+W%+KZ*X7e*s ziwng<#a-LILlCJT{6F~>gM-FWW`DMd$M;<(2{Pq#fo}VyBKt&uY||EH(Hm4dU{uI3q{~rrNtnYSPk6kt>=?T?B&Ol)wf0rnJF?~O%u$6_j>3CWn_Ii4|p5| z^Ws1}MSh6^R(w`MrNJK0+W|5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gi! zf4;brns-@}x01K(V2>j{U~Y4l$vJbUI;m6JUt8KqUGV9C$eizfA-|8A^M8*}!-u-* zVkcev=;TiN>{j>_CfQ}iJIwg@#4EoI?=lx4z+Gmd!%S=+o7-jP?;p(GdHwy@w^+yV zL9uy|&g{|XDEK^$>Cro}_hVb(hsb>}__>YGE^=`yPo*H;JetY@! zn<1(b%Dg!i${&M29$A{DtKq>Sx+@3No*EHxj=@s-HAo2GQ zV;OFbgEUS5lc8w(9qJF%#Gk2452=wqQA3YoRBUW3+hwyIHoHCc()QxT?&8(X;?*7Y it(%eiRHRE~I#lL1+NH*Tcj)*{_DSS8ok8CQrT+ow#lC$2 literal 0 HcmV?d00001 diff --git a/app/test/conftest.py b/app/test/conftest.py index af17368..86e39f3 100644 --- a/app/test/conftest.py +++ b/app/test/conftest.py @@ -9,5 +9,5 @@ def URL(): @pytest.fixture def driver(): - my_driver = webdriver.Chrome() + my_driver = webdriver.Chrome() or Edge() return my_driver diff --git a/app/test/helper.py b/app/test/helper.py new file mode 100644 index 0000000..a6991d0 --- /dev/null +++ b/app/test/helper.py @@ -0,0 +1,48 @@ +import uuid +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from selenium.common.exceptions import UnexpectedAlertPresentException, NoAlertPresentException +from selenium.webdriver.common.by import By + +def signup(URL, driver): + username = 'TestUser' + str(uuid.uuid1()).split('-')[0].title() + password = '[Abc+123]' + + driver.get(URL) + + try: + # Click the register link + register_link = WebDriverWait(driver, 10).until( + EC.element_to_be_clickable((By.LINK_TEXT, '注册')) + ) + register_link.click() + + # Fill the registration form + username_field = WebDriverWait(driver, 10).until( + EC.presence_of_element_located((By.ID, 'username')) + ) + username_field.send_keys(username) + + password_field = driver.find_element(By.ID, 'password') + password_field.send_keys(password) + + confirm_password_field = driver.find_element(By.ID, 'password2') + confirm_password_field.send_keys(password) + + # Click the register button + register_button = driver.find_element(By.CLASS_NAME, 'btn') + register_button.click() + + # Handle possible alert + try: + WebDriverWait(driver, 1).until(EC.alert_is_present()) + alert = driver.switch_to.alert + alert.accept() + except (UnexpectedAlertPresentException, NoAlertPresentException): + pass + + return username, password + + except Exception as e: + print(f"An error occurred: {e}") + return None, None \ No newline at end of file diff --git a/app/test/test_bug543_aya.py b/app/test/test_bug543_aya.py new file mode 100644 index 0000000..82ed698 --- /dev/null +++ b/app/test/test_bug543_aya.py @@ -0,0 +1,93 @@ +import random +import string +import time + +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC + +from helper import signup + +def has_punctuation(s): + return any(c in string.punctuation for c in s) + +def login(driver, home, uname, password): + driver.get(home) + 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}")) + + +def select_valid_word(driver): + elem = driver.find_element(By.ID, 'text-content') + essay_content = elem.text + valid_word = random.choice([word for word in essay_content.split() if len(word) >= 6 and not has_punctuation( + word) and 'font>' not in word and 'br>' not in word and 'p>' not in word]) + driver.find_element(By.ID, 'selected-words').send_keys(valid_word) + return valid_word + + +def select_more_words(driver): + elem = driver.find_element(By.ID, 'text-content') + essay_content = elem.text + valid_words = [word for word in essay_content.split() if len(word) >= 6 and not has_punctuation( + word) and 'font>' not in word and 'br>' not in word and 'p>' not in word] + words_to_send = ', '.join(valid_words[:7]) + driver.find_element(By.ID, 'selected-words').send_keys(words_to_send) + + +def test_get_user_level(driver, URL): + try: + username, password = signup(URL, driver) + time.sleep(5) + + word = select_valid_word(driver) + + # Wait for the button to be clickable + time.sleep(10) + # Add selected word to the list of words + add_words_button = driver.find_element(By.XPATH, '//button[text()="把生词加入我的生词库"]') + add_words_button.click() + # Wait for the page to update + time.sleep(3) + + add_words_button = driver.find_element(By.XPATH, '//button[text()="加入我的生词簿"]') # Replace with actual ID or selector + add_words_button.click() + # Wait for the page to update again + time.sleep(2) + + # Check if the added word appears in the word container + word_container = driver.find_element(By.CLASS_NAME, 'word-container') + words = word_container.find_elements(By.TAG_NAME, 'p') + added_word_exists = any(word.text == word for word in words) + time.sleep(2) + + + #add new words + word = select_more_words(driver) + add_button = driver.find_element(By.XPATH, '//button[text()="把生词加入我的生词库"]') + add_button.click() + + time.sleep(5) + + #add the words to the list of words + add_words_again = driver.find_element(By.XPATH, '//button[text()="加入我的生词簿"]') # Replace with actual ID or selector + add_words_again.click() + # Wait for the page to update again + time.sleep(3) + + + # compare user level + + + # Log out and close the browser + driver.find_element(By.XPATH, '//a[contains(@class, "btn-secondary") and text()="退出"]') + driver.execute_script("window.open('');window.close();") + WebDriverWait(driver, 2) + driver.execute_script("window.open('');") + driver.switch_to.window(driver.window_handles[-1]) + + finally: + driver.quit() \ No newline at end of file