Esempio n. 1
0
def getScreenShot():
    time.sleep(st)
    PIC_DIR = config.PIC_DIR
    PIC_NAME = "ScreenShot_" + common.stamp_datetime2() + ".png"    # ScreenShot naming rules
    PIC_ABS = os.path.join(PIC_DIR,PIC_NAME)
    driver.get_screenshot_as_file(PIC_ABS)
    log.wd_screen(PIC_ABS)
Esempio n. 2
0
def isEqual_raiseError(actual,expect):
    if actual == expect:
        log.check_normal("Result: PASS!")
        report.addResult_normal("PASS!")
    else:
        log.check_normal("Result: Fail!")
        report.addResult_normal("Fail!")
        # Error ScreenShot
        PIC_DIR = config.PIC_DIR
        PIC_NAME = "Error_" + common.stamp_datetime2() + ".png"    # ScreenShot naming rules
        PIC_ABS = os.path.join(PIC_DIR,PIC_NAME)
        driver.get_screenshot_as_file(PIC_ABS)
        log.assert_screen(PIC_ABS)
        # raise Error
        raise autoTestError("The isEqual Check is not OK!")
Esempio n. 3
0
 def __init__(self,xpath):
     self.xpath = xpath
     log.step_normal("Elements Groups:   xPath \"{0}\"".format(xpath)) 
     self.elementGroup = driver.find_elements_by_xpath(self.xpath)
     if self.elementGroup == []:
         log.assert_normal("The Elements Group found by xPath(\"{0}\") is wrong!".format(self.xpath))
         report.addError_normal("The Element found by xPath(\"{0}\") is wrong!".format(self.xpath))
         # Error ScreenShot
         PIC_DIR = config.PIC_DIR
         PIC_NAME = "Error_" + common.stamp_datetime2() + ".png"    # ScreenShot naming rules
         PIC_ABS = os.path.join(PIC_DIR,PIC_NAME)
         driver.get_screenshot_as_file(PIC_ABS)
         log.assert_screen(PIC_ABS)
         report.addError_pic("The screenshot is saved: {0}! ".format(PIC_NAME))
         # raise Error
         raise autoTestError("The Elements Group is wrong!")
Esempio n. 4
0
 def getText(self):
     try:
         log.step_normal("           return element value")
         return self.element.text
     except Exception: 
         log.assert_normal("The Element:{0} operating getText is invalid.".format(self.xpath))
         report.addError_normal("The Element:{0} operating getText is invalid.".format(self.xpath))
         # Error ScreenShot
         PIC_DIR = config.PIC_DIR
         PIC_NAME = "Error_" + common.stamp_datetime2() + ".png"    # ScreenShot naming rules
         PIC_ABS = os.path.join(PIC_DIR,PIC_NAME)
         driver.get_screenshot_as_file(PIC_ABS)
         log.assert_screen(PIC_ABS)
         report.addError_pic("The screenshot is saved: {0}! ".format(PIC_NAME))
         # raise Error
         raise autoTestError("The element is wrong!")
Esempio n. 5
0
 def send_keys(self,txt):
     try:
         log.step_normal("           Send_keys \"{0}\" ".format(txt))
         self.element.send_keys(txt)
         addTS(1)
     except Exception: 
         log.assert_normal("The Element:{0} operating send_keys is invalid.".format(self.xpath))
         report.addError_normal("The Element:{0} operating send_keys is invalid.".format(self.xpath))
         # Error ScreenShot
         PIC_DIR = config.PIC_DIR
         PIC_NAME = "Error_" + common.stamp_datetime2() + ".png"    # ScreenShot naming rules
         PIC_ABS = os.path.join(PIC_DIR,PIC_NAME)
         driver.get_screenshot_as_file(PIC_ABS)
         log.assert_screen(PIC_ABS)
         report.addError_pic("The screenshot is saved: {0}! ".format(PIC_NAME))
         # raise Error
         raise autoTestError("The element is wrong!")
