diff options
-rw-r--r-- | app/test/test_add_word.py | 7 |
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') |