예제 #1
0
    def __init__(self):
        for base in Page.__bases__:
            base.__init__(self)
        self._robot_handler = RobotHandler(self)
        self._option_handler = OptionHandler(self)
        self._yaml_handler = YAMLHandler(self)

        try:
            self.name
        except AttributeError:
            self.name = self._titleize(self.__class__.__name__)

        # Required Attributes in options ##
        self.browser = self._option_handler.get("browser", None)
        self.baseurl = self._option_handler.get("baseurl", None)

        # Setting Up Optional Selenium2Library attributes with OptionHandler ##
        selenium_speed = self._option_handler.get("selenium_speed", 0)
        selenium_implicit_wait = self._option_handler.get("selenium_implicit_wait", 5)

        self.set_selenium_timeout(selenium_implicit_wait)
        self.set_selenium_implicit_wait(selenium_implicit_wait)
        self.set_selenium_speed(selenium_speed)

        _shared_cache = Context.get_cache()
        if _shared_cache is not None:
            self._cache = _shared_cache
        Context.set_cache(self._cache)

        if Context.in_robot():
            Context.set_current_page("pageobjects.Page")
        KeywordManager().add_page_methods(self)
예제 #2
0
    def run_keyword(self, name, args, kwargs):
        """
        RF Dynamic API hook implementation that maps method names to their actual functions.

        :param name: The keyword name from robot
        :type name: str
        :param args: the args from robot
        :type args: list
        :param kwargs: a dict of additional args
        :type kwargs: dict
        :return: callable function
        :rtype: callable
        """
        # Translate back from Robot Framework name to actual method
        ret = None

        func_mapping = KeywordManager().get_meth_mapping_from_robot_alias(self, name)
        meth = func_mapping.func
        try:
            if "${" in func_mapping.func_alias:
                args = self._parse_embedded_args(name, func_mapping.func_alias)
            ret = meth(self, *args, **kwargs)
        except Exception, e:
            Context.set_current_page("automationpages.Page")
            # Pass up the stack, so we see complete stack trace in Robot trace logs
            BuiltIn().fail(str(e))
예제 #3
0
        try:
            if "${" in func_mapping.func_alias:
                args = self._parse_embedded_args(name, func_mapping.func_alias)
            ret = meth(self, *args, **kwargs)
        except Exception, e:
            Context.set_current_page("automationpages.Page")
            # Pass up the stack, so we see complete stack trace in Robot trace logs
            BuiltIn().fail(str(e))

        if isinstance(ret, Page):
            libnames = Context.get_libraries()
            classname = ret.__class__.__name__
            for names in libnames:
                # If we find a match for the class name, set the pointer in Context.
                if names.split(".")[-1:][0] == classname:
                    Context.set_current_page(names)

        if ret is None:
            func = meth.__name__
            if func in Selenium2Library.__dict__.values():
                ret = self
            else:
                for base in Selenium2Library.__bases__:
                    if func in base.__dict__.values():
                        ret = self
                        break

        return ret
    
    def get_keyword_documentation(self, kwname):
        """