예제 #1
0
    def invoke(self, method_name, arg1=None, arg2=None, arg3=None, arg4=None, arg5=None):
        message = {}
        message.update({"cmd": "invoke"})
        message.update({"context": self.context})
        args = {"method": method_name}

        if arg1 is not None:
            args.update({"arg1": arg1})

        if arg2 is not None:
            args.update({"arg2": arg2})

        if arg3 is not None:
            args.update({"arg3": arg3})

        if arg4 is not None:
            args.update({"arg4": arg4})

        if arg5 is not None:
            args.update({"arg5": arg5})

        message.update({"params": args})

        new_ctx, result = do_action(self._conn, message, fail_no_context=True)

        new_obj = create_object(result)

        logger.debug('ok')

        return self
예제 #2
0
 def role_names(self):
     logger.info('get model' 's value ')
     message = {}
     message.update({"cmd": "role_names"})
     message.update({"context": self.context})
     new_ctx, result = do_action(self._conn, message, fail_no_context=False)
     logger.debug('ok')
     return create_object(result)
예제 #3
0
 def values(self, role):
     logger.info('get model' 's values ' + role)
     message = {}
     message.update({"cmd": "model_value"})
     message.update({"context": self.context})
     message.update({"params": {"role": role}})
     new_ctx, result = do_action(self._conn, message, fail_no_context=False)
     logger.debug('ok')
     return create_object(result)
예제 #4
0
    def next(self):
        """
        Use to find item that has same ancestor as current object
        :param expr: i.e 'objectName=btn1&visible=true'
        :param ancestor_object_name: objectName of ancestor
        :return:
        """
        logger.info('next ')
        message = {}
        message.update({"cmd": "next"})
        message.update({"context": self.context})
        new_ctx, result = do_action(self._conn, message, fail_no_context=False)

        new_obj = create_object(result, '')

        logger.debug('ok')

        return new_obj
예제 #5
0
    def wait_for(self, expr):
        """
        For given object_name wait for object until global test timeout expire.

        :param expr: correspond to QML component's id
        :return: context QQ or raise  TestFailed
        should return QQ with found context. If nothing found, timeout raise TestFailed exception
        """
        logger.info('wait_for {}'.format(expr))
        message = {}
        message.update({"cmd": "wait_for"})
        message.update({"context": 'frontend'})
        message.update({"params": {"exp": expr}})
        new_ctx, result = do_action(self._conn, message)

        logger.debug(' found (ok)')

        new_obj = create_object(result)
        return new_obj
예제 #6
0
    def find_sibling(self, expr, ancestor_object_name):
        """
        Use to find item that has same ancestor as current object
        :param expr: i.e 'objectName=btn1&visible=true'
        :param ancestor_object_name: objectName of ancestor
        :return:
        """
        logger.info('find_sibling {} {}'.format(expr, ancestor_object_name))
        message = {}
        message.update({"cmd": "find_sibling"})
        message.update({"context": self.context})
        message.update({"params": {"exp": expr, "ancestor": ancestor_object_name}})
        new_ctx, result = do_action(self._conn, message, fail_no_context=False)

        new_obj = create_object(result)

        logger.debug('ok')

        return new_obj
예제 #7
0
    def get(self, property_name):
        """
        Makes query to application to get value of property
        Values is returned from this method and it is stored inside context object
        Accessing properties from context object doesn't make query to application and can be out of date
        :param property_name:
        :return: property value
        """
        logger.info('get property {}'.format(property_name))
        message = {}
        message.update({"cmd": "get"})
        message.update({"context": self.context})
        message.update({"params": {"property_name": property_name}})
        new_ctx, result = do_action(self._conn, message, fail_no_context=False)
        logger.debug('ok')

        if new_ctx == self.context:
            self._properties = result['properties']
            return self._properties[property_name] if property_name in self._properties else None
        else:
            # if context changed it means that property was new object
            return create_object(result)
예제 #8
0
    def wait_for_child(self, expr):
        """
        For given object_name wait for object until global test timeout expire.
        Searching scope is limited to children of context on which function was called.

        i.e wait_for('foo').wait_for_child('bar') will limit scope to children of foo

        Will return only one child

        :param expr: correspond to QML component's id
        :return: context QQ or raise  TestFailed
        should return QQ with found context. If nothing found, timeout raise TestFailed exception
        """
        logger.info('wait_for_child {}'.format(expr))
        message = {}
        message.update({"cmd": "wait_for_child"})
        message.update({"context": self.context})
        message.update({"params": {"exp": expr}})
        new_ctx, result = do_action(self._conn, message)

        logger.debug(' found (ok)')
        new_obj = create_object(result)
        return new_obj
예제 #9
0
    def wait_check_child(self, expr, timeout=5):
        """
        For given object_name wait for object until timeout expire.
        If timeout expire will return False as object was not found.
        If object found before timeout expire returns True.

        global test timeout is ignored for this action i.e timeout=10000 will make wait test until is finished
        regardless of test timeout which could be 5 seconds

        Can be used to check whether object exists or not without failing test

        :param object_name:
        :param visible:
        :param timeout:
        :return: True or False depending whether object was found
        """
        logger.info('exists_child {}'.format(expr))
        message = {}
        message.update({"cmd": "wait_check_child"})
        message.update({"context": self.context})
        message.update({"params": {"timeout": timeout, "exp": expr}})
        new_ctx, result = do_action(self._conn, message, fail_no_context=False)

        return create_object(result)