def _get_driver(self, process_name): '''获取AndroidDriver实例 ''' from qt4a.androiddriver.androiddriver import AndroidDriver if not process_name in self._driver_dict: driver = AndroidDriver.create(process_name, self._device) self._driver_dict[process_name] = driver return self._driver_dict[process_name]
def get_driver(self, process_name=''): '''根据进程名获取driver对象,默认为主程序driver ''' if not process_name: if not self._process_name: raise RuntimeError('主程序名为空') process_name = self._process_name if not self._drivers.has_key(process_name): # 只有尚未创建的时候才需要互斥 # logger.debug('wait for %s create driver' % process_name) # 创建driver driver = AndroidDriver.create(process_name, self._device) self._drivers[process_name] = driver # logger.debug('%s create driver success' % process_name) driver = self._drivers[process_name] return driver