Commit 3eeea1c8 by linguangwei

修改为pytest框架

parent ddf2e2f9
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<option name="ignoredErrors"> <option name="ignoredErrors">
<list> <list>
<option value="N806" /> <option value="N806" />
<option value="N802" />
</list> </list>
</option> </option>
</inspection_tool> </inspection_tool>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -4,12 +4,16 @@ ...@@ -4,12 +4,16 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="00f4febb-36b6-426d-bfe6-b023876a617e" name="Default Changelist" comment="review"> <list default="true" id="00f4febb-36b6-426d-bfe6-b023876a617e" name="Default Changelist" comment="添加测试白板的page和testcase">
<change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/framework/common.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/framework/common.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/pageobject/mainpage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/mainpage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pageobject/basepage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/basepage.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/testcase/testLivePage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/test_LivePage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/testcase/testLoginPage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/testLoginPage.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/testcase/testLoginPage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/test_LoginPage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/testcase/testMainPage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/test_MainPage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/testcase/testWhiteBoardPage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/test_WhiteBoardPage.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -147,7 +151,7 @@ ...@@ -147,7 +151,7 @@
<property name="node.js.selected.package.tslint" value="(autodetect)" /> <property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" /> <property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" /> <property name="settings.editor.selected.configurable" value="project.propVCSSupport.Mappings" />
</component> </component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
...@@ -158,7 +162,7 @@ ...@@ -158,7 +162,7 @@
<recent name="C:\Users\Administrator\PycharmProjects\xm-uitest-live" /> <recent name="C:\Users\Administrator\PycharmProjects\xm-uitest-live" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Python tests.pytest for testWhiteBoardPage.TestLivePage.testWhiteBoard"> <component name="RunManager" selected="Python tests.pytest in test_MainPage.py">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" /> <module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
...@@ -181,23 +185,28 @@ ...@@ -181,23 +185,28 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="pytest for testLivePage.TestLivePage.testWhiteBoard" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true"> <configuration name="test_LoginPage" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" /> <module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" /> <option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/testcase" /> <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/testcase" />
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="_new_keywords" value="&quot;&quot;" /> <option name="SCRIPT_NAME" value="E:\python project\xm-uitest-sow\src\testcase\test_LoginPage.py" />
<option name="_new_parameters" value="&quot;&quot;" /> <option name="PARAMETERS" value="" />
<option name="_new_additionalArguments" value="&quot;&quot;" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="_new_target" value="&quot;testLivePage.TestLivePage.testWhiteBoard&quot;" /> <option name="EMULATE_TERMINAL" value="false" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" /> <option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="pytest for testLoginPage.TestLoginPage.testLogin" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true"> <configuration name="pytest for src.testcase.test_LoginPage.TestLoginPage.testLogin" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" /> <module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -209,11 +218,11 @@ ...@@ -209,11 +218,11 @@
<option name="_new_keywords" value="&quot;&quot;" /> <option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" /> <option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" /> <option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;testLoginPage.TestLoginPage.testLogin&quot;" /> <option name="_new_target" value="&quot;src.testcase.test_LoginPage.TestLoginPage.testLogin&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" /> <option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="pytest for testWhiteBoardPage.TestLivePage.testWhiteBoard" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true"> <configuration name="pytest in test_LoginPage.py" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" /> <module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -225,11 +234,11 @@ ...@@ -225,11 +234,11 @@
<option name="_new_keywords" value="&quot;&quot;" /> <option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" /> <option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" /> <option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;testWhiteBoardPage.TestLivePage.testWhiteBoard&quot;" /> <option name="_new_target" value="&quot;$PROJECT_DIR$/src/testcase/test_LoginPage.py&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" /> <option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="pytest in testLoginPage.py" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true"> <configuration name="pytest in test_MainPage.py" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" /> <module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -241,17 +250,17 @@ ...@@ -241,17 +250,17 @@
<option name="_new_keywords" value="&quot;&quot;" /> <option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" /> <option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" /> <option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/src/testcase/testLoginPage.py&quot;" /> <option name="_new_target" value="&quot;$PROJECT_DIR$/src/testcase/test_MainPage.py&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" /> <option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python tests.pytest for testWhiteBoardPage.TestLivePage.testWhiteBoard" /> <item itemvalue="Python tests.pytest in test_MainPage.py" />
<item itemvalue="Python tests.pytest for testLivePage.TestLivePage.testWhiteBoard" />
<item itemvalue="Python.main" /> <item itemvalue="Python.main" />
<item itemvalue="Python tests.pytest in testLoginPage.py" /> <item itemvalue="Python tests.pytest in test_LoginPage.py" />
<item itemvalue="Python tests.pytest for testLoginPage.TestLoginPage.testLogin" /> <item itemvalue="Python tests.pytest for src.testcase.test_LoginPage.TestLoginPage.testLogin" />
<item itemvalue="Python.test_LoginPage" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
...@@ -351,7 +360,14 @@ ...@@ -351,7 +360,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1624067390535</updated> <updated>1624067390535</updated>
</task> </task>
<option name="localTasksCounter" value="12" /> <task id="LOCAL-00012" summary="添加测试白板的page和testcase">
<created>1624256411294</created>
<option name="number" value="00012" />
<option name="presentableId" value="LOCAL-00012" />
<option name="project" value="LOCAL" />
<updated>1624256411294</updated>
</task>
<option name="localTasksCounter" value="13" />
<servers /> <servers />
</component> </component>
<component name="TestHistory"> <component name="TestHistory">
...@@ -448,6 +464,9 @@ ...@@ -448,6 +464,9 @@
<option name="oldMeFiltersMigrated" value="true" /> <option name="oldMeFiltersMigrated" value="true" />
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<ignored-roots>
<path value="$PROJECT_DIR$/.." />
</ignored-roots>
<MESSAGE value="test test" /> <MESSAGE value="test test" />
<MESSAGE value="just just test" /> <MESSAGE value="just just test" />
<MESSAGE value="rename" /> <MESSAGE value="rename" />
...@@ -455,7 +474,8 @@ ...@@ -455,7 +474,8 @@
<MESSAGE value="登录-开课-结束课程-关闭客户端" /> <MESSAGE value="登录-开课-结束课程-关闭客户端" />
<MESSAGE value="添加转换窗口方法" /> <MESSAGE value="添加转换窗口方法" />
<MESSAGE value="review" /> <MESSAGE value="review" />
<option name="LAST_COMMIT_MESSAGE" value="review" /> <MESSAGE value="添加测试白板的page和testcase" />
<option name="LAST_COMMIT_MESSAGE" value="添加测试白板的page和testcase" />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/server.log" /> <entry file="file://$PROJECT_DIR$/server.log" />
......
import unittest import pytest
from src.framework.HTMLTestRunner import HTMLTestRunner
from src.framework import common from src.framework import common
from src.testcase.testLoginPage import TestLoginPage as TLP
# from src.testcase.testMainPage import TestMainPage as TMP
if __name__ == '__main__': if __name__ == '__main__':
testunit = unittest.TestSuite()
testunit.addTest(TLP('testLogin'))
# testunit.addTests([TMP('test_1_UnStartLive'), TMP('test_2_StartLive'), TMP('test_3_ReviewLive')])
# testunit.addTests([TMP('test_1_UnStartLive')])
# 定义报告输出路径
htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute()) htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute())
with(open(htmlPath, 'wb')) as fp: pytest.main(["-v", '--html={}'.format(htmlPath), './src/testcase/test_MainPage.py'])
runner = HTMLTestRunner(
stream=fp,
title='企培客户端UI自动化测试报告',
description='描述'
)
runner.run(testunit)
...@@ -80,6 +80,6 @@ class MainPage(LoginPage): ...@@ -80,6 +80,6 @@ class MainPage(LoginPage):
def page_down(self, coursename): def page_down(self, coursename):
while True: while True:
self.keys_down() self.keys_down()
ele = EC.presence_of_element_located((By.XPATH, """//div[text()={}]/..//button[@class="ant-btn ant-btn-primary"]""".format(coursename))) ele = EC.presence_of_element_located((By.XPATH, """//div[text()={}]/..//button[@class="ant-btn"]""".format(coursename)))
if ele: if ele:
break break
import time
import pytest
from src.framework.logger import Logger from src.framework.logger import Logger
from src.pageobject.livepage import LivePage from src.pageobject.livepage import LivePage
from src.framework.common import create_a_live from src.framework.common import create_a_live
...@@ -6,14 +10,15 @@ from src.framework.common import screenshot_path, compare_pictures, year_to_minu ...@@ -6,14 +10,15 @@ from src.framework.common import screenshot_path, compare_pictures, year_to_minu
from config import readConfig from config import readConfig
import unittest
import sys import sys
class TestLivePage(unittest.TestCase): class TestLivePage(object):
logger = Logger('live page').getlog() logger = Logger('live page').getlog()
cloud_class_location = readConfig.test_location() cloud_class_location = readConfig.test_location()
time.sleep(15)
live_course_name = create_a_live(start_time=25, start_time2=1) live_course_name = create_a_live(start_time=25, start_time2=1)
# 指定客户端的本地路径,在/config/config.ini配置
driver = get_app_driver(cloud_class_location) driver = get_app_driver(cloud_class_location)
live_page = LivePage(driver=driver) live_page = LivePage(driver=driver)
# 这里停15s是因为setUP里创建直播间获取token登录了一次,限制两次登录需间隔15s # 这里停15s是因为setUP里创建直播间获取token登录了一次,限制两次登录需间隔15s
...@@ -25,15 +30,13 @@ class TestLivePage(unittest.TestCase): ...@@ -25,15 +30,13 @@ class TestLivePage(unittest.TestCase):
live_page.change_window(live_page.camera_btn) live_page.change_window(live_page.camera_btn)
live_page.sleep(5) live_page.sleep(5)
def setUp(self) -> None: def setup_class(self):
# 指定客户端的本地路径,在/config/config.ini配置
pass pass
@classmethod def teardown_class(self):
def tearDownClass(cls) -> None: self.driver.quit()
cls.driver.quit()
# 测试直播间摄像头 测试的时候有个问题,如果摄像头黑屏,检查一下是否开了两个客户端,造成了摄像头抢占 # 测试直播间摄像头 测试的时候如果摄像头黑屏,检查一下是否开了两个客户端,造成了摄像头抢占
def testLiveCamera(self): def testLiveCamera(self):
before_savescreen = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png' before_savescreen = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.live_page.save_screenshot(before_savescreen) self.live_page.save_screenshot(before_savescreen)
...@@ -42,7 +45,7 @@ class TestLivePage(unittest.TestCase): ...@@ -42,7 +45,7 @@ class TestLivePage(unittest.TestCase):
after_savescreen = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png' after_savescreen = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.live_page.save_screenshot(after_savescreen) self.live_page.save_screenshot(after_savescreen)
result = compare_pictures(before_savescreen, after_savescreen) result = compare_pictures(before_savescreen, after_savescreen)
self.assertLessEqual(10, result) assert 10 < result
self.live_page.sleep(3) self.live_page.sleep(3)
# 测试添加白板并打开 # 测试添加白板并打开
...@@ -59,8 +62,8 @@ class TestLivePage(unittest.TestCase): ...@@ -59,8 +62,8 @@ class TestLivePage(unittest.TestCase):
after_whiteboard_savescreen = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png' after_whiteboard_savescreen = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.live_page.save_screenshot(after_whiteboard_savescreen) self.live_page.save_screenshot(after_whiteboard_savescreen)
whiteboard_result = compare_pictures(before_whiteboard_savescreen, after_whiteboard_savescreen) whiteboard_result = compare_pictures(before_whiteboard_savescreen, after_whiteboard_savescreen)
self.assertLessEqual(10, whiteboard_result) assert 10 < whiteboard_result
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(verbosity=1) pytest.main(["-v"])
import pytest
from src.pageobject.loginpage import LoginPage from src.pageobject.loginpage import LoginPage
from src.framework.logger import Logger from src.framework.logger import Logger
from src.framework.appDriver import get_app_driver from src.framework.appDriver import get_app_driver
from config import readConfig from config import readConfig
import unittest
class TestLoginPage(unittest.TestCase): class TestLoginPage(object):
logger = Logger('login page').getlog() logger = Logger('login page').getlog()
account = readConfig.test_account() account = readConfig.test_account()
password = readConfig.test_password() password = readConfig.test_password()
cloud_class_location = readConfig.test_location() cloud_class_location = readConfig.test_location()
def setUp(self) -> None: def setup_class(self):
print(11111)
# 指定客户端的本地路径,在/config/config.ini配置 # 指定客户端的本地路径,在/config/config.ini配置
self.driver = get_app_driver(self.cloud_class_location) self.driver = get_app_driver(self.cloud_class_location)
def tearDown(self) -> None: def teardown_class(self):
self.driver.quit() self.driver.quit()
# 测试登录 # 测试登录
...@@ -31,8 +30,8 @@ class TestLoginPage(unittest.TestCase): ...@@ -31,8 +30,8 @@ class TestLoginPage(unittest.TestCase):
login_page.click_login() login_page.click_login()
login_page.sleep(1) login_page.sleep(1)
# 校验是否存在店铺名称的元素 # 校验是否存在店铺名称的元素
self.assertTrue(login_page.ifElementExist(login_page.store_name)) assert login_page.ifElementExist(login_page.store_name)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(verbosity=1) pytest.main(["-v"])
import time
import pytest
from src.framework.logger import Logger from src.framework.logger import Logger
from src.pageobject.mainpage import MainPage from src.pageobject.mainpage import MainPage
from src.framework.common import create_a_live from src.framework.common import create_a_live
...@@ -5,19 +9,18 @@ from src.framework.appDriver import get_app_driver ...@@ -5,19 +9,18 @@ from src.framework.appDriver import get_app_driver
from config import readConfig from config import readConfig
import unittest
class TestMainPage(unittest.TestCase): class TestMainPage(object):
logger = Logger('main page').getlog() logger = Logger('main page').getlog()
cloud_class_location = readConfig.test_location() cloud_class_location = readConfig.test_location()
time.sleep(15)
live_course_name = create_a_live(start_time=25, start_time2=1) live_course_name = create_a_live(start_time=25, start_time2=1)
def setUp(self) -> None: def setup_method(self):
# 指定客户端的本地路径,在/config/config.ini配置 # 指定客户端的本地路径,在/config/config.ini配置
self.driver = get_app_driver(self.cloud_class_location) self.driver = get_app_driver(self.cloud_class_location)
def tearDown(self) -> None: def teardown_method(self):
self.driver.quit() self.driver.quit()
# 测试主页-进入未开启直播 # 测试主页-进入未开启直播
...@@ -34,7 +37,7 @@ class TestMainPage(unittest.TestCase): ...@@ -34,7 +37,7 @@ class TestMainPage(unittest.TestCase):
main_page.sleep(5) main_page.sleep(5)
main_page.change_window(main_page.camera_btn) main_page.change_window(main_page.camera_btn)
main_page.sleep(2) main_page.sleep(2)
self.assertTrue(main_page.ifElementExist(main_page.camera_btn)) assert main_page.ifElementExist(main_page.camera_btn)
main_page.sleep(3) main_page.sleep(3)
# 测试主页-进入已开启直播 # 测试主页-进入已开启直播
...@@ -63,7 +66,7 @@ class TestMainPage(unittest.TestCase): ...@@ -63,7 +66,7 @@ class TestMainPage(unittest.TestCase):
main_page.stop_live() main_page.stop_live()
main_page.sleep(3) main_page.sleep(3)
main_page.change_window(main_page.live_list) main_page.change_window(main_page.live_list)
self.assertEqual("查看回放", main_page.get_btn_text(self.live_course_name[1])) assert "查看回放" == main_page.get_btn_text(self.live_course_name[1])
main_page.sleep(3) main_page.sleep(3)
# 测试回放 # 测试回放
...@@ -82,4 +85,4 @@ class TestMainPage(unittest.TestCase): ...@@ -82,4 +85,4 @@ class TestMainPage(unittest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(verbosity=1) pytest.main(["-v"])
import time
import pytest
from src.framework.logger import Logger from src.framework.logger import Logger
from src.pageobject.whiteboardpage import WhiteBoardPage from src.pageobject.whiteboardpage import WhiteBoardPage
from src.framework.common import create_a_live from src.framework.common import create_a_live
...@@ -6,13 +10,13 @@ from src.framework.common import screenshot_path, compare_pictures, year_to_minu ...@@ -6,13 +10,13 @@ from src.framework.common import screenshot_path, compare_pictures, year_to_minu
from config import readConfig from config import readConfig
import unittest
import sys import sys
class TestLivePage(unittest.TestCase): class TestLivePage(object):
logger = Logger('live page').getlog() logger = Logger('live page').getlog()
cloud_class_location = readConfig.test_location() cloud_class_location = readConfig.test_location()
time.sleep(15)
live_course_name = create_a_live(start_time=25, start_time2=1) live_course_name = create_a_live(start_time=25, start_time2=1)
driver = get_app_driver(cloud_class_location) driver = get_app_driver(cloud_class_location)
live_page = WhiteBoardPage(driver=driver) live_page = WhiteBoardPage(driver=driver)
...@@ -25,13 +29,12 @@ class TestLivePage(unittest.TestCase): ...@@ -25,13 +29,12 @@ class TestLivePage(unittest.TestCase):
live_page.change_window(live_page.camera_btn) live_page.change_window(live_page.camera_btn)
live_page.sleep(5) live_page.sleep(5)
def setUp(self) -> None: def setup_class(self):
# 指定客户端的本地路径,在/config/config.ini配置 # 指定客户端的本地路径,在/config/config.ini配置
pass pass
@classmethod def teardown_class(self):
def tearDownClass(cls) -> None: self.driver.quit()
cls.driver.quit()
# 测试白板功能-文本输入 # 测试白板功能-文本输入
def testWhiteBoard(self): def testWhiteBoard(self):
...@@ -59,8 +62,8 @@ class TestLivePage(unittest.TestCase): ...@@ -59,8 +62,8 @@ class TestLivePage(unittest.TestCase):
self.live_page.save_screenshot(after_send_wenben) self.live_page.save_screenshot(after_send_wenben)
wenben_result = compare_pictures(before_send_wenben, after_send_wenben) wenben_result = compare_pictures(before_send_wenben, after_send_wenben)
print(wenben_result) print(wenben_result)
self.assertLessEqual(10, wenben_result) assert 10 < wenben_result
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(verbosity=1) pytest.main(["-v"])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment