Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xm-uitest-sow
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiamai-test
xm-uitest-sow
Commits
3b01b34d
Commit
3b01b34d
authored
Jun 22, 2021
by
linguangwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
review
parent
48b2569a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
40 deletions
+50
-40
.idea/workspace.xml
+16
-8
main.py
+1
-1
src/framework/common.py
+4
-1
src/pageobject/basepage.py
+4
-4
src/pageobject/loginpage.py
+0
-1
src/testcase/test_WhiteBoardPage.py
+25
-25
No files found.
.idea/workspace.xml
View file @
3b01b34d
...
@@ -4,12 +4,13 @@
...
@@ -4,12 +4,13 @@
<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=
"
修改为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$/.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$/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/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>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
...
@@ -159,7 +160,7 @@
...
@@ -159,7 +160,7 @@
<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
.main
"
>
<component
name=
"RunManager"
selected=
"Python
tests.pytest in test_LoginPage.py
"
>
<configuration
name=
"main"
type=
"PythonConfigurationType"
factoryName=
"Python"
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=
""
/>
...
@@ -253,9 +254,9 @@
...
@@ -253,9 +254,9 @@
</configuration>
</configuration>
<recent_temporary>
<recent_temporary>
<list>
<list>
<item
itemvalue=
"Python tests.pytest in test_LoginPage.py"
/>
<item
itemvalue=
"Python.main"
/>
<item
itemvalue=
"Python.main"
/>
<item
itemvalue=
"Python tests.pytest in test_MainPage.py"
/>
<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 tests.pytest for src.testcase.test_LoginPage.TestLoginPage.testLogin"
/>
<item
itemvalue=
"Python.test_LoginPage"
/>
<item
itemvalue=
"Python.test_LoginPage"
/>
</list>
</list>
...
@@ -371,7 +372,14 @@
...
@@ -371,7 +372,14 @@
<option
name=
"project"
value=
"LOCAL"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1624266261609
</updated>
<updated>
1624266261609
</updated>
</task>
</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
/>
<servers
/>
</component>
</component>
<component
name=
"TestHistory"
>
<component
name=
"TestHistory"
>
...
@@ -477,10 +485,10 @@
...
@@ -477,10 +485,10 @@
<MESSAGE
value=
"同步"
/>
<MESSAGE
value=
"同步"
/>
<MESSAGE
value=
"登录-开课-结束课程-关闭客户端"
/>
<MESSAGE
value=
"登录-开课-结束课程-关闭客户端"
/>
<MESSAGE
value=
"添加转换窗口方法"
/>
<MESSAGE
value=
"添加转换窗口方法"
/>
<MESSAGE
value=
"review"
/>
<MESSAGE
value=
"添加测试白板的page和testcase"
/>
<MESSAGE
value=
"添加测试白板的page和testcase"
/>
<MESSAGE
value=
"修改为pytest框架"
/>
<MESSAGE
value=
"修改为pytest框架"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"修改为pytest框架"
/>
<MESSAGE
value=
"review"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"review"
/>
</component>
</component>
<component
name=
"editorHistoryManager"
>
<component
name=
"editorHistoryManager"
>
<entry
file=
"file://$PROJECT_DIR$/server.log"
/>
<entry
file=
"file://$PROJECT_DIR$/server.log"
/>
...
...
main.py
View file @
3b01b34d
...
@@ -4,7 +4,7 @@ from src.framework import common
...
@@ -4,7 +4,7 @@ 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"
,
'--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())
# htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute())
...
...
src/framework/common.py
View file @
3b01b34d
...
@@ -6,6 +6,7 @@ import random
...
@@ -6,6 +6,7 @@ import random
import
string
import
string
import
time
import
time
from
functools
import
reduce
from
functools
import
reduce
from
config
import
readConfig
import
requests
import
requests
from
PIL
import
Image
from
PIL
import
Image
...
@@ -49,10 +50,12 @@ def compare_pictures(pic1, pic2):
...
@@ -49,10 +50,12 @@ def compare_pictures(pic1, pic2):
# 获取登录token
# 获取登录token
def
get_token
():
def
get_token
():
account
=
readConfig
.
test_account
()
password
=
readConfig
.
test_password
()
headers
=
{
"Content-Type"
:
"application/json; charset=UTF-8"
,
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) "
"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"
}
"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
)
data
=
json
.
dumps
(
params
)
url
=
"https://gateway.xiaomai5.com/hades/anon/hades/login?storeId=null&token=null&storeUserId=null&userId=null"
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
)
r
=
requests
.
post
(
url
=
url
,
data
=
data
,
headers
=
headers
)
...
...
src/pageobject/basepage.py
View file @
3b01b34d
...
@@ -103,7 +103,7 @@ class Page(object):
...
@@ -103,7 +103,7 @@ class Page(object):
def
save_screenshot
(
self
,
filename
):
def
save_screenshot
(
self
,
filename
):
self
.
driver
.
save_screenshot
(
filename
)
self
.
driver
.
save_screenshot
(
filename
)
# 跳
出
iframe
# 跳
入
iframe
def
switch_to_iframe
(
self
,
iframe_id
):
def
switch_to_iframe
(
self
,
iframe_id
):
self
.
driver
.
switch_to
.
frame
(
iframe_id
)
self
.
driver
.
switch_to
.
frame
(
iframe_id
)
...
@@ -111,7 +111,7 @@ class Page(object):
...
@@ -111,7 +111,7 @@ class Page(object):
def
switch_to_current
(
self
):
def
switch_to_current
(
self
):
self
.
driver
.
switch_to
.
default_content
()
self
.
driver
.
switch_to
.
default_content
()
# 切换窗口
# 切换窗口
,切换到存在loc元素的窗口
def
change_window
(
self
,
loc
):
def
change_window
(
self
,
loc
):
driver
=
self
.
driver
driver
=
self
.
driver
vars
=
driver
.
window_handles
vars
=
driver
.
window_handles
...
@@ -138,7 +138,7 @@ class Page(object):
...
@@ -138,7 +138,7 @@ class Page(object):
login_page
.
click
(
login_button
)
login_page
.
click
(
login_button
)
# 鼠标键盘操作
# 鼠标键盘操作
# 拖拽元素
# 拖拽元素
,从sourse元素开始拖拽(x,y)像素
def
drag_mouse
(
self
,
source
,
xoffset
,
yoffset
):
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
()
...
@@ -146,6 +146,6 @@ class Page(object):
...
@@ -146,6 +146,6 @@ class Page(object):
def
left_click
(
self
):
def
left_click
(
self
):
ActionChains
(
self
.
driver
)
.
click
()
.
perform
()
ActionChains
(
self
.
driver
)
.
click
()
.
perform
()
# 鼠标移动
N个像素
# 鼠标移动
(x,y)个像素后点击
def
mouse_move
(
self
,
x
,
y
):
def
mouse_move
(
self
,
x
,
y
):
ActionChains
(
self
.
driver
)
.
move_by_offset
(
xoffset
=
x
,
yoffset
=
y
)
.
click
()
.
perform
()
ActionChains
(
self
.
driver
)
.
move_by_offset
(
xoffset
=
x
,
yoffset
=
y
)
.
click
()
.
perform
()
src/pageobject/loginpage.py
View file @
3b01b34d
...
@@ -15,7 +15,6 @@ class LoginPage(Page):
...
@@ -15,7 +15,6 @@ class LoginPage(Page):
# 登录按钮
# 登录按钮
login_button
=
(
By
.
CLASS_NAME
,
"submit"
)
login_button
=
(
By
.
CLASS_NAME
,
"submit"
)
# 验证元素
# 验证元素
# 店铺名称
# 店铺名称
store_name
=
(
By
.
XPATH
,
"""//div[@class="inst"]"""
)
store_name
=
(
By
.
XPATH
,
"""//div[@class="inst"]"""
)
...
...
src/testcase/test_WhiteBoardPage.py
View file @
3b01b34d
...
@@ -19,15 +19,15 @@ class TestLivePage(object):
...
@@ -19,15 +19,15 @@ class TestLivePage(object):
time
.
sleep
(
15
)
time
.
sleep
(
15
)
live_course_name
=
create_a_live
(
start_time
=
25
,
start_time2
=
1
)
live_course_name
=
create_a_live
(
start_time
=
25
,
start_time2
=
1
)
driver
=
get_app_driver
(
cloud_class_location
)
driver
=
get_app_driver
(
cloud_class_location
)
live
_page
=
WhiteBoardPage
(
driver
=
driver
)
White_Board
_page
=
WhiteBoardPage
(
driver
=
driver
)
# 这里停15s是因为setUP里创建直播间获取token登录了一次,限制两次登录需间隔15s
# 这里停15s是因为setUP里创建直播间获取token登录了一次,限制两次登录需间隔15s
live
_page
.
sleep
(
15
)
White_Board
_page
.
sleep
(
15
)
live
_page
.
login
()
White_Board
_page
.
login
()
live
_page
.
sleep
(
2
)
White_Board
_page
.
sleep
(
2
)
live
_page
.
click_in_live_btn
(
live_course_name
[
0
])
White_Board
_page
.
click_in_live_btn
(
live_course_name
[
0
])
live
_page
.
sleep
(
5
)
White_Board
_page
.
sleep
(
5
)
live_page
.
change_window
(
live
_page
.
camera_btn
)
White_Board_page
.
change_window
(
White_Board
_page
.
camera_btn
)
live
_page
.
sleep
(
5
)
White_Board
_page
.
sleep
(
5
)
def
setup_class
(
self
):
def
setup_class
(
self
):
# 指定客户端的本地路径,在/config/config.ini配置
# 指定客户端的本地路径,在/config/config.ini配置
...
@@ -38,28 +38,28 @@ class TestLivePage(object):
...
@@ -38,28 +38,28 @@ class TestLivePage(object):
# 测试白板功能-文本输入
# 测试白板功能-文本输入
def
testWhiteBoard
(
self
):
def
testWhiteBoard
(
self
):
self
.
live
_page
.
click_white_board
()
self
.
White_Board
_page
.
click_white_board
()
self
.
live
_page
.
sleep
(
2
)
self
.
White_Board
_page
.
sleep
(
2
)
self
.
live
_page
.
click_add_white_board
()
self
.
White_Board
_page
.
click_add_white_board
()
self
.
live
_page
.
click_camera_btn
()
self
.
White_Board
_page
.
click_camera_btn
()
self
.
live
_page
.
sleep
(
1
)
self
.
White_Board
_page
.
sleep
(
1
)
self
.
live
_page
.
click_open_white_board
()
self
.
White_Board
_page
.
click_open_white_board
()
self
.
live
_page
.
click_wenben
()
self
.
White_Board
_page
.
click_wenben
()
self
.
live
_page
.
sleep
(
3
)
self
.
White_Board
_page
.
sleep
(
3
)
# 切换iframe前后都要点击一次才能生效,神奇
# 切换iframe前后都要点击一次才能生效,神奇
self
.
live
_page
.
move_get_wenben
()
self
.
White_Board
_page
.
move_get_wenben
()
self
.
live
_page
.
switch_to_iframe
(
"webview"
)
self
.
White_Board
_page
.
switch_to_iframe
(
"webview"
)
self
.
live
_page
.
move_get_wenben
()
self
.
White_Board
_page
.
move_get_wenben
()
print
(
self
.
live_page
.
ifElementExist
(
self
.
live
_page
.
wenben_text
))
print
(
self
.
White_Board_page
.
ifElementExist
(
self
.
White_Board
_page
.
wenben_text
))
self
.
live
_page
.
sleep
(
1
)
self
.
White_Board
_page
.
sleep
(
1
)
before_send_wenben
=
screenshot_path
(
sys
.
_getframe
()
.
f_code
.
co_name
)
+
"/"
+
year_to_minute
()
+
'.png'
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才能输入文本
# 切换iframe后必须时textarea才能输入文本
self
.
live
_page
.
input_wenben
(
"11111"
)
self
.
White_Board
_page
.
input_wenben
(
"11111"
)
self
.
live
_page
.
sleep
(
1
)
self
.
White_Board
_page
.
sleep
(
1
)
after_send_wenben
=
screenshot_path
(
sys
.
_getframe
()
.
f_code
.
co_name
)
+
"/"
+
year_to_minute
()
+
'.png'
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
)
wenben_result
=
compare_pictures
(
before_send_wenben
,
after_send_wenben
)
print
(
wenben_result
)
print
(
wenben_result
)
assert
10
<
wenben_result
assert
10
<
wenben_result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment