Commit 5f70970d by linguangwei

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

parent 00c96043
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"
...@@ -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