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
85c8cc14
Commit
85c8cc14
authored
Jul 06, 2021
by
mac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加ctrl+m方法,test
parent
c34fdbf2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
4 deletions
+30
-4
config/config.ini
+3
-0
config/readConfig.py
+6
-0
src/pageobject/basepage.py
+17
-1
src/pageobject/mainpage.py
+0
-3
src/testcase/test_LoginPage.py
+4
-0
tools/chromedriver
+0
-0
No files found.
config/config.ini
View file @
85c8cc14
...
...
@@ -9,6 +9,9 @@ browserName = Chrome
win_app_location
=
C:
\U
sers
\A
dministrator
\A
ppData
\L
ocal
\P
rograms
\x
mqxy
\小
麦企学院.exe
mac_app_location
=
/Applications/小麦企学院.app/Contents/MacOS/小麦企学院
[testEnv]
env
=
prod
[account]
# 白名单账号
username
=
13777867342
...
...
config/readConfig.py
View file @
85c8cc14
...
...
@@ -19,6 +19,12 @@ def test_location():
return
location
# 获取测试的环境
def
get_env
():
env
=
config
.
get
(
"testEnv"
,
"env"
)
return
env
def
test_account
():
return
config
.
get
(
"account"
,
"username"
)
...
...
src/pageobject/basepage.py
View file @
85c8cc14
from
time
import
sleep
import
platform
from
config
import
readConfig
...
...
@@ -72,10 +73,23 @@ class Page(object):
def
sleep
(
self
,
seconds
):
return
sleep
(
seconds
)
# 查找文本,点击该文本元素
def
click_text
(
self
,
text
):
self
.
click
((
By
.
XPATH
,
"""//span[text()="{}"]"""
.
format
(
text
)))
# 键盘down
def
keys_down
(
self
):
ActionChains
(
self
.
driver
)
.
key_down
(
Keys
.
DOWN
)
.
key_up
(
Keys
.
DOWN
)
.
perform
()
# 键盘ctrl+M,command+m
def
get_env_window
(
self
):
if
platform
.
system
()
.
lower
()
==
"windows"
:
ActionChains
(
self
.
driver
)
.
send_keys
(
Keys
.
CONTROL
,
"m"
)
.
perform
()
elif
platform
.
system
()
.
lower
()
==
"darwin"
:
ActionChains
(
self
.
driver
)
.
send_keys
(
Keys
.
COMMAND
,
"m"
)
.
perform
()
# self.driver.find_element(By.XPATH, "//div[@class='title']").send_keys(Keys.COMMAND, "m")
# ActionChains(self.driver).key_down(Keys.COMMAND).send_keys("M").key_up(Keys.COMMAND).perform()
# 屏幕最大化
def
max
(
self
,
*
loc
):
self
.
driver
.
find_element
(
*
loc
)
.
click
()
...
...
@@ -116,7 +130,6 @@ class Page(object):
# 操作脚本
def
excute_script
(
self
,
loc
):
# self.driver.execute_script("document.getElementsByClassName('form xm_phone_login')[0].style.position = 'static'")
self
.
driver
.
execute_script
(
"document.getElementsByClassName('{}')[0].style.position = 'static'"
.
format
(
loc
))
# 切换窗口,切换到存在loc元素的窗口
...
...
@@ -141,6 +154,9 @@ class Page(object):
# 登录按钮
login_button
=
(
By
.
CLASS_NAME
,
"submit"
)
# login_page.click(phone_login)
env
=
readConfig
.
get_env
()
login_page
.
get_env_window
()
login_page
.
click_text
(
env
)
login_page
.
excute_script
(
"form xm_phone_login"
)
login_page
.
sleep
(
2
)
login_page
.
input_text
(
account_input
,
readConfig
.
test_account
())
...
...
src/pageobject/mainpage.py
View file @
85c8cc14
...
...
@@ -79,9 +79,6 @@ class MainPage(LoginPage):
def
stop_live
(
self
):
self
.
click
(
self
.
stop_live_btn
)
def
get_live_name
(
self
):
self
.
keys_down
()
# 获取按钮文本
def
get_btn_text
(
self
,
coursename
):
self
.
in_live_btn
=
(
By
.
XPATH
,
"""//div[text()="{}"]/..//button[@class="ant-btn"]"""
.
format
(
coursename
))
...
...
src/testcase/test_LoginPage.py
View file @
85c8cc14
...
...
@@ -14,6 +14,7 @@ class TestLoginPage(object):
self
.
account
=
readConfig
.
test_account
()
self
.
password
=
readConfig
.
test_password
()
cloud_class_location
=
readConfig
.
test_location
()
self
.
env
=
readConfig
.
get_env
()
# 指定客户端的本地路径,在/config/config.ini配置
self
.
driver
=
get_app_driver
(
cloud_class_location
)
yield
self
.
driver
...
...
@@ -23,6 +24,9 @@ class TestLoginPage(object):
@pytest.mark.usefixtures
(
"before_test_case"
)
def
testLogin
(
self
):
login_page
=
LoginPage
(
driver
=
self
.
driver
)
login_page
.
get_env_window
()
login_page
.
sleep
(
2
)
login_page
.
click_text
(
self
.
env
)
login_page
.
phone_input_execute_script
()
login_page
.
sleep
(
2
)
# login_page.click_phone_login()
...
...
tools/chromedriver
100644 → 100755
View file @
85c8cc14
File mode changed from 100644 to 100755
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