Commit 00c96043 by linguangwei

增加白板的测试用例-7个

parent 3407a9cf
......@@ -6,7 +6,9 @@
<component name="ChangeListManager">
<list default="true" id="00f4febb-36b6-426d-bfe6-b023876a617e" name="Default Changelist" comment="review">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/basepage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/basepage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pageobject/whiteboardpage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/whiteboardpage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/testcase/test_MainPage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/test_MainPage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/testcase/test_WhiteBoardPage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/test_WhiteBoardPage.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
......@@ -161,7 +163,7 @@
</key>
</component>
<component name="RunManager" selected="Python tests.pytest for test_WhiteBoardPage.TestLivePage">
<configuration name="demo" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -173,7 +175,7 @@
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/demo.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
......@@ -182,7 +184,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="pytest for test_LoginPage.TestLoginPage" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<configuration name="pytest for test_MainPage.TestMainPage.test_2_StartLive" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -194,11 +196,11 @@
<option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_LoginPage.TestLoginPage&quot;" />
<option name="_new_target" value="&quot;test_MainPage.TestMainPage.test_2_StartLive&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<configuration name="pytest for test_LoginPage.TestLoginPage.testLogin" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<configuration name="pytest for test_WhiteBoardPage.TestLivePage" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -210,11 +212,11 @@
<option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_LoginPage.TestLoginPage.testLogin&quot;" />
<option name="_new_target" value="&quot;test_WhiteBoardPage.TestLivePage&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<configuration name="pytest for test_WhiteBoardPage.TestLivePage" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<configuration name="pytest for test_WhiteBoardPage.TestLivePage.testAddAndOpenWhiteBoard" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -226,11 +228,11 @@
<option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_WhiteBoardPage.TestLivePage&quot;" />
<option name="_new_target" value="&quot;test_WhiteBoardPage.TestLivePage.testAddAndOpenWhiteBoard&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<configuration name="pytest for test_WhiteBoardPage.TestLivePage.testWhiteBoard" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<configuration name="pytest for test_WhiteBoardPage.TestLivePage.testWhiteBoardText" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -242,17 +244,17 @@
<option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_WhiteBoardPage.TestLivePage.testWhiteBoard&quot;" />
<option name="_new_target" value="&quot;test_WhiteBoardPage.TestLivePage.testWhiteBoardText&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage" />
<item itemvalue="Python.demo" />
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage.testWhiteBoard" />
<item itemvalue="Python tests.pytest for test_LoginPage.TestLoginPage.testLogin" />
<item itemvalue="Python tests.pytest for test_LoginPage.TestLoginPage" />
<item itemvalue="Python.main" />
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage.testAddAndOpenWhiteBoard" />
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage.testWhiteBoardText" />
<item itemvalue="Python tests.pytest for test_MainPage.TestMainPage.test_2_StartLive" />
</list>
</recent_temporary>
</component>
......@@ -464,7 +466,14 @@
<option name="project" value="LOCAL" />
<updated>1625647121753</updated>
</task>
<option name="localTasksCounter" value="28" />
<task id="LOCAL-00028" summary="review">
<created>1625648148936</created>
<option name="number" value="00028" />
<option name="presentableId" value="LOCAL-00028" />
<option name="project" value="LOCAL" />
<updated>1625648148936</updated>
</task>
<option name="localTasksCounter" value="29" />
<servers />
</component>
<component name="TestHistory">
......
......@@ -20,22 +20,22 @@ class Page(object):
self.timeout = 30
# 寻找单元素或唯一元素
def find_element(self, *loc):
def find_element(self, loc):
return self.driver.find_element(*loc)
# 输入元素输入
def input_text(self, loc, text):
try:
self.find_element(*loc).send_keys(text)
self.find_element(loc).send_keys(text)
except Exception:
self.find_elements(*loc)[0].send_keys(text)
self.find_elements(loc)[0].send_keys(text)
# 获取元素文本
def get_text(self, loc):
return self.driver.find_element(*loc).text
return self.driver.find_element(loc).text
# 点击框点击
def click(self, loc):
def click(self, *loc):
self.find_element(*loc).click()
def get_title(self):
......@@ -177,7 +177,8 @@ class Page(object):
# 鼠标键盘操作
# 拖拽元素,从sourse元素开始拖拽(x,y)像素
def drag_mouse(self, source, xoffset, yoffset):
ActionChains(self.driver).drag_and_drop_by_offset(source=source, xoffset=xoffset, yoffset=yoffset).perform()
# ActionChains(self.driver).drag_and_drop_by_offset(source=source, xoffset=xoffset, yoffset=yoffset).perform()
ActionChains(self.driver).click_and_hold(source).move_by_offset(xoffset, yoffset).release().perform()
# 鼠标左键单击
def left_click(self):
......
......@@ -21,8 +21,18 @@ class WhiteBoardPage(MainPage):
huabi = (By.XPATH, """//span[@class="icon iconfont iconhuabi "]""")
# 文本
wenben = (By.XPATH, """//span[@class="icon iconfont iconwenben "]""")
# 直线
zhixian = (By.XPATH, """//span[@class="icon iconfont iconxiantiao "]""")
# 形状
xingzhuang = (By.XPATH, """//span[@class="icon iconfont iconfangxing "]""")
# 移动
yidong = (By.XPATH, """//span[@class="icon iconfont iconyidong "]""")
# 橡皮擦
xiangpica = (By.XPATH, """//span[@class="icon iconfont iconxiangpica "]""")
# 文本输入框
wenben_text = (By.XPATH, """//textarea[@class="editable-textarea my-textarea"]""")
# 文本位置
wenben_location = (By.XPATH, "//div[@class='textarea-container']")
# "进入直播间"按钮 format里面的参数还是要继续修改,先创建课程,再通过课程名称来查看进入直播间按钮
in_live_btn = (By.XPATH, """//div[text()={}]/..//button[@class="ant-btn ant-btn-primary"]""".format("测试新增直播课"))
......@@ -52,10 +62,30 @@ class WhiteBoardPage(MainPage):
def click_wenben(self):
self.click(self.wenben)
# 直线
def click_line(self):
self.click(self.zhixian)
# 形状
def click_block(self):
self.click(self.xingzhuang)
# 移动
def click_move(self):
self.click(self.yidong)
# 橡皮擦
def click_eraser(self):
self.click(self.xiangpica)
def input_wenben(self, text):
self.input_text(self.wenben_text, text=text)
def move_get_wenben(self):
self.mouse_move(100, 100)
def wenben_location_ele(self):
# 不加*会报错
return self.find_element(self.wenben_location)
......@@ -11,9 +11,8 @@ from src.framework.appDriver import get_app_driver
from config import readConfig
@pytest.mark.usefixtures("before_test")
class TestMainPage(object):
@pytest.fixture(scope="module")
@pytest.fixture(scope="module", autouse=True)
def before_test(self):
print("before_test")
self.logger = Logger('main page').getlog()
......@@ -22,7 +21,7 @@ class TestMainPage(object):
time.sleep(15)
return self.cloud_class_location, self.live_course_name
@pytest.fixture(scope="function")
@pytest.fixture(scope="function", autouse=True)
def before_test_case(self, before_test):
print("before_test_case")
# 指定客户端的本地路径,在/config/config.ini配置
......@@ -36,8 +35,6 @@ class TestMainPage(object):
yield self.driver
self.driver.quit()
@pytest.mark.usefixtures("before_test")
@pytest.mark.usefixtures("before_test_case")
@allure.title("测试主页-进入未开启直播")
def test_1_UnStartLive(self):
self.main_page.sleep(self.sleep_time)
......@@ -81,8 +78,7 @@ class TestMainPage(object):
assert "查看回放" == self.main_page.get_btn_text(self.live_course_name[1])
self.main_page.sleep(self.sleep_time)
@pytest.mark.usefixtures("before_test")
@pytest.mark.usefixtures("before_test_case")
# @pytest.mark.skip()
@allure.title("测试主页-进入已开启直播")
def test_2_StartLive(self):
self.enter_start_live()
......@@ -91,8 +87,6 @@ class TestMainPage(object):
self.end_live()
@pytest.mark.skip()
@pytest.mark.usefixtures("before_test")
@pytest.mark.usefixtures("before_test_case")
@allure.title("测试回放")
def test_3_ReviewLive(self):
print(self.live_course_name)
......
......@@ -17,14 +17,15 @@ import sys
class TestLivePage(object):
@pytest.fixture(scope="function")
def before_test_case(self):
cloud_class_location = readConfig.test_location()
driver = get_app_driver(cloud_class_location)
White_Board_page = WhiteBoardPage(driver=driver)
@pytest.fixture(scope="module", autouse=True)
def before_test(self):
self.logger = Logger('live page').getlog()
cloud_class_location = readConfig.test_location()
time.sleep(15)
live_course_name = create_a_live(start_time=25, start_time2=1)
self.driver = get_app_driver(cloud_class_location)
self.White_Board_page = WhiteBoardPage(driver=self.driver)
# 这里停15s是因为setUP里创建直播间获取token登录了一次,限制两次登录需间隔15s
self.White_Board_page.sleep(15)
self.White_Board_page.login()
......@@ -34,26 +35,41 @@ class TestLivePage(object):
self.White_Board_page.sleep(5)
self.White_Board_page.change_window(self.White_Board_page.camera_btn)
self.White_Board_page.sleep(5)
@pytest.yield_fixture(scope="module", autouse=True)
def after_test(self):
yield self.driver
self.driver.quit()
@allure.title("测试白板功能-文本输入")
@pytest.mark.usefixtures("before_test_case")
def testWhiteBoard(self):
@allure.title("测试白板功能-新增白板")
def testAddAndOpenWhiteBoard(self):
self.White_Board_page.click_white_board()
self.White_Board_page.sleep(2)
self.White_Board_page.click_add_white_board()
self.White_Board_page.click_camera_btn()
self.White_Board_page.sleep(1)
before_open_white_board = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(before_open_white_board)
get_allure_screenshots(before_open_white_board, "打开白板前截图")
self.White_Board_page.click_open_white_board()
self.White_Board_page.sleep(1)
after_open_white_board = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(after_open_white_board)
get_allure_screenshots(after_open_white_board, "打开白板后截图")
result = compare_pictures(before_open_white_board, after_open_white_board)
print(result)
assert 10 < result
@allure.title("测试白板功能-文本输入")
def testWhiteBoardText(self):
self.White_Board_page.sleep(1)
self.White_Board_page.click_wenben()
self.White_Board_page.sleep(3)
# 切换iframe前后都要点击一次才能生效,神奇
self.White_Board_page.move_get_wenben()
self.White_Board_page.switch_to_iframe("webview")
self.White_Board_page.move_get_wenben()
print(self.White_Board_page.ifElementExist(self.White_Board_page.wenben_text))
# print(self.White_Board_page.ifElementExist(self.White_Board_page.wenben_text))
self.White_Board_page.sleep(1)
before_send_wenben = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(before_send_wenben)
......@@ -64,9 +80,104 @@ class TestLivePage(object):
after_send_wenben = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(after_send_wenben)
get_allure_screenshots(after_send_wenben, "输入文本框字符后截图")
wenben_result = compare_pictures(before_send_wenben, after_send_wenben)
print(wenben_result)
assert 10 < wenben_result
result = compare_pictures(before_send_wenben, after_send_wenben)
print(result)
assert 10 < result
@allure.title("测试白板功能-画笔")
def testWhiteBoardPen(self):
self.White_Board_page.sleep(1)
self.White_Board_page.switch_to_current()
self.White_Board_page.click_huabi()
self.White_Board_page.switch_to_iframe("webview")
before_drap_huabi = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(before_drap_huabi)
get_allure_screenshots(before_drap_huabi, "点击画笔前截图")
self.White_Board_page.sleep(1)
self.White_Board_page.drag_mouse(self.White_Board_page.wenben_location_ele(), 200, 200)
self.White_Board_page.sleep(1)
after_drap_huabi = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(after_drap_huabi)
get_allure_screenshots(after_drap_huabi, "点击画笔后截图")
result = compare_pictures(before_drap_huabi, after_drap_huabi)
print(result)
assert 10 < result
@allure.title("测试白板功能-直线")
def testWhiteBoardLine(self):
self.White_Board_page.sleep(1)
self.White_Board_page.switch_to_current()
self.White_Board_page.click_zhixian()
self.White_Board_page.switch_to_iframe("webview")
before_drap_zhixian = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(before_drap_zhixian)
get_allure_screenshots(before_drap_zhixian, "点击直线前截图")
self.White_Board_page.sleep(1)
self.White_Board_page.drag_mouse(self.White_Board_page.wenben_location_ele(), 200, 200)
self.White_Board_page.sleep(1)
after_drap_zhixian = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(after_drap_zhixian)
get_allure_screenshots(after_drap_zhixian, "点击直线后截图")
result = compare_pictures(before_drap_zhixian, after_drap_zhixian)
print(result)
assert 10 < result
@allure.title("测试白板功能-形状")
def testWhiteBoardBlock(self):
self.White_Board_page.sleep(1)
self.White_Board_page.switch_to_current()
self.White_Board_page.click_block()
self.White_Board_page.switch_to_iframe("webview")
before_drap_xingzhuang = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(before_drap_xingzhuang)
get_allure_screenshots(before_drap_xingzhuang, "点击形状前截图")
self.White_Board_page.sleep(1)
self.White_Board_page.drag_mouse(self.White_Board_page.wenben_location_ele(), 200, 200)
self.White_Board_page.sleep(1)
after_drap_xingzhuang = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(after_drap_xingzhuang)
get_allure_screenshots(after_drap_xingzhuang, "点击形状后截图")
result = compare_pictures(before_drap_xingzhuang, after_drap_xingzhuang)
print(result)
assert 10 < result
@allure.title("测试白板功能-移动")
def testWhiteBoardMove(self):
self.White_Board_page.sleep(1)
self.White_Board_page.switch_to_current()
self.White_Board_page.click_move()
self.White_Board_page.switch_to_iframe("webview")
before_drap_yidong = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(before_drap_yidong)
get_allure_screenshots(before_drap_yidong, "点击移动前截图")
self.White_Board_page.sleep(1)
self.White_Board_page.drag_mouse(self.White_Board_page.wenben_location_ele(), 200, 200)
self.White_Board_page.sleep(1)
after_drap_yidong = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(after_drap_yidong)
get_allure_screenshots(after_drap_yidong, "点击移动后截图")
result = compare_pictures(before_drap_yidong, after_drap_yidong)
print(result)
assert 10 < result
@allure.title("测试白板功能-橡皮擦")
def testWhiteBoardBlock(self):
self.White_Board_page.sleep(1)
self.White_Board_page.switch_to_current()
self.White_Board_page.click_eraser()
self.White_Board_page.switch_to_iframe("webview")
before_drap_xiangpica = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(before_drap_xiangpica)
get_allure_screenshots(before_drap_xiangpica, "点击橡皮擦前截图")
self.White_Board_page.sleep(1)
self.White_Board_page.drag_mouse(self.White_Board_page.wenben_location_ele(), 200, 200)
self.White_Board_page.sleep(1)
after_drap_xiangpica = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(after_drap_xiangpica)
get_allure_screenshots(after_drap_xiangpica, "点击橡皮擦后截图")
result = compare_pictures(before_drap_xiangpica, after_drap_xiangpica)
print(result)
assert 10 < result
if __name__ == '__main__':
......
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