コード例 #1
0
    def test_query(self):
        """成功"""
        filepath = os.path.join(datapath, "query.yml")
        data1 = ReadYaml(filepath).read_yaml()

        confpath = os.path.join(datapath, "conftest.yml")
        data2 = ReadYaml(confpath).read_yaml()

        url = search('ip.testip1', data2) + search('test01.request.url', data1)
        method = search('test01.request.method', data1)
        headers = search('test01.request.headers', data1)
        body = search('test01.request.body', data1)
        code = search('test01.request.code', data1)

        response = RequestUtil().request(url,
                                         method=method,
                                         headers=headers,
                                         param=body,
                                         content_type='data')
        print(response)
        assert search('code', response) == 0
コード例 #2
0
import time

import allure
import pytest
from common.log import Log
from common.read_yml import ReadYaml
from pages.login_page import LoginPage
from selenium import webdriver

testdata = ReadYaml('login_page.yml').get_yaml_data()  # 读取数据


class Test_login():
    log = Log()

    @allure.feature("功能点:用户登录页面")
    @allure.story("用例:用户登录")
    @pytest.mark.parametrize("username,password,msg",
                             testdata["test_login_success_data"],
                             ids=["正确用户名密码登录"])
    # @pytest.mark.skip('跳过该成功用例')
    def test_success_login(self, username, password, msg):
        driver = webdriver.Chrome()
        web = LoginPage(driver)
        web.login(user=username, password=password)
        result = web.is_login_success(expect_text=msg)
        self.log.info("登录结果:%s" % result)
        # time.sleep(10)
        assert result
        # web.is_quit()
コード例 #3
0
from common.base import Base
from common.read_yml import ReadYaml

testelement = ReadYaml("news_page.yml").get_yaml_data()


class NewsPage(Base):
    new1 = tuple(testelement["test_add_new"][0])  # 新闻管理
    new2 = tuple(testelement["test_add_new"][1])  # 新增新闻
    new3 = tuple(testelement["test_add_new"][2])  # 输入标题
    new4 = tuple(testelement["test_add_new"][3])  # 自定义作者
    new5 = tuple(testelement["test_add_new"][4])  # 输入作者名
    new6 = tuple(testelement["test_add_new"][5])  # 选择TMT(一级)频道
    new7 = tuple(testelement["test_add_new"][6])  # 选择原创类型输入框
    new8 = tuple(testelement["test_add_new"][7])  # 选择原创类型
    new9 = tuple(testelement["test_add_new"][8])  # 选择同步首页
    new10 = tuple(testelement["test_add_new"][9])  # 选择摘要

    # 判断元素
    # loc4 = tuple(testelement["test_login_element"][3])#登录成功断言
    # loc5 = tuple(testelement["test_login_element"][4])#登录失败断言

    def come_news(self):
        '''进入新闻管理模块'''
        self.click(self.new1)

    def add_news(self):
        '''进入新增新闻'''
        self.click(self.new2)

    def input_title(self, text):
コード例 #4
0
import allure
import pytest
from common.log import Log
from common.read_yml import ReadYaml
from pages.add_account_page import Add_Account

testdata = ReadYaml('add_account_page.yml').get_yaml_data()  # 读取测试数据


class Test_Add_Account():
    log = Log()

    @allure.feature("功能点:添加银行卡账户")
    @allure.story("用例:添加银行卡账户")
    @pytest.mark.parametrize("card_num,name,phone,mail,city,sex,msg",
                             testdata["test_add_account_data1"],
                             ids=["正常添加"])
    def test_add_account(self, login_fixtrue, card_num, name, phone, mail,
                         city, sex, msg):
        driver = login_fixtrue
        account = Add_Account(driver)
        with allure.step("点击银行卡账户,跳转添加账户页面"):
            account.click_account()
        with allure.step("点击添加账户按钮,进入编辑页面"):
            account.click_add_account()
        with allure.step("输入账户号"):
            account.input_card_num(text=card_num)
        with allure.step("输入姓名"):
            account.input_name(text=name)
        with allure.step("输入手机号"):
            account.input_phone(text=phone)
コード例 #5
0
'''
Code description: 用户注册
Create time: 2020/12/14
Developer: 叶修
'''
import time

import allure
import pytest
from faker import Faker

from common.base import Base
from common.log import Log
from common.read_yml import ReadYaml
from pages.register_page import Register_Page
testdata = ReadYaml('register_page.yml').get_yaml_data()  #读取数据


