Commit 5f70970d by linguangwei

发送钉钉测试报告,本机作为服务器

parent 00c96043
...@@ -4,11 +4,10 @@ ...@@ -4,11 +4,10 @@
<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="增加白板的测试用例-7个">
<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$/src/pageobject/basepage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/basepage.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.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/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" /> <change beforePath="$PROJECT_DIR$/src/testcase/test_WhiteBoardPage.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" />
...@@ -35,6 +34,11 @@ ...@@ -35,6 +34,11 @@
<filtered-out-file-type name="COMMIT_BY_MESSAGE" /> <filtered-out-file-type name="COMMIT_BY_MESSAGE" />
</file-type-list> </file-type-list>
</component> </component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/main.py" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/src/framework/dingTalk.py" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/src/testcase/test_WhiteBoardPage.py" root0="FORCE_HIGHLIGHTING" />
</component>
<component name="IdeDocumentHistory"> <component name="IdeDocumentHistory">
<option name="CHANGED_PATHS"> <option name="CHANGED_PATHS">
<list> <list>
...@@ -162,8 +166,8 @@ ...@@ -162,8 +166,8 @@
<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 test_WhiteBoardPage.TestLivePage"> <component name="RunManager" selected="Python.main">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="demo" 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" />
...@@ -175,7 +179,7 @@ ...@@ -175,7 +179,7 @@
<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="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/demo.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
...@@ -184,39 +188,49 @@ ...@@ -184,39 +188,49 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="pytest for test_MainPage.TestMainPage.test_2_StartLive" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true"> <configuration name="dingTalk" 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/framework" />
<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="$PROJECT_DIR$/src/framework/dingTalk.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;test_MainPage.TestMainPage.test_2_StartLive&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 test_WhiteBoardPage.TestLivePage" type="tests" factoryName="py.test" 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="" />
<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$" />
<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="$PROJECT_DIR$/main.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;test_WhiteBoardPage.TestLivePage&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 test_WhiteBoardPage.TestLivePage.testAddAndOpenWhiteBoard" 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" /> <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" />
...@@ -228,11 +242,11 @@ ...@@ -228,11 +242,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;test_WhiteBoardPage.TestLivePage.testAddAndOpenWhiteBoard&quot;" /> <option name="_new_target" value="&quot;test_WhiteBoardPage.TestLivePage&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 test_WhiteBoardPage.TestLivePage.testWhiteBoardText" 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" /> <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" />
...@@ -244,17 +258,17 @@ ...@@ -244,17 +258,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;test_WhiteBoardPage.TestLivePage.testWhiteBoardText&quot;" /> <option name="_new_target" value="&quot;test_WhiteBoardPage.TestLivePage.testAddAndOpenWhiteBoard&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>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage" />
<item itemvalue="Python.main" /> <item itemvalue="Python.main" />
<item itemvalue="Python.dingTalk" />
<item itemvalue="Python.demo" />
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage" />
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage.testAddAndOpenWhiteBoard" /> <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> </list>
</recent_temporary> </recent_temporary>
</component> </component>
...@@ -473,7 +487,14 @@ ...@@ -473,7 +487,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1625648148936</updated> <updated>1625648148936</updated>
</task> </task>
<option name="localTasksCounter" value="29" /> <task id="LOCAL-00029" summary="增加白板的测试用例-7个">
<created>1625735563148</created>
<option name="number" value="00029" />
<option name="presentableId" value="LOCAL-00029" />
<option name="project" value="LOCAL" />
<updated>1625735563148</updated>
</task>
<option name="localTasksCounter" value="30" />
<servers /> <servers />
</component> </component>
<component name="TestHistory"> <component name="TestHistory">
...@@ -590,7 +611,8 @@ ...@@ -590,7 +611,8 @@
<MESSAGE value="增加了调试中的切换环境方法" /> <MESSAGE value="增加了调试中的切换环境方法" />
<MESSAGE value="请求头添加enterpriseId,并且设置各个请求头参数为变量,在config.ini中设置" /> <MESSAGE value="请求头添加enterpriseId,并且设置各个请求头参数为变量,在config.ini中设置" />
<MESSAGE value="review" /> <MESSAGE value="review" />
<option name="LAST_COMMIT_MESSAGE" value="review" /> <MESSAGE value="增加白板的测试用例-7个" />
<option name="LAST_COMMIT_MESSAGE" value="增加白板的测试用例-7个" />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/server.log" /> <entry file="file://$PROJECT_DIR$/server.log" />
......
import pytest import pytest
import os import os
from src.framework import dingTalk
from src.framework import common from src.framework import common
if __name__ == '__main__': if __name__ == '__main__':
htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute()) htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute())
pytest.main(["-v", '--alluredir={}'.format(htmlPath), './src/testcase/test_WhiteBoardPage.py', "--durations=0"]) pytest.main(["-v", '--alluredir={}'.format(htmlPath), './src/testcase/test_WhiteBoardPage.py', "--durations=0"])
os.system('allure generate {} -o ./report/output --clean'.format(htmlPath)) os.system('allure generate {} -o ./report/output --clean'.format(htmlPath))
# os.system('allure open report/output')
dingTalk.alert()
os.system("python -m http.server 63342 -d ./report/output")
# # 定义报告输出路径 # # 定义报告输出路径
# htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute()) # htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute())
...@@ -17,4 +21,3 @@ if __name__ == '__main__': ...@@ -17,4 +21,3 @@ if __name__ == '__main__':
# description='描述' # description='描述'
# ) # )
# runner.run(testunit) # runner.run(testunit)
import time
import requests
import json
def alert():
# 获取当前日期
tile = time.strftime("%Y-%m-%d %H:%M:%S")
url = "https://oapi.dingtalk.com/robot/send"
querystring = {"access_token": "8f7f39c8872c67f25ddadcfd95f86a69593a1e060cf69dc92b5981827d401383"} # 钉钉机器人url里面的token值
data = {
"msgtype": "markdown", # 发送类型:text/markdown
"markdown": {
"title": "uitest报告", # 需要和机器人设置的关键字相对于 否则不会推送到消息
"text": "### 代码质量检测报告 \n\n **项目名称:**测试markdown样式项目 \n\n **项目地址:**[点击跳转详情](http://10.0.1.109:63342/index.html) \n\n **检测分支:** master \n\n **bug数量:**3 \n\n **相关人员:**@测试 \n\n **播报时间:** %s" % tile,
"at": {
"atMobiles": [
"" # 如果需要@某人,这里写他的手机号  这块暂时没有触发 还在研究
],
"isAtAll": 0 # 如果需要@所有人,这些写1
}
}
}
json_str = json.dumps(data) # 需要将类型转换为json类型
headers = {
'content-type': "application/json"
}
response = requests.request("POST", url, data=json_str, headers=headers, params=querystring)
print(response)
print(response.text)
if __name__ == '__main__':
alert()
"https://oapi.dingtalk.com/robot/send?access_token=8f7f39c8872c67f25ddadcfd95f86a69593a1e060cf69dc92b5981827d401383"
...@@ -24,7 +24,7 @@ class WhiteBoardPage(MainPage): ...@@ -24,7 +24,7 @@ class WhiteBoardPage(MainPage):
# 直线 # 直线
zhixian = (By.XPATH, """//span[@class="icon iconfont iconxiantiao "]""") zhixian = (By.XPATH, """//span[@class="icon iconfont iconxiantiao "]""")
# 形状 # 形状
xingzhuang = (By.XPATH, """//span[@class="icon iconfont iconfangxing "]""") xingzhuang = (By.XPATH, """//span[@class="icon iconfont iconfangxing "]""")
# 移动 # 移动
yidong = (By.XPATH, """//span[@class="icon iconfont iconyidong "]""") yidong = (By.XPATH, """//span[@class="icon iconfont iconyidong "]""")
# 橡皮擦 # 橡皮擦
...@@ -62,19 +62,19 @@ class WhiteBoardPage(MainPage): ...@@ -62,19 +62,19 @@ class WhiteBoardPage(MainPage):
def click_wenben(self): def click_wenben(self):
self.click(self.wenben) self.click(self.wenben)
# 直线 # 点击直线
def click_line(self): def click_line(self):
self.click(self.zhixian) self.click(self.zhixian)
# 形状 # 点击形状
def click_block(self): def click_block(self):
self.click(self.xingzhuang) self.click(self.xingzhuang)
# 移动 # 点击移动
def click_move(self): def click_move(self):
self.click(self.yidong) self.click(self.yidong)
# 橡皮擦 # 点击橡皮擦
def click_eraser(self): def click_eraser(self):
self.click(self.xiangpica) self.click(self.xiangpica)
......
...@@ -35,12 +35,10 @@ class TestLivePage(object): ...@@ -35,12 +35,10 @@ class TestLivePage(object):
self.White_Board_page.sleep(5) self.White_Board_page.sleep(5)
self.White_Board_page.change_window(self.White_Board_page.camera_btn) self.White_Board_page.change_window(self.White_Board_page.camera_btn)
self.White_Board_page.sleep(5) self.White_Board_page.sleep(5)
@pytest.yield_fixture(scope="module", autouse=True)
def after_test(self):
yield self.driver yield self.driver
self.driver.quit() self.driver.quit()
@pytest.mark.run(order=1)
@allure.title("测试白板功能-新增白板") @allure.title("测试白板功能-新增白板")
def testAddAndOpenWhiteBoard(self): def testAddAndOpenWhiteBoard(self):
self.White_Board_page.click_white_board() self.White_Board_page.click_white_board()
...@@ -60,6 +58,7 @@ class TestLivePage(object): ...@@ -60,6 +58,7 @@ class TestLivePage(object):
print(result) print(result)
assert 10 < result assert 10 < result
@pytest.mark.run(order=2)
@allure.title("测试白板功能-文本输入") @allure.title("测试白板功能-文本输入")
def testWhiteBoardText(self): def testWhiteBoardText(self):
self.White_Board_page.sleep(1) self.White_Board_page.sleep(1)
...@@ -84,6 +83,7 @@ class TestLivePage(object): ...@@ -84,6 +83,7 @@ class TestLivePage(object):
print(result) print(result)
assert 10 < result assert 10 < result
# @pytest.mark.skip()
@allure.title("测试白板功能-画笔") @allure.title("测试白板功能-画笔")
def testWhiteBoardPen(self): def testWhiteBoardPen(self):
self.White_Board_page.sleep(1) self.White_Board_page.sleep(1)
...@@ -103,11 +103,12 @@ class TestLivePage(object): ...@@ -103,11 +103,12 @@ class TestLivePage(object):
print(result) print(result)
assert 10 < result assert 10 < result
# @pytest.mark.skip()
@allure.title("测试白板功能-直线") @allure.title("测试白板功能-直线")
def testWhiteBoardLine(self): def testWhiteBoardLine(self):
self.White_Board_page.sleep(1) self.White_Board_page.sleep(1)
self.White_Board_page.switch_to_current() self.White_Board_page.switch_to_current()
self.White_Board_page.click_zhixian() self.White_Board_page.click_line()
self.White_Board_page.switch_to_iframe("webview") self.White_Board_page.switch_to_iframe("webview")
before_drap_zhixian = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png' before_drap_zhixian = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.White_Board_page.save_screenshot(before_drap_zhixian) self.White_Board_page.save_screenshot(before_drap_zhixian)
...@@ -122,6 +123,7 @@ class TestLivePage(object): ...@@ -122,6 +123,7 @@ class TestLivePage(object):
print(result) print(result)
assert 10 < result assert 10 < result
# @pytest.mark.skip()
@allure.title("测试白板功能-形状") @allure.title("测试白板功能-形状")
def testWhiteBoardBlock(self): def testWhiteBoardBlock(self):
self.White_Board_page.sleep(1) self.White_Board_page.sleep(1)
...@@ -141,6 +143,7 @@ class TestLivePage(object): ...@@ -141,6 +143,7 @@ class TestLivePage(object):
print(result) print(result)
assert 10 < result assert 10 < result
# @pytest.mark.skip()
@allure.title("测试白板功能-移动") @allure.title("测试白板功能-移动")
def testWhiteBoardMove(self): def testWhiteBoardMove(self):
self.White_Board_page.sleep(1) self.White_Board_page.sleep(1)
...@@ -160,8 +163,10 @@ class TestLivePage(object): ...@@ -160,8 +163,10 @@ class TestLivePage(object):
print(result) print(result)
assert 10 < result assert 10 < result
@pytest.mark.run(order=-1)
# @pytest.mark.skip()
@allure.title("测试白板功能-橡皮擦") @allure.title("测试白板功能-橡皮擦")
def testWhiteBoardBlock(self): def testWhiteBoardEraser(self):
self.White_Board_page.sleep(1) self.White_Board_page.sleep(1)
self.White_Board_page.switch_to_current() self.White_Board_page.switch_to_current()
self.White_Board_page.click_eraser() self.White_Board_page.click_eraser()
......
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