def _convert_resp_to_dict(response): new_response = { item: getattr(response, item) for item in dir(response) if item[0] != '_' } return DotDict(new_response)
async def wait_for_request_url(self, url, method='GET', body=None, timeout=None): req = await self.library_ctx.get_current_page().get_page( ).wait_for_event( "request", predicate=lambda request: re.search( url, request.url) is not None and request.method == method, timeout=self.timestr_to_secs_for_default_timeout(timeout) * 1000) try: pos_data = (await req.postData()) except: pos_data = '' if body is None or re.search(body, pos_data.replace('\n', '')): log_str = 'Wait for request url: ' + req.method + ' - ' + req.url if pos_data != '': log_str + '\n' + pos_data self.info(log_str) else: raise Exception('Can\'t match request body with ' + body + ' \n ' + pos_data) return DotDict({ 'url': req.url, 'method': req.method, 'body': pos_data })
def _load_config(self): """Load config.py as a variable file in a way that the individual variables can be overriden on command line as if it was loaded explicitly as a variables file. """ config_file = os.path.abspath('config.py') if not os.path.exists(config_file): source_dir = os.path.dirname(os.path.abspath(__file__)) configure = os.path.join(source_dir, 'configure') configure = os.path.relpath(configure) raise ConfigurationError( "Configuration file not found. Forgot to run '{}'?".format( configure)) config = Variables() config.set_from_file(config_file) try: global_variables = BuiltIn().get_variables() for name in config.as_dict(): if name in global_variables: config[name] = global_variables[name] except RobotNotRunningError: # Use the defaults when the IDE queries variables pass return DotDict(config.as_dict(decoration=False))
def _convert_resp_to_dict(response): new_response = {} for item in dir(response): if item[0] != '_': new_response[item] = getattr(response, item) return DotDict(new_response)