summaryrefslogtreecommitdiff
path: root/app/test/test_add_word.py
diff options
context:
space:
mode:
authorHui Lan <lanhui@zjnu.edu.cn>2021-02-08 21:37:45 +0800
committerHui Lan <lanhui@zjnu.edu.cn>2021-02-08 21:37:45 +0800
commita8faa5076643107d4fa8ab408c251a43874a245b (patch)
treee0d31b7dbcd97e2fab6ba8a9ff29a04484f230a7 /app/test/test_add_word.py
parent274470e820ae5c06d4edee4649e1b45f5708e66b (diff)
app/test/test_add_word.py: select a word that does not have punctuation.
Diffstat (limited to 'app/test/test_add_word.py')
-rw-r--r--app/test/test_add_word.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/test/test_add_word.py b/app/test/test_add_word.py
index 0d5356a..4ff5a75 100644
--- a/app/test/test_add_word.py
+++ b/app/test/test_add_word.py
@@ -5,13 +5,16 @@ from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import random, time
+import string
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.CHROME)
HOME_PAGE = 'http://121.4.94.30:91/'
-
+def has_punctuation(s):
+ return [c for c in s if c in string.punctuation] != []
+
def test_add_word():
driver.get(HOME_PAGE)
assert 'English Pal -' in driver.page_source
@@ -41,7 +44,7 @@ def test_add_word():
# click Next
elem = driver.find_element_by_id('selected-words')
word = random.choice(essay_content.split())
- while 'font>' in word or 'br>' in word or 'p>' in word or len(word) < 5:
+ while 'font>' in word or 'br>' in word or 'p>' in word or len(word) < 5 or has_punctuation(word):
word = random.choice(essay_content.split())
elem.send_keys(word)
driver.save_screenshot('./app/test/test_add_word_pic1.png')