Example #1
0
# coding=utf-8
__author__ = 'xcma'
import datetime, unittest, Run
from Src.Lib.HTMLTestRunner import HTMLTestRunner
from ReadConfig import readConfig
from Src.Function.Misc import Misc
from LogMainClass import Log
from Src.Function.model.test_result import test_result
import GlobalVariable, os, sys

reload(sys)
sys.setdefaultencoding('utf-8')

log = Log('MainRelated')
tr = test_result()
# 获取传参
report = Run.report
Main = Run.Main
url_target = Run.url_target
run_case = Run.run_case
run_case_by_name = Run.run_case_by_filename
# run_case = ['a05', 'c01']
log.debug('run_case: %s' % run_case)

class MainRelated():
    u'''为构造测试用例、目录、套件服务'''
    log.debug('MainRelated=》start')

    @classmethod
    def generate_report(cls, test_dir, test_Report_path):
        """
Example #2
0
# coding=utf-8
__author__ = 'xcma'
import datetime, unittest, ConfigParser, Run
from Src.Lib.HTMLTestRunner import HTMLTestRunner
from ReadConfig import readConfig
from UiMethods import Os
from LogMainClass import Log
from MySql import MySQL
import GlobalVariable,os, sys

reload(sys)
sys.setdefaultencoding('utf-8')

log = Log('MainRelated')
#获取传参
report = Run.report
Main = Run.Main
url_target = Run.url_target
run_case = Run.run_case
run_case_by_name = Run.run_case_by_filename
# run_case = ['a05', 'c01']
log.debug('run_case: %s' % run_case)
class MainRelated():
    u'''为构造测试用例、目录、套件服务'''
    log.debug('MainRelated=》start')

    @classmethod
    def generate_report(cls, test_dir, test_Report_path):
        """
        主套件执行方法
        :param test_dir:
Example #3
0
# coding=utf-8
__author__ = "xcma"

import unittest, datetime, time, os, shutil
import requests, sys, Run
from selenium import webdriver
from ReadConfig import readConfig
from LogMainClass import Log
from selenium.webdriver import ActionChains
from Misc import Misc

log = Log(name="Methods")
log.debug("Selenium version:%s" % webdriver.__version__)
Config_path = Misc.ABSpath() + "/Src/Conf/Config.yml"
operation = Run.brower


class Operation:
    """
    浏览器相关操作
    """

    def __init__(self, modules_path, chrome_options=None):
        choosebrower = Run.brower
        if choosebrower in "firfox":
            log.debug(u"调用Firefox")
            self.driver = webdriver.Firefox()
        elif choosebrower in "phantomjs":
            self.driver = webdriver.PhantomJS()
            log.debug(u"调用phantomjs")
        else:
Example #4
0
# coding=utf-8
__author__ = 'xcma'
import urllib, urllib2, json, requests
import Run
import unittest, os, shutil, cookielib
from ReadConfig import readConfig
from LogMainClass import Log
from Utils import ABSpath
import json ,time, sys

# utf-8
reload(sys)
sys.setdefaultencoding('utf8')
log = Log('Methods')
Config_path_ym = ABSpath()+"/Src/Conf/Config.yml"
cookfile_path = ABSpath() + readConfig(Config_path_ym)['path']['global_dir']
cookfile_name = readConfig(Config_path_ym)['cookfile_name']

# 获取主域名
input_url = Run.url_target
url_category = "url_off"
if input_url in "www.xxtao.com":
    url_category = "url_off"
elif input_url in "www.wanpinghui.com":
    url_category = "url_on"
else:
    url_category = "url_off"
url_all = readConfig(Config_path_ym)[url_category]
if ',' not in url_all:
    main_domain = url_all
else:
Example #5
0
# coding=utf-8
__author__ = 'xcma'
import unittest, datetime, time, os, shutil, platform
import random, requests, json, sys, Run
from selenium import webdriver
from ReadConfig import readConfig
from LogMainClass import Log
from selenium.webdriver import ActionChains
from Utils import ABSpath

log = Log(name='Methods')
log.debug('Selenium version:%s' % webdriver.__version__)
Config_path = ABSpath() + "/Src/Conf/Config.yml"


class Operation(unittest.TestCase):
    u'''
    浏览器相关操作
    '''
    @classmethod
    def open_browser(cls, chrome_options=None):
        choosebrower = Run.brower
        if choosebrower in 'chrome':
            log.debug(u'调用Chrome')
            cls.driver = webdriver.Chrome(chrome_options=chrome_options)
        elif choosebrower in 'firfox':
            log.debug(u'调用Firefox')
            cls.driver = webdriver.Firefox()
        elif choosebrower in 'phantomjs':
            cls.driver = webdriver.PhantomJS('phantomjs')
            log.debug(u'调用phantomjs')
Example #6
0
# coding=utf-8
__author__ = 'xcma'
import unittest, datetime, time, os, shutil
import requests, sys, Run
from selenium import webdriver
from ReadConfig import readConfig
from LogMainClass import Log
from selenium.webdriver import ActionChains
from Misc import Misc

log = Log(name='Methods')
log.debug('Selenium version:%s' % webdriver.__version__)
Config_path = Misc.ABSpath() + "/Src/Conf/Config.yml"
operation = Run.brower
class Operation(unittest.TestCase):
    """
    浏览器相关操作
    """

    @classmethod
    def open_browser(cls, chrome_options=None):
        choosebrower = Run.brower
        if choosebrower in 'chrome':
            log.debug(u'调用Chrome')
            path = Misc.ABSpath()+"/Src/Lib/chromedriver"

            cls.driver = webdriver.Chrome(executable_path=path, chrome_options=chrome_options)
        elif choosebrower in 'firfox' :
            log.debug(u'调用Firefox')
            cls.driver = webdriver.Firefox()
        elif choosebrower in 'phantomjs':
Example #7
0
# coding=utf-8
__author__ = 'xcma'
import urllib, urllib2, requests
import Run
import unittest, os, cookielib
from ReadConfig import readConfig
from LogMainClass import Log
from Misc import Misc
import sys

# utf-8
reload(sys)
sys.setdefaultencoding('utf8')
log = Log('Methods')
Config_path_ym = Misc.ABSpath()+"/Src/Conf/Config.yml"
cookfile_path = Misc.ABSpath() + readConfig(Config_path_ym)['path']['global_dir']
cookfile_name = readConfig(Config_path_ym)['cookfile_name']

# 获取主域名
input_url = Run.url_target
url_category = "url_off"
if input_url in "www.xxtao.com":
    url_category = "url_off"
elif input_url in "www.wanpinghui.com":
    url_category = "url_on"
else:
    url_category = "url_off"
url_all = readConfig(Config_path_ym)[url_category]
if ',' not in url_all:
    main_domain = url_all
else:
Example #8
0
# coding=utf-8
__author__ = 'xcma'
import MySQLdb
import MySQLdb.cursors
from ReadConfig import readConfig
from Utils import ABSpath
import sys, time, Run, platform
from LogMainClass import Log
reload(sys)
sys.setdefaultencoding('utf-8')

log = Log('MySql')
url_target = Run.url_target


class MySQL:
    """
    mysql相关方法
    connect:链接数据库
    creat_table:创建表
    create datebase dbname;
    """
    @classmethod
    def connect(cls, database='', who='Null'):
        # 链接数据库
        conf_path = ABSpath() + '/Src/Conf/Config.yml'
        if who in 'short_url':
            mysql = readConfig(conf_path)['short_url']
        else:
            mysql = readConfig(conf_path)['local_mysql']
            if platform.system() == 'Linux':