@allure.feature("功能点:用户注册")
class Test_Register():

    log = Log()

    @allure.story("用例:用户注册")
    @pytest.mark.parametrize("login_name,user_name,password,repassword,msg",
                             testdata["register_success_data"],
                             ids=["用户成功注册"])
    #@pytest.mark.skip('跳过该成功用例')
    def test_register(self, open_browser, login_name, user_name, password,
                      repassword, msg):
        driver = open_browser
コード例 #6
0
from common.base import Base
from common.read_yml import ReadYaml
testelement = ReadYaml("add_account_page.yml").get_yaml_data()


class Add_Account(Base):

    loc1 = tuple(testelement["test_account_element"][0])  # 银行卡账户
    loc2 = tuple(testelement["test_account_element"][1])  # 添加银行卡账户
    loc3 = tuple(testelement["test_account_element"][2])  # 卡号
    loc4 = tuple(testelement["test_account_element"][3])  # 姓名
    loc5 = tuple(testelement["test_account_element"][4])  # 电话
    loc6 = tuple(testelement["test_account_element"][5])  # 邮箱
    loc7 = tuple(testelement["test_account_element"][6])  # 城市
    loc8 = tuple(testelement["test_account_element"][7])  # 性别
    loc9 = tuple(testelement["test_account_element"][8])  # 保存
    loc10 = tuple(testelement["test_account_element"][9])  # 新增成功校验
    loc11 = tuple(testelement["test_account_element"][10])  #账号为空校验
    loc12 = tuple(testelement["test_account_element"][11])  #姓名为空校验

    def click_account(self):
        '''点击银行卡账号'''
        self.finds(self.loc1)[0].click()

    def click_add_account(self):
        '''点击添加银行卡账号'''
        self.click(self.loc2)

    def input_card_num(self, text="123456"):
        '''输入卡号'''
        self.writein(self.loc3, text)
コード例 #7
0
ファイル: login_page.py プロジェクト: Jacklovely/new_pytestUI
'''
Code description: 登录页面
Create time: 2020/12/14
Developer: 叶修
'''

from common.base import Base
from common.driver import WDriver
from common.read_yml import ReadYaml
testelement = ReadYaml("login_page.yml").get_yaml_data()


class LoginPage(Base):

    #定位元素
    loc1 = tuple(testelement["login_element"][0])  #用户名
    loc2 = tuple(testelement["login_element"][1])  #密码
    loc3 = tuple(testelement["login_element"][2])  #登录按钮
    # 断言元素
    loc4 = tuple(testelement["login_element"][3])  #登录成功断言
    loc5 = tuple(testelement["login_element"][4])  #登录失败断言

    def input_username(self, text="*****@*****.**"):
        '''输入用户名'''
        self.input(self.loc1, text)

    def input_password(self, text="123456"):
        '''输入密码'''
        self.input(self.loc2, text)

    def click_button(self):
コード例 #8
0
'''
Code description: 新建储存库
Create time: 2020/12/14
Developer: 叶修
'''

import allure
import pytest

from common.base import Base
from common.log import Log
from common.read_yml import ReadYaml
from pages.new_repository import New_Repository_Page
testdata = ReadYaml('new_repository.yml').get_yaml_data()  #读取数据


@allure.feature("功能点:新建储存库")
class Test_New_Repository():

    log = Log()

    @allure.story("用例:新建储存库")
    @pytest.mark.parametrize("msg", testdata["success_data"], ids=["点击新建储存库"])
    #@pytest.mark.skip('跳过该成功用例')
    def test_new_repository(self, login_fixtrue, msg):
        driver = login_fixtrue
        new_repository = New_Repository_Page(driver)
        with allure.step("点击new"):
            new_repository.click_new()
        with allure.step("获取结果: 获取页面实际结果,判断是否打开新增窗口"):
            result = new_repository.is_open_windows_success(expect_text=msg[0])
コード例 #9
0
'''
Code description:注册
Create time: 2020/12/14
Developer: 叶修
'''

from common.base import Base
from common.read_yml import ReadYaml
testelement = ReadYaml("register_page.yml").get_yaml_data()

