Commit 3b01b34d by linguangwei

review

parent 48b2569a
......@@ -4,12 +4,13 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="00f4febb-36b6-426d-bfe6-b023876a617e" name="Default Changelist" comment="修改为pytest框架">
<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$/config/config.ini" beforeDir="false" afterPath="$PROJECT_DIR$/config/config.ini" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/requirements.txt" 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/loginpage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/loginpage.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" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -159,7 +160,7 @@
<recent name="C:\Users\Administrator\PycharmProjects\xm-uitest-live" />
</key>
</component>
<component name="RunManager" selected="Python.main">
<component name="RunManager" selected="Python tests.pytest in test_LoginPage.py">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" />
......@@ -253,9 +254,9 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python tests.pytest in test_LoginPage.py" />
<item itemvalue="Python.main" />
<item itemvalue="Python tests.pytest in test_MainPage.py" />
<item itemvalue="Python tests.pytest in test_LoginPage.py" />
<item itemvalue="Python tests.pytest for src.testcase.test_LoginPage.TestLoginPage.testLogin" />
<item itemvalue="Python.test_LoginPage" />
</list>
......@@ -371,7 +372,14 @@
<option name="project" value="LOCAL" />
<updated>1624266261609</updated>
</task>
<option name="localTasksCounter" value="14" />
<task id="LOCAL-00014" summary="review">
<created>1624270134308</created>
<option name="number" value="00014" />
<option name="presentableId" value="LOCAL-00014" />
<option name="project" value="LOCAL" />
<updated>1624270134308</updated>
</task>
<option name="localTasksCounter" value="15" />
<servers />
</component>
<component name="TestHistory">
......@@ -477,10 +485,10 @@
<MESSAGE value="同步" />
<MESSAGE value="登录-开课-结束课程-关闭客户端" />
<MESSAGE value="添加转换窗口方法" />
<MESSAGE value="review" />
<MESSAGE value="添加测试白板的page和testcase" />
<MESSAGE value="修改为pytest框架" />
<option name="LAST_COMMIT_MESSAGE" value="修改为pytest框架" />
<MESSAGE value="review" />
<option name="LAST_COMMIT_MESSAGE" value="review" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/server.log" />
......
......@@ -4,7 +4,7 @@ from src.framework import common
if __name__ == '__main__':
htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute())
pytest.main(["-v", '--html={}'.format(htmlPath), './src/testcase/test_LoginPage.py'])
pytest.main(["-v", '--html={}'.format(htmlPath), './src/testcase/test_LoginPage.py', "--durations=0"])
# # 定义报告输出路径
# htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute())
......
......@@ -6,6 +6,7 @@ import random
import string
import time
from functools import reduce
from config import readConfig
import requests
from PIL import Image
......@@ -49,10 +50,12 @@ def compare_pictures(pic1, pic2):
# 获取登录token
def get_token():
account = readConfig.test_account()
password = readConfig.test_password()
headers = {"Content-Type": "application/json; charset=UTF-8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/91.0.4472.77 Safari/537.36"}
params = {"phone": "13777867342", "authCode": "0000", "appTermEnum": "XIAOMAI_CLOUD_CLASS_PC_WEB_ADMIN"}
params = {"phone": account, "authCode": password, "appTermEnum": "XIAOMAI_CLOUD_CLASS_PC_WEB_ADMIN"}
data = json.dumps(params)
url = "https://gateway.xiaomai5.com/hades/anon/hades/login?storeId=null&token=null&storeUserId=null&userId=null"
r = requests.post(url=url, data=data, headers=headers)
......
......@@ -103,7 +103,7 @@ class Page(object):
def save_screenshot(self, filename):
self.driver.save_screenshot(filename)
# 跳iframe
# 跳iframe
def switch_to_iframe(self, iframe_id):
self.driver.switch_to.frame(iframe_id)
......@@ -111,7 +111,7 @@ class Page(object):
def switch_to_current(self):
self.driver.switch_to.default_content()
# 切换窗口
# 切换窗口,切换到存在loc元素的窗口
def change_window(self, loc):
driver = self.driver
vars = driver.window_handles
......@@ -138,7 +138,7 @@ class Page(object):
login_page.click(login_button)
# 鼠标键盘操作
# 拖拽元素
# 拖拽元素,从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()
......@@ -146,6 +146,6 @@ class Page(object):
def left_click(self):
ActionChains(self.driver).click().perform()
# 鼠标移动N个像素
# 鼠标移动(x,y)个像素后点击
def mouse_move(self, x, y):
ActionChains(self.driver).move_by_offset(xoffset=x, yoffset=y).click().perform()
......@@ -15,7 +15,6 @@ class LoginPage(Page):
# 登录按钮
login_button = (By.CLASS_NAME, "submit")
# 验证元素
# 店铺名称
store_name = (By.XPATH, """//div[@class="inst"]""")
......
......@@ -19,15 +19,15 @@ class TestLivePage(object):
time.sleep(15)
live_course_name = create_a_live(start_time=25, start_time2=1)
driver = get_app_driver(cloud_class_location)
live_page = WhiteBoardPage(driver=driver)
White_Board_page = WhiteBoardPage(driver=driver)
# 这里停15s是因为setUP里创建直播间获取token登录了一次,限制两次登录需间隔15s
live_page.sleep(15)
live_page.login()
live_page.sleep(2)
live_page.click_in_live_btn(live_course_name[0])
live_page.sleep(5)
live_page.change_window(live_page.camera_btn)
live_page.sleep(5)
White_Board_page.sleep(15)
White_Board_page.login()
White_Board_page.sleep(2)
White_Board_page.click_in_live_btn(live_course_name[0])
White_Board_page.sleep(5)
White_Board_page.change_window(White_Board_page.camera_btn)
White_Board_page.sleep(5)
def setup_class(self):
# 指定客户端的本地路径,在/config/config.ini配置
......@@ -38,28 +38,28 @@ class TestLivePage(object):
# 测试白板功能-文本输入
def testWhiteBoard(self):
self.live_page.click_white_board()
self.live_page.sleep(2)
self.live_page.click_add_white_board()
self.live_page.click_camera_btn()
self.live_page.sleep(1)
self.live_page.click_open_white_board()
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)
self.White_Board_page.click_open_white_board()
self.live_page.click_wenben()
self.live_page.sleep(3)
self.White_Board_page.click_wenben()
self.White_Board_page.sleep(3)
# 切换iframe前后都要点击一次才能生效,神奇
self.live_page.move_get_wenben()
self.live_page.switch_to_iframe("webview")
self.live_page.move_get_wenben()
print(self.live_page.ifElementExist(self.live_page.wenben_text))
self.live_page.sleep(1)
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))
self.White_Board_page.sleep(1)
before_send_wenben = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.live_page.save_screenshot(before_send_wenben)
self.White_Board_page.save_screenshot(before_send_wenben)
# 切换iframe后必须时textarea才能输入文本
self.live_page.input_wenben("11111")
self.live_page.sleep(1)
self.White_Board_page.input_wenben("11111")
self.White_Board_page.sleep(1)
after_send_wenben = screenshot_path(sys._getframe().f_code.co_name) + "/" + year_to_minute() + '.png'
self.live_page.save_screenshot(after_send_wenben)
self.White_Board_page.save_screenshot(after_send_wenben)
wenben_result = compare_pictures(before_send_wenben, after_send_wenben)
print(wenben_result)
assert 10 < wenben_result
......
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