Example #1
0
    def logcat_time_interval(self, log, start, end):
        '''
        get time interval between start/end string in logcat message
        '''
        tblog.traceLog(self.logcat_time_interval, start, end)
        if start in log and end in log:
            for line in log.splitlines():
                if start in line:
                    start_time = line.split()[1]
                    #print(start + ": " + start_time)
                if end in line:
                    end_time = line.split()[1]
                    #print(end + ": " + end_time)
                    break  #FIXME: only check first pair
        else:
            print("No {0}/{1} event found!!!".format(start, end))
            tblog.errorLog("Failed to find event string in logcat")
            return ("0:0:0.0")
            #raise BellagioError("Failed to find event string in logcat")

        interval_hr, interval_min, interval_sec, interval_ms = self.calculate_logcat_interval(
            start_time, end_time)
        return (start_time, end_time,
                "{}:{}:{}.{}".format(interval_hr, interval_min, interval_sec,
                                     interval_ms))
Example #2
0
 def text_click(self, string):
     '''
     click object contains specific string
     '''
     try:
         self.dev(textContains=string).click()
     except Exception as e:
         #raise BellagioError("Failed to click {0} {1}" .format(txt, e))
         tblog.errorLog(str(e))
Example #3
0
 def text_on_screen(self, string):
     '''
     Check if current screen contains string
     '''
     ret = self.dev.exists(textContains=string)
     if ret == False:
         tblog.errorLog("Text \"{0}\" not found".format(string))
     #raise BellagioError("Text {0} not found: {1}" .format(string, e))
     return ret
Example #4
0
 def search_and_click(self,
                      searchStr,
                      parentClass="android.widget.LinearLayout",
                      childClass="android.widget.TextView"):
     '''
     scroll and search text and click it 
     '''
     try:
         self.dev(className=parentClass).child_by_text(
             searchStr, allow_scroll_search=True,
             className=childClass).click()
     except Exception as e:
         #raise BellagioError("Failed to click {0} {1}" .format(txt, e))
         tblog.errorLog(str(e))
Example #5
0
 def text_click_obj_around(self,
                           searchStr,
                           around="right",
                           objectAround="android.widget.Switch"):
     '''
     search
     '''
     try:
         if around == "right":
             self.dev(textContains="OK Google").right(
                 className=objectAround).click()
         elif around == "left":
             self.dev(textContains="OK Google").left(
                 className=objectAround).click()
     except Exception as e:
         #raise BellagioError("Failed to click {0} {1}" .format(txt, e))
         tblog.errorLog(str(e))