コード例 #1
0
ファイル: step.py プロジェクト: feesland/AutoUI_Frame
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!")
コード例 #2
0
ファイル: step.py プロジェクト: feesland/AutoUI_Frame
 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!")
コード例 #3
0
ファイル: step.py プロジェクト: feesland/AutoUI_Frame
 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!")
コード例 #4
0
ファイル: step.py プロジェクト: feesland/AutoUI_Frame
 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!")
コード例 #5
0
ファイル: step.py プロジェクト: feesland/AutoUI_Frame
 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!")
コード例 #6
0
ファイル: step.py プロジェクト: feesland/AutoUI_Frame
 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.")