class Register_Page(Base):

    #定位元素
    loc1 = tuple(testelement["register_element"][0])  # 注册
    loc2 = tuple(testelement["register_element"][1])  # 登录名
    loc3 = tuple(testelement["register_element"][2])  # 用户名
    loc4 = tuple(testelement["register_element"][3])  # 密码
    loc5 = tuple(testelement["register_element"][4])  # 确认密码
    # 断言元素
    loc6 = tuple(testelement["register_element"][5])  # 成功断言
    loc7 = tuple(testelement["register_element"][6])  # 失败断言

    def click_register(self):
        '''点击注册,进入注册页面'''
        self.driver.get(self.base_url)
        self.click(self.loc1)

    def input_loginname(self, text="Mrqiu"):
        '''输入登录名'''
        self.input(self.loc2, text)
コード例 #10
0
'''
Code description:新建储存库
Create time: 2020/12/14
Developer: 叶修
'''

from common.base import Base
from common.read_yml import ReadYaml
testelement = ReadYaml("new_repository.yml").get_yaml_data()


class New_Repository_Page(Base):

    #定位元素
    loc1 = tuple(testelement["new_repositories_element"][0])  #new
    # 断言元素
    loc2 = tuple(testelement["new_repositories_element"][1])  #登录成功断言

    def click_new(self):
        '''点击new'''
        self.click(self.loc1)

    def is_open_windows_success(self, expect_text='Create a new repository'):
        text = self.get_text(self.loc2)
        self.log.info("获取到断言元素的文本内容:%s" % text)
        return expect_text == text


if __name__ == '__main__':
    pass
コード例 #11
0
import time

import allure
import pytest
from common.log import Log
from common.read_yml import ReadYaml
from pages.login_page import LoginPage
from pages.news_page import NewsPage
from selenium import webdriver

testdata = ReadYaml('news_page.yml').get_yaml_data()  # 读取数据


class Test_news():
    log = Log()

    @allure.feature("功能点:添加新闻")
    @allure.story("用例:用户新添加新闻")
    @pytest.mark.parametrize("title,author,abstract",
                             testdata["test_add_news_data"],
                             ids=["正常添加"])
    # @pytest.mark.skip('跳过该成功用例')
    def test_add_new(self, login_fixtrue, title, author, abstract):
        driver = login_fixtrue
        new = NewsPage(driver)
        with allure.step("点击进入新闻管理模块"):
            new.come_news()
            time.sleep(2)
        with allure.step("点击进入新增新闻页面"):
            new.add_news()
        with allure.step("输入新闻标题"):
コード例 #12
0
'''
Code description:添加设备
Create time: 2021/3/24
Developer: 李万洋
'''

from common.base import Base
from common.read_yml import ReadYaml
testelement = ReadYaml("add_equipment_page.yml").get_yaml_data()

class Add_Equipment_Page(Base):

    #定位元素
    loc1 = tuple(testelement["equipment_element"][0])  # 添加设备
    loc2 = tuple(testelement["equipment_element"][1])  # 设备名
    loc3 = tuple(testelement["equipment_element"][2])  # 型号
    loc4 = tuple(testelement["equipment_element"][3])  # 编号
    loc5 = tuple(testelement["equipment_element"][4])  # 品牌
    loc6 = tuple(testelement["equipment_element"][5])  # 系统
    loc7 = tuple(testelement["equipment_element"][6])  # 系统
    # 断言元素
    loc8 = tuple(testelement["equipment_element"][7])  # 成功断言

    def click_add_equipment(self):
        '''点击添加设备'''
        self.click(self.loc1)

    def input_name(self, text="Mrqiu"):
        '''输入设备名'''
        self.input(self.loc2, text)
コード例 #13
0
'''
Code description:添加设备
Create time: 2021/3/24
Developer: 叶修
'''
import time

import allure
import pytest
from common.log import Log
from common.read_yml import ReadYaml
from pages.add_equipment_page import Add_Equipment_Page
testdata = ReadYaml('add_equipment_page.yml').get_yaml_data()  #读取数据


@allure.feature("功能点:添加设备")
class Test_Add_Equipment():

    log = Log()

    @allure.story("用例:添加设备")
    @pytest.mark.parametrize("name,model,num,brand,version",
                             testdata["equipment_success_data"],
                             ids=["添加设备"])
    #@pytest.mark.skip('跳过该成功用例')
    def test_add_equipment(self, login_fixtrue, name, model, num, brand,
                           version):
        driver = login_fixtrue
        register = Add_Equipment_Page(driver)
        with allure.step("点击添加设备,跳转添加设备"):
            time.sleep(1)