Esempio n. 1
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. 2
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. 3
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. 4
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. 5
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.")