Linux平台UI自动化测试-调用dbus

import dbus

class DbusUtils():
    '''
    需传入dbus的几个参数:
    dbus_name
    object_path
    interface
    '''

    def __init__(self, dbus_name, object_path, interface):
        self.dbus_name = dbus_name
        self.object_path = object_path
        self.interface = interface
        self.session_dbus = dbus.SessionBus()


    def object_methods(self):
        '''
        可以调用应用所具有的方法
        :return: 方法的对象
        '''
        self.proxy_object = self.session_dbus.get_object(self.dbus_name, self.object_path)
        self.object_methods = dbus.Interface(self.proxy_object, self.interface)
        return self.object_methods


    def object_properties(self):
        '''
        可以获取应用所具有的属性
        :return: 属性的对象
        '''
        self.proxy_object = self.session_dbus.get_object(self.dbus_name, self.object_path)
        self.object_properties = dbus.Interface(self.proxy_object, dbus.PROPERTIES_IFACE)
        return self.object_properties

  

posted @ 2020-06-27 12:03  mikigo  阅读(41)  评论(0编辑  收藏  举报