Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UIProject
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liying
UIProject
Commits
d279c021
Commit
d279c021
authored
Feb 07, 2024
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正1
parent
12dbb29f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
20 deletions
+51
-20
login.py
BasePage/login.py
+0
-10
login_page.py
BasePage/login_page.py
+20
-0
test_login.py
TestCases/test_login.py
+28
-0
main.py
main.py
+3
-10
No files found.
BasePage/login.py
deleted
100644 → 0
View file @
12dbb29f
from
selenium
import
webdriver
from
selenium.webdriver.common.by
import
By
driver
=
webdriver
.
Chrome
()
driver
.
get
(
"https://rays7.5rs.me/login"
)
driver
.
find_element
(
By
.
XPATH
,
"//*[@id='userName']"
)
.
send_keys
(
"17373027967"
)
driver
.
find_element
(
By
.
XPATH
,
"//*[@id='pwd']"
)
.
send_keys
(
"Qwe123456"
)
driver
.
find_element
(
By
.
XPATH
,
"//*[@id='App']/div/div[1]/div[3]/div/div/div[3]/form/div[4]/div/div/div/div/button"
)
.
click
()
\ No newline at end of file
BasePage/login_page.py
0 → 100644
View file @
d279c021
import
time
from
selenium
import
webdriver
from
selenium.webdriver.common.by
import
By
driver
=
webdriver
.
Chrome
()
driver
.
get
(
"https://rays7.raysgo.com/login"
)
class
LoginPage
:
def
login_username
(
self
,
username
=
None
,
password
=
None
):
driver
.
find_element
(
By
.
XPATH
,
"//*[@id='userName']"
)
.
send_keys
(
username
)
driver
.
find_element
(
By
.
XPATH
,
"//*[@id='pwd']"
)
.
send_keys
(
password
)
driver
.
find_element
(
By
.
XPATH
,
"//*[@id='App']/div/div/div[1]/div[3]/div/div/div[3]/form/div[4]/div/div/div/div/button"
)
.
click
()
time
.
sleep
(
10
)
TestCases/test_login.py
0 → 100644
View file @
d279c021
import
pytest
from
BasePage.login_page
import
LoginPage
# @pytest.fixture(scope="function",autouse=True)
# def fixture_test():
# """前后置处理"""
# # print('----测试开始----')
# # yield
# # print('----测试结束----')
# return "结束"
class
Test_Login
(
LoginPage
):
# 前后置条件
@pytest.fixture
def
setup
(
self
):
print
(
"
\n
Setup - Before Test"
)
# 可以在这里进行一些初始化工作
# 如果有返回值,测试函数可以使用这个返回值
yield
"Setup data"
# 后置条件 - 在测试运行后执行
print
(
"
\n
Teardown - After Test"
)
# 可以在这里进行一些清理工作
def
test_case01
(
self
,
setup
):
LoginPage
.
login_username
(
self
,
username
=
"17373027967"
,
password
=
"3149390154Li"
)
main.py
View file @
d279c021
# 这是一个示例 Python 脚本。
# 这是一个示例 Python 脚本。
import
pytest
# 按 Shift+F10 执行或将其替换为您的代码。
# 按 Shift+F10 执行或将其替换为您的代码。
# 按 双击 Shift 在所有地方搜索类、文件、工具窗口、操作和设置。
# 按 双击 Shift 在所有地方搜索类、文件、工具窗口、操作和设置。
def
print_hi
(
name
):
pytest
.
main
([
'-s'
,
'-v'
])
# 在下面的代码行中使用断点来调试脚本。
\ No newline at end of file
print
(
f
'Hi, {name}'
)
# 按 Ctrl+F8 切换断点。
# 按间距中的绿色按钮以运行脚本。
if
__name__
==
'__main__'
:
print_hi
(
'PyCharm'
)
# 访问 https://www.jetbrains.com/help/pycharm/ 获取 PyCharm 帮助
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