Esempio n. 6
0
 def submit(self):		
     try:
         log.step_normal("           Submit ")
         log.step_normal("           Current URL: {0}".format(driver.current_url))
         self.element.submit()
         addTS(1)
         driver.implicitly_wait(it)
     except Exception: 
         log.assert_normal("The Element:{0} operating submit is invalid.".format(self.xpath))
         report.addError_normal("The Element:{0} operating submit is invalid.".format(self.xpath))
         # Error ScreenShot
         PIC_DIR = config.PIC_DIR
         PIC_NAME = "Error_" + common.stamp_datetime2() + ".png"    # ScreenShot naming rules
         PIC_ABS = os.path.join(PIC_DIR,PIC_NAME)
         driver.get_screenshot_as_file(PIC_ABS)
         log.assert_screen(PIC_ABS)
         report.addError_pic("The screenshot is saved: {0}! ".format(PIC_NAME))
         # raise Error
         raise autoTestError("The element is wrong!")
Esempio n. 7
0
 def getAttribute(self, attributeName):
     try:
         log.step_normal("           return element's attribute: {0}".format(attributeName))
         value = self.element.get_attribute(attributeName)
         if value is None:
             raise caseVarError()
         else:
             return value
     except Exception: 
         log.assert_normal("The Element:{0} operating get_attribute:'{1}' is invalid.".format(self.xpath,attributeName))
         report.addError_normal("The Element:{0} operating get_attribute:{0} is invalid.".format(self.xpath,attributeName))
         # Error ScreenShot
         PIC_DIR = config.PIC_DIR
         PIC_NAME = "Error_" + common.stamp_datetime2() + ".png"    # ScreenShot naming rules
         PIC_ABS = os.path.join(PIC_DIR,PIC_NAME)
         driver.get_screenshot_as_file(PIC_ABS)
         log.assert_screen(PIC_ABS)
         report.addError_pic("The screenshot is saved: {0}! ".format(PIC_NAME))
         # raise Error
         raise autoTestError("The element is wrong.")
Esempio n. 8
0
'''

import common, config

import sys, os
reload(sys)
sys.setdefaultencoding('utf-8')

'''
    log file path & naming rules
'''  
LOG_DIR = config.LOG_DIR      
HTML_DIR = config.HTML_DIR
PIC_DIR = config.PIC_DIR

LOG_NAME = "log_" + common.stamp_datetime2() + ".txt"   # Log naming rules
LOG_ABS = common.pathJoin(LOG_DIR, LOG_NAME)

USERLOG_NAME = "userlog_" + common.stamp_datetime2() + ".txt"   # user's Log naming rules
USERLOG_ABS  = common.pathJoin(LOG_DIR, USERLOG_NAME)

HTML_NAME = common.stamp_datetime2() + ".html"          # HTML naming rules             
HTML_ABS = common.pathJoin(HTML_DIR,HTML_NAME) 


'''
    db log (to mongo)
'''  
groupDir = os.getcwd()
caseSuite = os.path.basename(groupDir)
Esempio n. 9
0
@author: sisi
'''

import common, config


import sys, os
reload(sys)
sys.setdefaultencoding('utf-8')

'''
    Report file path & naming rules
'''  
REPORT_DIR = config.REPORT_DIR      

REPORT_NAME = "Report_" + common.stamp_datetime2() + ".txt"   # Report_ naming rules
REPORT_ABS = common.pathJoin(REPORT_DIR, REPORT_NAME)

groupDir = os.getcwd()
caseSuite = os.path.basename(groupDir)
caseName = ""
caseRunNth = -1

'''
     Report directory and files initial
''' 
common.mkdirs(REPORT_DIR)
with open(REPORT_ABS,"w") as f:             
    pass
print "[Report]\t\t" + REPORT_ABS 
Esempio n. 10
0
def getDatetime():
    return common.stamp_datetime2()