02-4 easytrader.clientTrader.py

1 原理是pywinauto ,自动测试化工具

1.BaseLoginClientTrader 一个有关登录的类,需要传入(ClientTrader)里的参数.

BaseLoginClientTrader里的一个装饰器@abc.abstractmethod和两个方法login(),prepare(),

login()方法 ,

def login(self, user, password, exe_path, comm_password=None, **kwargs):
        """Login Client Trader"""
        pass

Login()方法里有, 账号,密码,exe位置,通讯密码(部分客户端需要)

prepare()方法

    def prepare(
        self,
        config_path=None,
        user=None,
        password=None,
        exe_path=None,
        comm_password=None,
        **kwargs
    ):

登陆客户端
config_path: 登陆配置文件,跟参数登陆方式二选一
user: 账号
password: 明文密码
exe_path: 客户端路径类似 r'C:\htzqzyb2\xiadan.exe', 默认 r'C:\htzqzyb2\xiadan.exe'
comm_password: 通讯密码

如果没有设置config_path, 会把json文件通过file2dict转为字典.,找出user等信息,再通过login()登录

        if config_path is not None:
            account = file2dict(config_path)
            user = account["user"]
            password = account["password"]
            comm_password = account.get("comm_password")
            exe_path = account.get("exe_path")
        self.login(
            user,
            password,
            exe_path or self._config.DEFAULT_EXE_PATH,
            comm_password,
            **kwargs)

2.ClientTrader(IClientTrader) 交易主体类

    def enable_type_keys_for_editor(self):
        """
        有些客户端无法通过 set_edit_text 方法输入内容,可以通过使用 type_keys 方法绕过
        """
        self._editor_need_type_keys = True

如果 set_edit_textv不能使用,使用editor_need_type_keys

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容