def RunBrowser(baseURL):
    fc = FileChecK()
    boolean = fc.is_has_file("RunWhichBrowser.ini")
    if boolean:
        rwb_ini_path = fc.get_fileabspath()
    conf = Config(rwb_ini_path)
    runBrowser = conf.get("run", "browser")
    LogObj().debug("======本次试用%s浏览器进行测试======" % runBrowser)
    driver = WebDriverDoBeforeTest().getDriverTooler(runBrowser, baseURL)
    return driver
 def __init__(self, driver):
     fc = FileChecK()
     boolean = fc.is_has_file("framework.ini")
     if boolean:
         self.projectpath = fc.getProjectPath()
         self.fwInipath = fc.get_fileabspath()
     self.conf = Config(self.fwInipath)
     self.capturePath = os.path.join(
         self.projectpath, self.conf.get("capturePath", "capturePath"))
     self.pauseTime = self.conf.get("TimeSet", "pauseTime")
     self.logger = LogObj()
     self.driver = driver
Exemplo n.º 3
0
    def __init__(self):
        fc = FileChecK()
        boolean = fc.is_has_file("framework.ini")
        if boolean:
            rwb_ini_path = fc.get_fileabspath()
        conf = Config(rwb_ini_path)
        baseURL = conf.get("baseURL", "baseURL")
        self.driver = RunBrowser(baseURL)

        self.driverapi = WebdriverApi(self.driver)
        self.logger = LogObj()
        self.basecase = WebDriverDoBeforeTest()
        self.basecase.driver = self.driver
Exemplo n.º 4
0
    def __init__(self):

        self.__GBD = GetBrowserDriver()
        self.__logger = LogObj()
        self.driver = None
        fc = FileChecK()
        boolean = fc.is_has_file("framework.ini")
        if boolean:
            self.inipath = fc.get_fileabspath()

        self.fw_conf = Config(self.inipath)
        self.waitTimeout = self.fw_conf.get("TimeSet", "waitTimeout")
        self.scriptTimeout = self.fw_conf.get("TimeSet", "scriptTimeout")
        self.pageLoadTimeout = self.fw_conf.get("TimeSet", "pageLoadTimeout")
Exemplo n.º 5
0
class InitBrowser():
    '''
    configbrowser本身的self对象去调用其他的类方法
    '''
    def __init__(self):

        self.__GBD = GetBrowserDriver()
        self.__logger = LogObj()
        self.driver = None
        fc = FileChecK()
        boolean = fc.is_has_file("framework.ini")
        if boolean:
            self.inipath = fc.get_fileabspath()

        self.fw_conf = Config(self.inipath)
        self.waitTimeout = self.fw_conf.get("TimeSet", "waitTimeout")
        self.scriptTimeout = self.fw_conf.get("TimeSet", "scriptTimeout")
        self.pageLoadTimeout = self.fw_conf.get("TimeSet", "pageLoadTimeout")

    def beforeTestInitBrowser(self, browsername, baseURL):
        if "chrome" == browsername:
            self.startChromeDriver(baseURL)
        elif "ie" == browsername:
            self.startInternetExplorerDriver(baseURL)
        elif "firefox" == browsername:
            self.startFirefoxDriver(baseURL)
        else:
            self.startFirefoxDriver(baseURL)

    def startFirefoxDriver(self, baseURL):
        try:
            firefoxdriver = self.__GBD.get_FirefoxDrvier()
            os.environ["webdriver.firefox.bin"] = firefoxdriver
            self.driver = webdriver.Firefox()

            self.driver.set_page_load_timeout(self.pageLoadTimeout)
            self.__logger.debug("set pageLoadTimeout : " +
                                self.pageLoadTimeout)
            self.driver.implicitly_wait(self.waitTimeout)
            self.__logger.debug("set waitTimeout : " + self.waitTimeout)
            self.driver.set_script_timeout(self.scriptTimeout)
            self.__logger.debug("set scriptTimeout : " + self.scriptTimeout)
            self.__logger.info("初始化火狐浏览器成功")
            self.driver.maximize_window()
            self.get(baseURL, 3)

        except Exception, e:
            self.__logger.error("getFirefoxDriver()方法发生异常,异常信息:" + e)
Exemplo n.º 6
0
 def __init__(self):
     self.logger = LogObj()
     self.fc = FileChecK()
     boolean = self.fc.is_has_file("db.ini")
     if boolean:
         self.inipath = self.fc.get_fileabspath()
     self.conf = Config(self.inipath)
     self.host = str(self.conf.get("dbset", "host"))
     self.port = int(self.conf.get("dbset", "port"))
     self.user = str(self.conf.get("dbset", "user"))
     self.passwd = str(self.conf.get("dbset", "passwd"))
     self.db = str(self.conf.get("dbset", "db"))
     self.charset = str(self.conf.get("dbset", "charset"))
     self.conn = MySQLdb.Connect(self.host, self.user, self.passwd, self.db,
                                 self.port, self.charset)
     self.logger.debug("数据库初始化完成" + self.host + str(self.port) + self.db +
                       self.charset)
