def wait_engine_dump_tree(self,timeout): if self.device and self.device.engine_connector(): element = None try: element = WebDriverWait(timeout,2).until(self.device.engine_connector()._get_dump_tree) except Exception as e: logger.warn("getdumptree timeout") return element return None
def wait_engine_element_by_name(self, name, timeout): if self.device and self.device.engine_connector(): element = None try: element = WebDriverWait(timeout,2).until(self.device.engine_connector().find_element,name) except Exception as e: logger.warn("element wait timeout:" + name) return element return None
def get_engine_version(self, timeout): if self.device and self.device.engine_connector(): element = None try: element = WebDriverWait(timeout, 2).until(self.device.engine_connector().get_sdk_version) except Exception as e: logger.warn("get engine version timeout") return element return None
def __default_alert_callback(self, session): btns = set([u'稍后', u'稍后提醒我', u'不再提醒', u'无线局域网与蜂窝移动网络', u'允许', u'知道了', u'确定', u'好']).intersection( session.alert.buttons()) if len(btns) == 0: logger.warn("Alert not handled, buttons: " + ', '.join(session.alert.buttons())) return logger.info('alert handled:' + str(list(btns)[0])) session.alert.click(list(btns)[0]) pass
def __get_wdaport_by_udid(udid): outputlines = CmdExecuter.executeAndWait("ps -ef|grep \"iproxy [0-9]\+ 8100 " + udid + "\"") for line in outputlines: ret = re.search("iproxy ([0-9]+) 8100 " + udid, line.decode("utf-8")) if ret: return ret.group(1) outputlines = CmdExecuter.executeAndWait("ps -ef|grep \"iproxy [0-9]\+ 8100" + "\"") for line in outputlines: ret = re.search("iproxy ([0-9]+) 8100$", line.decode("utf-8")) if ret: return ret.group(1) logger.warn("No wda port detected for device.. " + udid) return None