Example #1
0
from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

config = ReadConfig()
logger = Logging('perpmLogin').getlog()


class perpmLogin(Page):
    def __init__(self, driver):
        Page.__init__(self, driver)
        self.config_element = {
            "账号输入框": ["id", "login_user_email"],
            "密码输入框": ['id', "login_password"],
            "登录按钮":
            ['xpath', "/html/body/div[1]/div[2]/div/div[2]/div/form/button"],
            "登录错误提示": ['id', 'login_msg'],
            "忘记密码": ['id', 'forget_password'],
            "验证码登录": [
                'css',
                'body > div.company-login.login01 > div > div.login-panel-body > form > div.tips > div > a.pull-right.code-btn'
            ],
            "账号密码登录": ['id', 'accout-login'],
            "中英文切换":
            ['css', 'body > div.language > ul > li.language-active > a'],
            "英文": ['linktext', 'English'],
            "中文": ['linktext', '中文'],
            "登录按钮_1":
            ['xpath', '/html/body/nav/div/div[2]/ul[3]/li[1]/button']
        }
Example #2
0
import time

from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver import ActionChains
from selenium.webdriver.support.select import Select

import readConfig

from common.logger import Logging
config = readConfig.ReadConfig()
logger = Logging("Page").getlog()


class Page():
    #初始化
    def __init__(self, driver):
        self.driver = driver
        self.config_element = {}
        self.time = float(config.getConfig("element_wait"))
        self.implicit_wait = float(config.getConfig("implicit_wait"))

    #通用的方法封装
    #单个元素定位
    def find_element(self, element):
        """单个元素定位"""
        try:
            el = self.config_element[element]
            type = el[0]
            value = el[1]
            if type == "ID" or type == "id" or type == "Id" or type == 'iD':
                try:
Example #3
0
from time import sleep

from common.logger import Logging
from page_obj.base import Page
from testFile.elementAndText import Page_Text

logger = Logging("livelist").getlog()
class Livelist(Page):
    """文本信息"""
    def list_tests(self):
        """文本信息对比测试"""
        list = []
        #text方法,把元素文本值取出来,append到list中
        list.append(self.text("live_list", "title"))
        list.append(self.text("live_list", "直播列表"))
        list.append(self.text("live_list", "开始直播"))
        list.append(self.text("live_list", "更多操作"))
        list.append(self.text("live_list", "创建直播"))
        list.append(self.text("live_list", "页数"))
        return list

    def list_check_url(self):

        self.click("live_list", "创建直播按钮")
        reality_url = self.get_url()
        self.browser_page_handle("-1")
        return reality_url
    def list_check_click(self):
        """开始直播测试,断言是否开启新窗口"""
        self.click("live_list", "开始直播")
        self.new_window()
Example #4
0
from common.drive import Driver
from common.logger import Logging
from page_obj.persion_data.data_set import dataSet
from testCase.myunittest import myunittest

logger = Logging('dataSetT').getlog()


class dataSetT(myunittest):
    def setUp(self):
        driver = Driver(self.browser).open_browser()
        self.dataSet = dataSet(driver)
        self.dataSet.open(self.url)
        self.AssertionError = []

    def tearDown(self):
        self.dataSet.quit()
        self.assertEqual([], self.AssertionError)

    #修改用户资料测试

    def test_edit(self):
        self.dataSet.lognin()
        tests = self.dataSet.add_data()

        if str(tests[0]) == '我是呢称' and tests[1] != None:
            logger.info("修改信息成功")
        else:
            logger.error("修改信息失败")
            self.AssertionError.append("修改信息失败")
Example #5
0

from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig


