From 3f200e538416ebb5e635a4c8d6d6581493e73732 Mon Sep 17 00:00:00 2001 From: heyang <951513216@qq.com> Date: Thu, 30 May 2024 21:19:28 +0800 Subject: [PATCH] Fixed Bug 562 --- app/test/test_bug562_Wuyichen.py | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 app/test/test_bug562_Wuyichen.py diff --git a/app/test/test_bug562_Wuyichen.py b/app/test/test_bug562_Wuyichen.py new file mode 100644 index 0000000..fdaebec --- /dev/null +++ b/app/test/test_bug562_Wuyichen.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Run the docker image using the following command: +# docker run -d -p 4444:4444 selenium/standalone-chrome +from selenium import webdriver +from selenium.webdriver.common.desired_capabilities import DesiredCapabilities + +import random, string, time + +driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX) +driver.implicitly_wait(10) + +HOME_PAGE = 'http://121.4.94.30:91/' + +def test_generate_article(): + try: + driver.get(HOME_PAGE) + assert 'English Pal -' in driver.page_source + + # login + elem = driver.find_element_by_link_text('登录') + elem.click() + + uname = 'lanhui' + password = 'l0ve1t' + elem = driver.find_element_by_name('username') + elem.send_keys(uname) + + elem = driver.find_element_by_name('password') + elem.send_keys(password) + + elem = driver.find_element_by_xpath('//form[1]/p[3]/input[1]') # 找到登录按钮 + elem.click() + + assert 'EnglishPal Study Room for ' + uname in driver.title + + # get initial essay content + driver.save_screenshot('./app/test/test_generate_article_pic0.png') + elem = driver.find_element_by_id('text-content') + initial_essay_content = elem.text + + # generate article + driver.save_screenshot('./app/test/test_generate_article_pic1.png') + elem = driver.find_element_by_link_text('下一篇') + elem.click() + + # get generated essay content + driver.save_screenshot('./app/test/test_generate_article_pic2.png') + elem = driver.find_element_by_id('text-content') + generated_essay_content = elem.text + + assert generated_essay_content != initial_essay_content # Check if a new article is generated + + finally: + driver.quit()