def ng_call_scope_function(self, element, func, params='', return_out=False):
"""
:Description: Will execute scope function with provided parameters.
:Warning: This will only work for angular.js 1.x.
:Warning: Requires angular debugging to be enabled.
:param element: Element for browser instance to target.
:param func: Function to execute from angular element scope.
:type func: string
:param params: String (naked) args, or list of parameters to pass to target function.
:type params: string, tuple, list
:param return_out: Return output of function call otherwise None
:type return_out: bool
"""
if isinstance(params, string_types):
param_str = params
elif isinstance(params, (tuple, list)):
param_str = self.__serialize_params(params)
else:
raise ValueError('Invalid type specified for function parameters')
exec_str = 'angular.element(arguments[0]).scope().%s(%s);' % (func, param_str)
if return_out:
return self.__type2python(
self.browser.execute_script('return {}'.format(exec_str), element))
else:
self.browser.execute_script(exec_str, element)
评论列表
文章目录