logger = Logging("cms_Login").getlog()
class cmsLogin(Page):


    def tests(self):
        """登录文本信息"""
        self.click("cms_login", "登录右")
        list = []
        list.append(self.text("cms_login", "帮助"))
        list.append(self.text("cms_login", "登录右"))
        list.append(self.text("cms_login", "标题"))
        list.append(self.text("cms_login", "邮箱或手机"))
        list.append(self.element_type_value("cms_login", "账号输入框"))
        list.append(self.text("cms_login", "密码"))
        list.append(self.text("cms_login", "登录按钮"))
        list.append(self.text("cms_login", "使用验证码登录"))
        list.append(self.text("cms_login", "版权所有"))
        list.append(self.text("cms_login", "商标名称"))

        # list.append(self.text("cms_login", "验证码账号"))
        # list.append(self.element_type_value("cms_login", "验证码账号输入框"))
        # list.append(self.text("cms_login", "验证码"))
        # list.append(self.element_type_value("cms_login", "获取验证码按钮"))
        # list.append(self.element_type_value("cms_login", "验证码登录按钮"))
Example #6
0
import random

from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

logger = Logging('change_pwd').getlog()
config = ReadConfig()


class change_pwd(Page):
    def __init__(self, driver):
        Page.__init__(self, driver)
        self.config_element = {
            "账号输入框": ["id", "login_user_email"],
            "密码输入框": ['id', "login_password"],
            "登录按钮": [
                'css',
                "body > div.company-login.login01 > div > div.login-panel-body > form > div.form-group.no-margin-bot > div > button"
            ],
            "登录错误提示": ['id', 'show_error'],
            "忘记密码": ['id', 'forget_password'],
            "验证码登录": [
                'css',
                'body > div.company-login.login01 > div > div.login-panel-body > form > div.tips > div > a.pull-right.code-btn'
            ],
            "账号密码登录": ['id', 'accout-login'],
            "中英文切换":
            ['css', 'body > div.language > ul > li.language-active > a'],
            "英文": ['linktext', 'English'],
            "中文": ['linktext', '中文'],
Example #7
0
from common.function import Excel
from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

logger = Logging('addressAdd').getlog()
config = ReadConfig()


class addressAdd(Page):
    def __init__(self, driver):
        Page.__init__(self, driver)
        self.config_element = {
            "地址管理": ['css', '#myTabs > li:nth-child(3) > a'],
            "个人资料入口": ['css', '#hover-drop > a > img'],
            "个人资料": ['css', '#hover-drop > ul > li:nth-child(2) > a'],
            "添加新地址": ['css', '#tab3 > div > div > div > button'],
            "收件人姓名": ['id', 'consignee'],
            "收件人手机号码": ['id', 'consignee_tel'],
            "选择省": ['id', 'province'],
            "广东": ['css', '#province > option:nth-child(20)'],
            "选择市": ['id', 'city'],
            "深圳": ['css', '#city > option:nth-child(4)'],
            "选择区": ['id', 'district'],
            "南山": ['css', '#district > option:nth-child(4)'],
            "提交": ["id", 'btn-submit'],
            "右上角x": [
                "css",
                'body > div:nth-child(11) > div.mask.mask_address > div > div.popup-head > span.close.fa.fa-times'
            ],
            "地址错误信息": ['id', 'consignee-error'],
Example #8
0
# -*- coding: utf-8 -*-
import random
import time
from datetime import datetime
import xlrd
from xlrd import xldate_as_tuple
from xlutils.copy import copy

from testFile import DATAPATH
from common.logger import Logging

logger_random = Logging("Random").getlog()
logger_excel = Logging("Excel").getlog()


class Excel():
    def __init__(self, filename):
        """filename = excel文件名称,row = 从excel表的第几行开始读取"""
        logger_excel.info("加载{}excel表".format(filename))
        self.filename = filename

        self.workbook = xlrd.open_workbook(
            DATAPATH + r"/{}.xls".format(filename))  #加载EXCLE文件

        self.table = self.workbook.sheets()[0]  #获取文件sheet

        self.nrows = self.table.nrows  #excel表格中的行数

        self.ncols = self.table.ncols  #excel表格中的列数

    def read_excel(self, row):
Example #9
0
from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

logger = Logging('safeEdit').getlog()
config = ReadConfig()


class safeEdit(Page):
    def __init__(self, driver):
        Page.__init__(self, driver)
        self.config_element = {
            "账号输入框": ["id", "login_user_email"],
            "密码输入框": ['id', "login_password"],
            "登录按钮": [
                'css',
                "body > div.company-login.login01 > div > div.login-panel-body > form > div.form-group.no-margin-bot > div > button"
            ],
            "登录错误提示": ['id', 'show_error'],
            "忘记密码": ['id', 'forget_password'],
            "验证码登录": [
                'css',
                'body > div.company-login.login01 > div > div.login-panel-body > form > div.tips > div > a.pull-right.code-btn'
            ],
            "账号密码登录": ['id', 'accout-login'],
            "中英文切换":
            ['css', 'body > div.language > ul > li.language-active > a'],
            "英文": ['linktext', 'English'],
            "中文": ['linktext', '中文'],
            "个人资料入口": ['css', '#hover-drop > a > img'],
            "个人资料": ['css', '#hover-drop > ul > li:nth-child(2) > a'],
from time import sleep

from common.drive import Driver
from common.logger import Logging
from page_obj.homepage.study_centre import study_centre
from testCase.myunittest import myunittest

logger = Logging('homePageTest').getlog()
class homePageTest(myunittest):
    def setUp(self):
        driver = Driver(self.browser).open_browser()
        self.study_centre = study_centre(driver)
        self.study_centre.open(self.url)

        self.AssertionError = []

    def tearDown(self):
        self.study_centre.quit()
        self.assertEqual([], self.AssertionError)
    def test_1study_course(self):
        check = self.study_centre.select_course()

        if check[0] == True:
            logger.info('课程_正在学习is true')
        else:
            self.AssertionError.append('课程_正在学习is false')
        if check[1] == True:
            logger.info('课程_正在学习is true')
        else:
            self.AssertionError.append('课程_正在学习is false')
Example #11
0
from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

logger = Logging("courseOutline").getlog()
config = ReadConfig()


class courseOutline(Page):
    def course_outline_texts(self):
        """内容课程大纲的文本验证"""
        self.click("course_outline", "顶内容")
        self.click("course_outline", "顶大纲")
        self.wait_time(2)
        outlinelist = []
        outlinelist.append(self.text("course_outline", "课程大纲"))
        outlinelist.append(self.text("course_outline", "课程开始日期"))
        outlinelist.append(self.text("course_outline", "新增章固定"))
        outlinelist.append(self.text("course_outline", "在线查看"))
        outlinelist.append(self.text("course_outline", "说明标题1"))
        outlinelist.append(self.text("course_outline", "说明内容1.1"))
        outlinelist.append(self.text("course_outline", "说明内容1.2"))
        outlinelist.append(self.text("course_outline", "说明标题2"))
        outlinelist.append(self.text("course_outline", "说明内容2"))
        outlinelist.append(self.text("course_outline", "了解更多2"))
        outlinelist.append(self.text("course_outline", "说明标题3"))
        outlinelist.append(self.text("course_outline", "说明内容3"))
        outlinelist.append(self.text("course_outline", "了解更多3"))
        outlinelist.append(self.text("course_outline", "说明标题4"))
        outlinelist.append(self.text("course_outline", "说明内容4.1"))
        outlinelist.append(self.text("course_outline", "说明内容4.2"))
from common.drive import Driver
from common.logger import Logging
from page_obj.study_course.study_course import studyCourse
from testCase.myunittest import myunittest

logger = Logging('studuCourseT').getlog()


class studuCourseT(myunittest):
    def setUp(self):
        driver = Driver(self.browser).open_browser()
        self.studyCourse = studyCourse(driver)
        self.studyCourse.open(self.url)
        self.AssertionError = []

    def tearDown(self):
        self.studyCourse.quit()
        self.assertEqual([], self.AssertionError)

    def test_1choice_course(self):
        self.studyCourse.choice_course()
        check = self.studyCourse.write_comment()
        for check, check1 in zip(check[0], check[1]):
            try:
                self.assertEqual(check, check1)
                logger.info("实际文本:{},预期文本:{}".format(check, check1))

            except Exception as e:
                logger.error("********用例执行错误*********%s" % e)
                self.AssertionError.append("实际文本:{},预期文本:{}".format(
                    check, check1))
Example #13
0
from time import sleep

from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

logger = Logging('selectCourse').getlog()
config = ReadConfig()


class selectCourse(Page):
    def __init__(self, driver):
        Page.__init__(self, driver)
        self.config_element = {
            "find_course": [
                "css",
                "#bs-example-navbar-collapse-1 > ul:nth-child(1) > li.all-discover-classify > a"
            ],
            "选择一个课程": ["css", 'h3.course-name>a'],
            "全文": [
                "css",
                'body > div:nth-child(11) > div > div.col-md-9 > div.panel.panel-default.course-detail > div > div.content > p > span'
            ],
            "收起": [
                'css',
                'body > div:nth-child(11) > div > div.col-md-9 > div.panel.panel-default.course-detail > div > div.content > div.more > p:nth-child(2) > span'
            ],
            "内容": [
                'css',
                'body > div:nth-child(11) > div > div.col-md-9 > div.panel.panel-default.course-detail > div > div.content > p'
            ],
Example #14
0
from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

config = ReadConfig()
logger = Logging('LmsLogin').getlog()


class pmLogin(Page):
    def __init__(self, driver):
        Page.__init__(self, driver)
        self.config_element = {
            "账号输入框": ["id", "login_user_email"],
            "密码输入框": ['id', "login_password"],
            "登录按钮": [
                'css',
                "body > div.company-login.login01 > div > div.login-panel-body > form > div.form-group.no-margin-bot > div > button"
            ],
            "登录错误提示": ['id', 'show_error'],
            "忘记密码": ['id', 'forget_password'],
            "验证码登录": [
                'css',
                'body > div.company-login.login01 > div > div.login-panel-body > form > div.tips > div > a.pull-right.code-btn'
            ],
            "账号密码登录": ['id', 'accout-login'],
            "中英文切换":
            ['css', 'body > div.language > ul > li.language-active > a'],
            "英文": ['linktext', 'English'],
            "中文": ['linktext', '中文'],
        }
Example #15
0
from common.drive import Driver
from common.logger import Logging
from page_obj.base import Page
from page_obj.send.send_p import test_s

from testCase.myunittest import myunittest

logger = Logging('send_test').getlog()


class send_test(myunittest, Page):
    def setUp(self):
        driver = Driver(self.browser).open_browser()
        self.test_s = test_s(driver)
        self.test_s.open('https://4xjhtu.beta.e-ducation.cn/live/1415/login')
        self.AssertionError = []

    def tearDown(self):
        self.test_s.quit()
        self.assertEqual([], self.AssertionError)

    def test_1address(self):
        self.test_s.login()
        self.test_s.send_msg()
Example #16
0
from common.drive import Driver
from common.logger import Logging
from page_obj.base import Page
from page_obj.pm.af import lmsAF
from testCase.myunittest import myunittest

logger = Logging("lmsAFtest").getlog()


class lmsAFtest(myunittest, Page):
    def setUp(self):
        driver = Driver(self.browser).open_browser()
        self.lmsAF = lmsAF(driver)
        self.lmsAF.open(self.url)
        self.AssertionError = []

    def tearDown(self):
        self.lmsAF.quit()
        self.assertEqual([], self.AssertionError)

    def test_1forget(self):
        #测试忘记密码功能
        self.lmsAF.cli()
        for i in range(len(self.lmsAF.page_texts) - 3):
            check = self.lmsAF.forget_t(i + 3)
            if check != '邮箱或手机号码格式有误':
                logger.info('忘记密码功能正常')
            else:
                self.AssertionError.append("登录用例错误")

    def test_2autcode(self):
Example #17
0
from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

logger = Logging("courseDetail").getlog()
config = ReadConfig()


class coursePage(Page):
    def course_page_texts(self):
        """内容页面文本验证"""
        #缺笔记文本获取,“页面”和“右答3”有换行符可能会出问题

        self.click("course_page", "顶内容")
        self.click("course_page", "顶页面")
        self.wait_time(2)

        pagelist = []
        pagelist.append(self.text("course_page", "内容"))
        pagelist.append(self.text("course_page", "页面"))
        pagelist.append(self.text("course_page", "在线查看"))
        pagelist.append(self.text("course_page", "注意"))
        pagelist.append(self.text("course_page", "主页"))
        pagelist.append(self.text("course_page", "课程"))
        pagelist.append(self.text("course_page", "讨论"))
        pagelist.append(self.text("course_page", "Wiki"))
        pagelist.append(self.text("course_page", "进度"))
        # pagelist.append(self.text("course_page", "笔记"))
        pagelist.append(self.text("course_page", "右问1"))
        pagelist.append(self.text("course_page", "右答1"))
        pagelist.append(self.text("course_page", "右问2"))
Example #18
0
import random

from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

logger = Logging("createCourse").getlog()
config = ReadConfig()


class createCourse(Page):
    def create_course_texts(self):
        """创建课程的文本验证"""

        self.wait_time(2)
        list = []
        list.append(self.text("course_create", "创建课程标题"))
        list.append(self.text("course_create", "课程名称"))
        list.append(self.element_type_value("course_create", "课程名输入框"))
        list.append(self.text("course_create", "课程名备注"))
        list.append(self.text("course_create", "组织机构"))
        list.append(self.element_type_value("course_create", "组织机构输入框"))
        list.append(self.text("course_create", "组织机构备注"))
        list.append(self.text("course_create", "课程编号"))
        list.append(self.element_type_value("course_create", "课程编号输入框"))
        list.append(self.text("course_create", "课程编号备注"))
        list.append(self.text("course_create", "开课时间"))
        list.append(self.element_type_value("course_create", "开课时间输入框"))
        list.append(self.text("course_create", "开课时间备注"))
        list.append(self.text("course_create", "课程分类"))
        list.append(self.text("course_create", "新增分类"))
Example #19
0
from common.logger import Logging
from page_obj.base import Page



logger = Logging("lmsLoginFun").getlog()
class lmsLoginFun(Page):
    def __init__(self,driver):
        Page.__init__(self,driver)
        self.config_element = {
            "账号输入框": ["id", "login_user_email"],
            "密码输入框": ['id', "login_password"],
            "登录按钮": ['css', "body > div.company-login.login01 > div > div.login-panel-body > form > div.form-group.no-margin-bot > div > button"],
            "登录错误提示": ['id', 'show_error'],
            "忘记密码": ['id', 'forget_password'],
            "验证码登录": ['css', 'body > div.company-login.login01 > div > div.login-panel-body > form > div.tips > div > a.pull-right.code-btn'],
            "账号密码登录": ['id', 'accout-login'],
            "中英文切换": ['css', 'body > div.language > ul > li.language-active > a'],
            "英文": ['linktext', 'English'],
            "中文": ['linktext', '中文'],
        }
    page_texts = [
        "https://rk98tc.e-ducation.cn/account/forget_password/",
        "Forgot password",
        "忘记密码"
    ]
    def forget_t(self):

        self.click('忘记密码')
        # print(Page_Text['lms_login'][0])
        # url = self.get_url()
Example #20
0
from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

config = ReadConfig()
logger = Logging('perpmRegister').getlog()


class perpmRegister(Page):
    def __init__(self, driver):
        Page.__init__(self, driver)
        self.config_element = {
            "账号输入框": ["id", "reg_user_email"],
            "密码输入框": ['id', "login_password"],
            "登录按钮": [
                'xpath',
                "/html/body/div[1]/div[2]/div/div[1]/div/form/div[1]/button"
            ],
            "登录错误提示": ['id', 'reg_msg'],
            "忘记密码": ['id', 'forget_password'],
            "验证码登录": [
                'css',
                'body > div.company-login.login01 > div > div.login-panel-body > form > div.tips > div > a.pull-right.code-btn'
            ],
            "账号密码登录": ['id', 'accout-login'],
            "中英文切换":
            ['css', 'body > div.language > ul > li.language-active > a'],
            "英文": ['linktext', 'English'],
            "中文": ['linktext', '中文'],
            "登录按钮_1":
            ['xpath', '/html/body/nav/div/div[2]/ul[3]/li[2]/button']
Example #21
0
from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

logger = Logging('app_d').getlog()
config = ReadConfig()


class app_d(Page):
    def __init__(self, driver):
        Page.__init__(self, driver)
        self.config_element = {
            "app下载": [
                'css',
                '#bs-example-navbar-collapse-1 > ul:nth-child(1) > li:nth-child(4) > a'
            ],
            "立即下载": [
                'css',
                'body > div.app-download-banner > div.container > div.app-download-text > div > a'
            ],
            "有效管理": [
                'css',
                'body > div.container > div > div > ul > li:nth-child(1) > p:nth-child(3)'
            ],
            "及时关注": [
                'css',
                'body > div.container > div > div > ul > li:nth-child(2) > p:nth-child(3)'
            ],
            "节奏自掌控": [
                'css',
                'body > div.container > div > div > ul > li:nth-child(3) > p:nth-child(3)'
Example #22
0
from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

logger = Logging('find_course').getlog()
config = ReadConfig()
moneyis = 198.00


class study_centre(Page):
    def __init__(self, driver):
        Page.__init__(self, driver)
        self.config_element = {
            "选择一个课程": [
                'css',
                '#page1 > div > div > div > div.course-aside.panel-md > div.course-about > h3 > a'
            ],
            "已完成": ['css', '#myTabs > li:nth-child(2) > a'],
            "助教": ['xpath', '//*[@id="course_user_menu"]/a[3]'],
            "助教_已完成": ['css', '#myTabs > li:nth-child(2) > a'],
            "助教_已取消": ['xpath', '//*[@id="myTabs"]/li[3]'],
            "宝典": ['xpath', '//*[@id="course_user_menu"]/a[5]'],
            "宝典获取": ['id', 'tab1-tab'],
            "宝典支出": ['css', '#myTabs > li:nth-child(2)'],
            "转赠": [
                'css',
                'body > div:nth-child(11) > div.container > div > div.stay-r > div > div.panel-body.relate > div.book-recharge > button'
            ],
            "对方id": ['id', 'user_id'],
            "对方账号": ['id', 'phone_or_email'],
            "转赠宝典": ['id', 'max_score'],
Example #23
0
import random

from common.function import Random
from common.logger import Logging
from page_obj.base import Page
from readConfig import ReadConfig

logger = Logging('studyCourse').getlog()
config = ReadConfig()


class test_s(Page, Random):
    def __init__(self, driver):
        Page.__init__(self, driver)
        self.config_element = {
            '账号输入': [
                'css',
                '#app > div.container > div:nth-child(1) > div.up-layer > div:nth-child(2) > input'
            ],
            '密码输入': [
                'css',
                '#app > div.container > div:nth-child(1) > div.up-layer > div:nth-child(3) > input'
            ],
            '确认': [
                'css',
                '#app > div.container > div:nth-child(1) > div.up-layer > div:nth-child(4) > button'
            ],
            '输入': ['css', '#mywords'],
            'send': ['id', 'jssend'],
        }
from selenium.webdriver.support.wait import WebDriverWait

from common.drive import Driver
from common.function import Excel, Random
from common.logger import Logging
from page_obj.base import Page


from readYaml import yl
"""
登录测试


"""

logger = Logging("wel_LoginTest").getlog()
class test_click(unittest.TestCase,Page,Random):
    url = yl['t_wc']['url']
    browser = yl['t_wc']['browser']
    real_title = yl['t_wc']['real_title']

    def setUp(self):
        self.driver = Driver(self.browser).open_browser(self.url)
        #self.open(self.url)
    def tearDown(self):
        logger.info('测试完成,现在退出')
        self.driver.quit()
    def test_1_click(self):
        logger.info('点击一下click click')
        self.click("w_login","宣传登陆")
        WebDriverWait(self.driver,5,0.5).until(EC.presence_of_all_elements_located)
Example #25
0
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

import readConfig
from common.logger import Logging
logger = Logging("Driver").getlog()
dir = readConfig.ProjectPath        #获取配置文件所在的文件路径
class Driver():
    """选择加载浏览器的驱动"""
    #firefox_driver_path = dir+ '/driver/geckodriver.exe'
    #chrome_driver_path = dir + '/driver/chromedriver.exe'
    #ie_driver_path = dir + '/driver/IEDriverServer.exe'
    """修改为mac os驱动路经"""
    firefox_driver_path = dir + '/driver/geckodriver'
    chrome_driver_path = dir + '/driver/chromedriver'
    def __init__(self, driver, time = 15):
        self.driver = driver
        self.time = time
    def open_browser(self):
        """打开浏览器"""
        if self.driver == "Firefox" or self.driver == "firefox":
            self.browser = webdriver.Firefox(self.firefox_driver_path)
            logger.info("打开火狐浏览器")
        if self.driver == "Chrome":
            #self.browser = webdriver.Chrome(self.chrome_driver_path)
            self.browser = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities={'browserName': 'chrome'})
            logger.info("打开谷歌浏览器")
        #if self.driver == "IE":
           # self.browser = webdriver.Ie(self.ie_driver_path)
           # logger.info("打开IE浏览器")
Example #26
0
from time import sleep

from common.logger import Logging
from page_obj.base import Page
from testCase.myunittest import livecreate
from testFile.elementAndText import Page_Text

logger = Logging("createLive").getlog()
class createLive(livecreate, Page):
    """创建直播测试用例"""
    def test_texts_1(self):
        """文本验证"""
        reality_text = self.createLive.create_live_texts()
        anticipated_text = Page_Text["create_string"]
        for reality, anticipated in zip(reality_text, anticipated_text[0:16]):
            try:
                self.assertEqual(reality, anticipated)
                logger.info("实际文本:{},预期文本:{}".format(reality, anticipated))
            except  Exception as e:
                logger.error("********用例执行错误*********%s" % e)
                self.AssertionError.append("实际文本:{},预期文本:{}".format(reality, anticipated))

    def test_title_2(self):
        """测试title输入框"""
        title_texts = self.createLive.input_title_test()
        real_num = ['0/30', '18/30', '30/30', '30/30']
        for title, real in zip(title_texts, real_num):
            try:
                self.assertEqual(title, real)
                logger.info("实际输入:{}个字符,预计输入:{}字符".format(title, real))
            except Exception as e:
Example #27
0
from common.logger import Logging

from testCase.myunittest import cmslogin_test
from testFile.elementAndText import Page_Text

logger = Logging("CMSLoginTest").getlog()


class CMSLoginTest(cmslogin_test):
    """CMS登录测试用例"""
    def test_login_1(self):
        """页面文本验证"""
        reality_text = self.cmsLogin.tests()
        # len(reality_text)

        anticipated_text = Page_Text["cms_login"]
        for reality, anticipated in zip(reality_text, anticipated_text):
            try:
                self.assertEqual(reality, anticipated)
                logger.info("实际文本:{},预期文本:{}".format(reality, anticipated))
            except Exception as e:
                logger.error("********用例执行错误*********%s" % e)
                self.AssertionError.append("实际文本:{},预期文本:{}".format(
                    reality, anticipated))

        print("期望的值:", anticipated_text)
        print("获取的值:", reality_text)

    def test_login_2(self):
        """登录错误提示语验证"""
        datas = self.get_excel_data("login/cmslogin", 2)
Example #28
0
from common.logger import Logging
from page_obj.base import Page



logger = Logging("lmsAF").getlog()
class lmsAF(Page):
    def __init__(self,driver):
        Page.__init__(self,driver)
        self.config_element = {
            "账号输入框": ["id", "login_user_email"],
            "密码输入框": ['id', "login_password"],
            "登录按钮": ['css', "body > div.company-login.login01 > div > div.login-panel-body > form > div.form-group.no-margin-bot > div > button"],
            "登录错误提示": ['id', 'show_error'],
            "忘记密码": ['id', 'forget_password'],
            "验证码登录": ['css', 'body > div.company-login.login01 > div > div.login-panel-body > form > div.tips > div > a.pull-right.code-btn'],
            "账号密码登录": ['id', 'accout-login'],
            "中英文切换": ['css', 'body > div.language > ul > li.language-active > a'],
            "英文": ['linktext', 'English'],
            "中文": ['linktext', '中文'],
            '错误': ['id', 'part1_err_msg'],
            '提交': ['id', 'btn_account_submit'],
            '手机&邮箱': ['id', 'account'],
            '忘记_手机': ['xpath', '/html/body/div[2]/div/div[2]/form/div[1]/div/input'],
            '忘记_验证码': ['xpath', '/html/body/div[2]/div/div[2]/form/div[2]/div/button'],
            '验证_error': ['id', 'show_code_error'],
        }
    page_texts = [
        "https://rk98tc.e-ducation.cn/account/forget_password/",
        "Forgot password",
        "忘记密码",
Example #29
0
from common.drive import Driver
from common.logger import Logging
from page_obj.pm.per_pm import perpmLogin


from testCase.myunittest import myunittest

logger = Logging("pmLoginTest").getlog()
class perpmLoginTest(myunittest):
    def setUp(self):
        driver = Driver(self.browser).open_browser()
        self.perpmLogin = perpmLogin(driver)
        self.perpmLogin.open('https://www.eliteu.cn/')
        self.AssertionError = []

    def tearDown(self):
        self.perpmLogin.quit()
        self.assertEqual([], self.AssertionError)
    def test_login_1(self):
        self.perpmLogin.cli()
        for i in range(len(self.perpmLogin.page_texts)):
            error_text = self.perpmLogin.per_login_test(i)
            print(error_text)
            if error_text != '邮箱或手机号码格式有误' and error_text != '':
                logger.info('登录用例成功')

            else:
                logger.info('登录用例错误')
                self.AssertionError.append("登录用例错误")
Example #30
0
import unittest

from common.drive import Driver
from common.logger import Logging
from page_obj.base import Page
from page_obj.price_t_select import check
from readYaml import yl
"""
功能以及支持测试,比对目标地址
"""
logger = Logging("test_fun").getlog()

class test_f(unittest.TestCase,Page,check):
    browser = yl['t_wc']['browser']
    url = yl['t_wc']['url']

    def setUp(self):
        self.driver = Driver(self.browser).open_browser(self.url)
    def tearDown(self):
        logger.info('测试完成,现在退出')
        self.driver.quit()

    def test_fn(self):
        self.click("t_fun","fun")
        self.click("t_fun","free")
        url = self.driver.current_url
        t_url = yl["t_fun"]["url"]
        self.check_url(url,t_url,"free")
        self.driver.back()
        self.click("t_fun","use_now")
        url = self.driver.current_url