Exemplo n.º 7
0
class Execute_SQL():
    def __init__(self):
        self.logger = LogObj()
        self.fc = FileChecK()
        boolean = self.fc.is_has_file("db.ini")
        if boolean:
            self.inipath = self.fc.get_fileabspath()
        self.conf = Config(self.inipath)
        self.host = str(self.conf.get("dbset", "host"))
        self.port = int(self.conf.get("dbset", "port"))
        self.user = str(self.conf.get("dbset", "user"))
        self.passwd = str(self.conf.get("dbset", "passwd"))
        self.db = str(self.conf.get("dbset", "db"))
        self.charset = str(self.conf.get("dbset", "charset"))
        self.conn = MySQLdb.Connect(self.host, self.user, self.passwd, self.db,
                                    self.port, self.charset)
        self.logger.debug("数据库初始化完成" + self.host + str(self.port) + self.db +
                          self.charset)

    def execute_select(self, sql):
        cursor = self.conn.cursor()
        try:
            cursor.execute(sql)
            self.logger.debug("check_acct_available :" + sql)
            res = cursor.fetchall()
            if len(res) < 1:
                self.logger.error("%s执行查询内容不存在" % sql)
            return res
        finally:
            cursor.close()
        return None

    def execute_addone(self, sql):
        cursor = self.conn.cursor()  #操作数据库的游标
        try:
            cursor.execute(sql)  #执行sql语句
            if cursor.rowcount == 1:
                self.logger.debug("%s添加成功" % sql)
                self.conn.commit()  #执行成功后向数据库进行提交
                return True
        except Exception, e:
            self.conn.rollback()
            self.logger.error("插入数据出现错误" + str(e))
        finally:
class WebdriverApi():
    def __init__(self, driver):
        fc = FileChecK()
        boolean = fc.is_has_file("framework.ini")
        if boolean:
            self.projectpath = fc.getProjectPath()
            self.fwInipath = fc.get_fileabspath()
        self.conf = Config(self.fwInipath)
        self.capturePath = os.path.join(
            self.projectpath, self.conf.get("capturePath", "capturePath"))
        self.pauseTime = self.conf.get("TimeSet", "pauseTime")
        self.logger = LogObj()
        self.driver = driver

    def pause(self, millisecond):
        try:
            time.sleep(millisecond)
        except Exception, e:
            self.logger.error("pause error:" + str(e))
Exemplo n.º 9
0
 def __init__(self):
     self.fc = FileChecK()
     bools = self.fc.is_has_file("email.ini")
     if bools:
         fp = self.fc.get_fileabspath()
         conf = Config(fp)
         self.smtp_host = conf.get("emails", "smtp_host")
         self.pop3_host = conf.get("emails", "pop3_host")
         self.receiver = conf.get("emails", "receiver").split(",")
         self.receiver_pa = conf.get("emails", "receiver_pa")
         self.sender = conf.get("emails", "sender")
         self.sender_pa = conf.get("emails", "sender_pa")
     self.logger = LogObj()
Exemplo n.º 10
0
def html_reporter():
    logger = LogObj()
    fc = FileChecK()
    pro_path = fc.getProjectPath()
    boolean = fc.is_has_file("framework.ini")
    if boolean:
        inipath = fc.get_fileabspath()
        fw_conf = Config(inipath)
    htmlrp_path = fw_conf.get("htmlreportPath", "htmlreportPath")
    htmreportl_abs_path = os.path.join(pro_path,htmlrp_path)
    timecurrent = DateTimeManager().formatedTime("%Y-%m-%d-%H-%M-%S")
    logger.debug("=====创建了一个html文件报告,路径是::"+htmreportl_abs_path) 
    if not os.path.exists(htmreportl_abs_path):
        os.makedirs(htmreportl_abs_path)
    file_path = str(htmreportl_abs_path)+timecurrent+"-LDP-TestingRreporter.html"
    try:
        if os.path.exists(file_path):
            html_obj = open(file_path,"a") #打开文件   追加
            return html_obj
        else:
            html_obj = file(file_path,"wb+")
            return html_obj 
    except Exception,e:
        logger.error("创建html_reporter出现错误"+str(e)) 
 def __init__(self):
     self.driver = None
     self.className = None
     self.beforeSuiteStarts = 0
     self.afterSuiteStops = 0
     self.beforeClassStarts = 0
     self.afterClassStops = 0
     self.beforeTestStarts = 0
     self.afterTestStops = 0
     fc = FileChecK()
     boolean = fc.is_has_file("framework.ini")
     if boolean:
         self.projectpath = fc.getProjectPath()
         self.fwInipath = fc.get_fileabspath()
     self.logger = LogObj()
     self.capturePath = os.path.join(
         self.projectpath,
         Config(self.fwInipath).get("capturePath", "capturePath"))
Exemplo n.º 12
0
# -*- coding:UTF-8 -*-
'''
Created on 2016年5月12日

@author: jayzhen
'''

from com.framework.util.FileCheckAndGetPath import FileChecK
from com.framework.util.ConfigCommonManager import Config

fc = FileChecK()
b = fc.is_has_file("email.ini")
if b:
    fp = fc.get_fileabspath()

    c = Config(fp)

    cc = c.get("emails", "receiver")

    print cc
    ee = cc.split(",")
    print type(ee)
    print type(cc)