Esempio n. 1
0
 def __init__(self, elem_name, *locators, container=None, message=None):
     container = container and " in {}".format(container) or ""
     message = format_msg(message)
     super().__init__(
         "{} not found using any of the locators: {}{}.{}".format(
             elem_name, GuiWidgetMetaData.locators_as_str(locators),
             container, message))
Esempio n. 2
0
 def add_element_meta_data(self, name, context, raw_locators, meta):
     wmd = GuiWidgetMetaData.create_wmd(*raw_locators, meta=meta)
     name = name.lower()
     if not self.has(name):
         self.__ns[name] = {}
     self.__ns[name][context] = wmd
     from arjuna import log_debug
     log_debug("Loaded {} label. EMD: {}".format(name, str(wmd)))
Esempio n. 3
0
 def __init__(self,
              elem_name,
              *locators,
              container=None,
              relations=None,
              filters=None,
              message=None):
     container = container and " in {}".format(container) or ""
     relations = relations and " with relations {}".format(relations) or ""
     filters = filters and " and filters {}".format(filters) or ""
     message = format_msg(message)
     super().__init__(
         "{} not found using any of the locators: {}{}{}{}.{}".format(
             elem_name, GuiWidgetMetaData.locators_as_str(locators),
             relations, filters, container, message))
Esempio n. 4
0
 def _as_raw_wmd(self):
     from arjuna import Arjuna
     from arjuna.interact.gui.auto.finder._with import With
     from arjuna.interact.gui.auto.finder.enums import WithType
     with_list = []
     for k,v in self.__named_args.items():
         if k.upper() in WithType.__members__:
             if isinstance(v, Dictable):
                 v = v.as_dict()
             with_list.append(getattr(With, k.lower())(v))
         elif Arjuna.get_withx_ref().has_locator(k):
             if isinstance(v, Dictable):
                 v = v.as_dict()
                 with_list.append(getattr(With, k.lower())(**v))
             else:
                 with_list.append(getattr(With, k.lower())(v))
         else:
             self.__meta[k] = v
     if not with_list:
         raise Exception("You must provide atleast one locator.")
     from arjuna.interact.gui.auto.finder.wmd import GuiWidgetMetaData
     return GuiWidgetMetaData.create_wmd(*with_list, meta=self.__meta)
Esempio n. 5
0
    def _as_raw_wmd(self):
        from arjuna import Arjuna, oneof, log_debug
        from arjuna.interact.gui.auto.finder._with import With
        from arjuna.interact.gui.auto.finder.enums import WithType

        def add_to_list(with_list, k, v):
            if k.upper() in WithType.__members__:
                if isinstance(v, Dictable):
                    v = v.as_dict()
                with_list.append(getattr(With, k.lower())(v))
            elif Arjuna.get_withx_ref().has_locator(k):
                if isinstance(v, Dictable):
                    v = v.as_dict()
                    with_list.append(getattr(With, k.lower())(**v))
                elif type(v) in {list, tuple}:
                    with_list.append(getattr(With, k.lower())(*v))
                else:
                    with_list.append(getattr(With, k.lower())(v))
            else:
                self.__meta[k] = v

        with_list = []
        for k, v in self.__named_args.items():
            if isinstance(v, oneof):
                for oneofval in v.as_list():
                    add_to_list(with_list, k, oneofval)
            else:
                add_to_list(with_list, k, v)

        if not with_list:
            from arjuna.tpi.error import GuiWidgetDefinitionError
            raise GuiWidgetDefinitionError(
                "You must provide atleast one valid locator argument to create GuiWidgetDefinition definition. None of Arjuna defined locators or withx locators were provided. Got the speification dictionary as: {}"
                .format(self.__named_args))
        from arjuna.interact.gui.auto.finder.wmd import GuiWidgetMetaData

        return GuiWidgetMetaData.create_wmd(*with_list, meta=self.__meta)
Esempio n. 6
0
 def __init__(self, elem_type, *locators, message=None):
     message = message = format_msg(message)
     super().__init__(
         "{} expected to be absent but still present for one of the locators: {}.{}"
         .format(elem_type, GuiWidgetMetaData.locators_as_str(locators),
                 message))
Esempio n. 7
0
 def create_wmd(self, *locators):
     return GuiWidgetMetaData.create_wmd(*locators)