Commit 9652f10d by linguangwei

review

parent 897d5b0f
......@@ -4,10 +4,15 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="00f4febb-36b6-426d-bfe6-b023876a617e" name="Default Changelist" comment="添加删除白板功能">
<change afterPath="$PROJECT_DIR$/src/pageobject/livecamerapage.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/testcase/test_LiveCameraPage.py" afterDir="false" />
<list default="true" id="00f4febb-36b6-426d-bfe6-b023876a617e" name="Default Changelist" comment="添加摄像头的四个功能">
<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$/src/framework/common.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/framework/common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/framework/dingTalk.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/framework/dingTalk.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/livecamerapage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/livecamerapage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pageobject/loginpage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/loginpage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/testcase/test_LiveCameraPage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/test_LiveCameraPage.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -174,7 +179,7 @@
<recent name="C:\Users\Administrator\PycharmProjects\xm-uitest-live" />
</key>
</component>
<component name="RunManager" selected="Python tests.pytest for test_LiveCameraPage.TestLivePage">
<component name="RunManager" selected="Python tests.pytest for test_LiveCameraPage.TestLivePage.testOpenCameraImage">
<configuration name="demo" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
......@@ -196,23 +201,28 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="pytest for test_LiveCameraPage.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" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<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="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<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_LiveCameraPage.TestLivePage&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<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" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="pytest for test_MainBarPage.TestMainPage.test_SelectToday" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<configuration name="pytest for test_LiveCameraPage.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" />
......@@ -224,11 +234,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_MainBarPage.TestMainPage.test_SelectToday&quot;" />
<option name="_new_target" value="&quot;test_LiveCameraPage.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_LiveCameraPage.TestLivePage.testCloseCameraByFunction2" 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" />
......@@ -240,11 +250,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_LiveCameraPage.TestLivePage.testCloseCameraByFunction2&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<configuration name="pytest for test_WhiteBoardPage.TestLivePage.testDeleteWhiteBoardr" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<configuration name="pytest for test_LiveCameraPage.TestLivePage.testOpenCameraImage" 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" />
......@@ -256,17 +266,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.testDeleteWhiteBoardr&quot;" />
<option name="_new_target" value="&quot;test_LiveCameraPage.TestLivePage.testOpenCameraImage&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python tests.pytest for test_LiveCameraPage.TestLivePage" />
<item itemvalue="Python tests.pytest for test_LiveCameraPage.TestLivePage.testOpenCameraImage" />
<item itemvalue="Python tests.pytest for test_LiveCameraPage.TestLivePage.testCloseCameraByFunction2" />
<item itemvalue="Python.main" />
<item itemvalue="Python.demo" />
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage.testDeleteWhiteBoardr" />
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage" />
<item itemvalue="Python tests.pytest for test_MainBarPage.TestMainPage.test_SelectToday" />
<item itemvalue="Python tests.pytest for test_LiveCameraPage.TestLivePage" />
</list>
</recent_temporary>
</component>
......@@ -548,7 +558,14 @@
<option name="project" value="LOCAL" />
<updated>1626687629349</updated>
</task>
<option name="localTasksCounter" value="38" />
<task id="LOCAL-00038" summary="添加摄像头的四个功能">
<created>1626747477550</created>
<option name="number" value="00038" />
<option name="presentableId" value="LOCAL-00038" />
<option name="project" value="LOCAL" />
<updated>1626747477550</updated>
</task>
<option name="localTasksCounter" value="39" />
<servers />
</component>
<component name="TestHistory">
......@@ -669,7 +686,8 @@
<MESSAGE value="添加时间轴case" />
<MESSAGE value="review" />
<MESSAGE value="添加删除白板功能" />
<option name="LAST_COMMIT_MESSAGE" value="添加删除白板功能" />
<MESSAGE value="添加摄像头的四个功能" />
<option name="LAST_COMMIT_MESSAGE" value="添加摄像头的四个功能" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/server.log" />
......
......@@ -6,7 +6,7 @@ from src.framework import common
if __name__ == '__main__':
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_LiveCameraPage.py', "--durations=0"])
os.system('allure generate {} -o ./report/output --clean'.format(htmlPath))
# os.system('allure open report/output')
dingTalk.alert()
......
......@@ -158,6 +158,6 @@ def create_a_live(start_time, start_time2=None):
try:
# 校验result中是否会返回课程id
assert r.json()["result"] != ''
return courseName
return [courseName]
except Exception as e:
print(e.args)
......@@ -3,10 +3,18 @@ import requests
import json
import socket
from src.framework.common import file_abspath
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
file_path = file_abspath() + "report\\output\\widgets\\suites.json"
with open(file_path) as f:
file_context = json.loads(f.read())
result = file_context['items'][0]['statistic']
def alert():
# 获取当前日期
......@@ -18,7 +26,7 @@ def alert():
"msgtype": "markdown", # 发送类型:text/markdown
"markdown": {
"title": "uitest报告", # 需要和机器人设置的关键字相对于 否则不会推送到消息
"text": "### 代码质量检测报告 \n\n **项目名称:**测试markdown样式项目 \n\n **项目地址:**[点击跳转详情](http://{}:63342/index.html) \n\n **检测分支:** master \n\n **bug数量:**3 \n\n **相关人员:**@测试 \n\n **播报时间:** {}".format(ip, tile),
"text": "### 代码质量检测报告 \n\n **项目名称:**UI自动化 \n\n **项目地址:**[点击跳转详情](http://{}:63342/index.html) \n\n **检测分支:** master \n\n **bug数量:**{} \n\n **相关人员:**@测试 \n\n **播报时间:** {}".format(ip, result, tile),
"at": {
"atMobiles": [
"" # 如果需要@某人,这里写他的手机号  这块暂时没有触发 还在研究
......
......@@ -6,6 +6,8 @@ from config import readConfig
# pages基类
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
......@@ -133,8 +135,8 @@ class Page(object):
def switch_to_current(self):
self.driver.switch_to.default_content()
# 操作脚本
def excute_script(self, loc):
# 操作脚本-元素显性
def excute_script_dominance(self, loc):
self.driver.execute_script("document.getElementsByClassName('{}')[0].style.position = 'static'".format(loc))
# 切换窗口,切换到存在loc元素的窗口
......@@ -169,7 +171,7 @@ class Page(object):
# 新的登录方法
# 执行脚本,隐藏的手机号码输入框弹出
# login_page.excute_script("form xm_phone_login")
# login_page.excute_script_dominance("form xm_phone_login")
# login_page.sleep(2)
login_page.input_text(account_input, readConfig.test_account())
......@@ -194,5 +196,9 @@ class Page(object):
ActionChains(self.driver).move_by_offset(xoffset=x, yoffset=y).click().perform()
# 鼠标悬停直至元素出现
def mouse_stop_until_ele_show(self, ele):
ActionChains(self.driver).move_to_element(ele).perform()
def mouse_stop_until_ele_show(self, *ele):
if len(ele) == 2:
ActionChains(self.driver).move_to_element(ele[0]).perform()
WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable(ele[1]))
else:
ActionChains(self.driver).move_to_element(ele).perform()
......@@ -9,11 +9,11 @@ class LiveCameraPage(MainPage):
# 开启/关闭摄像头按钮
camera_btn = (By.XPATH, "//div[@class='camera']/span")
# 摄像头ele
camera_ele = (By.XPATH, "//[@id='localVideo']")
camera_ele = (By.XPATH, "//div[@class='react-draggable']")
# 画面内的摄像头关闭按钮
close_camera_btn = (By.XPATH, "//span[@class='iconBox trans']/span")
close_camera_btn = (By.XPATH, "//span[@class='iconBox']/span")
# 画面内的摄像头镜像按钮
camera_image = (By.XPATH, "//span[@class='iconBox']/span")
camera_image = (By.XPATH, "//span[@class='iconBox trans']/span")
def __init__(self, driver):
MainPage.__init__(self, driver)
......@@ -24,7 +24,7 @@ class LiveCameraPage(MainPage):
# 鼠标选择在摄像头画面
def mouse_on_camera(self):
self.mouse_stop_until_ele_show(self.camera_ele)
self.mouse_stop_until_ele_show(self.find_element(self.camera_ele), self.camera_image)
# 点击关闭摄像头
def click_close_camera_btn(self):
......@@ -34,3 +34,22 @@ class LiveCameraPage(MainPage):
def click_camera_image(self):
self.click(self.camera_image)
# 摄像头ele
camera_ele1 = (By.XPATH, "//div[@class='react-draggable']/div[1]")
# 摄像头ele
camera_ele2 = (By.XPATH, "//div[@class='react-draggable']/div[1]/div[1]")
# 摄像头ele
camera_ele3 = (By.XPATH, "//div[@class='react-draggable']/div[1]/div[1]/div[1]")
# 摄像头ele
camera_ele4 = (By.XPATH, "//div[@class='react-draggable']/div[1]/div[1]/div[1]/canvas")
# 摄像头ele
camera_ele5 = (By.XPATH, "//div[@class='drag tl']")
list = [camera_ele, camera_ele1, camera_ele2, camera_ele3, camera_ele4, camera_ele5]
def test_mouse_on_camera(self):
for self.i in self.list:
self.sleep(1)
self.mouse_stop_until_ele_show(self.find_element(self.i))
print(self.i)
......@@ -43,7 +43,7 @@ class LoginPage(Page):
# 手机号码登录窗口可显示操作
def phone_input_execute_script(self):
self.excute_script("form xm_phone_login")
self.excute_script_dominance("form xm_phone_login")
# 关闭环境选择窗口
def click_close_env_window(self):
......
......@@ -25,16 +25,16 @@ class TestLivePage(object):
def before_test(self):
self.logger = Logger('live page').getlog()
time.sleep(15)
live_course_name = create_a_live(start_time=25, start_time2=1)
live_course_name = create_a_live(start_time=25)
# 这里停15s是因为setUP里创建直播间获取token登录了一次,限制两次登录需间隔15s
self.Live_Camera_Page.sleep(15)
self.Live_Camera_Page.login()
self.Live_Camera_Page.sleep(2)
print(live_course_name[0])
self.Live_Camera_Page.click_in_live_btn(live_course_name[0])
self.Live_Camera_Page.sleep(5)
self.Live_Camera_Page.sleep(2)
self.Live_Camera_Page.change_window(self.Live_Camera_Page.camera_btn)
self.Live_Camera_Page.sleep(5)
self.Live_Camera_Page.sleep(2)
yield self.driver
self.driver.quit()
......@@ -69,13 +69,15 @@ class TestLivePage(object):
assert 10 < result
@pytest.mark.run(order=3)
# @pytest.mark.skip()
@allure.title("测试摄像头功能-摄像头镜像")
def testOpenCameraImage(self):
before_open_camera_image = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.Live_Camera_Page.save_screenshot(before_open_camera_image)
get_allure_screenshots(before_open_camera_image, "开启摄像头镜像前截图")
self.Live_Camera_Page.mouse_on_camera()
self.Live_Camera_Page.sleep(1)
# self.Live_Camera_Page.test_mouse_on_camera()
self.Live_Camera_Page.sleep(2)
self.Live_Camera_Page.click_camera_image()
after_open_camera_image = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.Live_Camera_Page.save_screenshot(after_open_camera_image)
......@@ -85,13 +87,13 @@ class TestLivePage(object):
assert 10 < result
@pytest.mark.run(order=4)
@pytest.mark.skip()
@allure.title("测试摄像头功能-关闭摄像头-方法2")
def testCloseCameraByFunction2(self):
before_open_camera_image = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.Live_Camera_Page.save_screenshot(before_open_camera_image)
get_allure_screenshots(before_open_camera_image, "关闭摄像头前截图")
self.Live_Camera_Page.mouse_on_camera()
self.Live_Camera_Page.sleep(1)
self.Live_Camera_Page.click_close_camera_btn()
after_open_camera_image = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.Live_Camera_Page.save_screenshot(after_open_camera_image)
......
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