e2ejs.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:pyselenium-js 作者: neetjn 项目源码 文件源码
def ng2_call_component_function(self, element, func, params='', return_out=False):
        """
        :Description: Will execute the component instance function with provided parameters.
        :Warning: This will only work for Angular components.
        :param element: Element for browser instance to target.
        :param func: Function to execute from component instance.
        :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 = 'ng.probe(arguments[0]).componentInstance.%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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号