# 使用selenium进行批量操作

By [plsdm7](https://paragraph.com/@dogsuisui) · 2023-11-30

---

这次全程记录一下使用selenium进行批量控制的流程。

[https://qna3.ai/](https://qna3.ai/)

以qun3为例，大概流程是

登录钱包→切换到eth→访问网站→链接钱包（如果已链接则跳过）→切换到opBNB→点击签到→点击确认交易→确认签到成功（如果不成功则重试最多N次）。

整体流程比较复杂，因此能够充分测试到一些异常情况。

几个问题

*   为啥不直接用Automa?
    
    Automa不支持访问chrome-extention，作者也表示没有支持的计划
    

[https://github.com/AutomaApp/automa/issues/247](https://github.com/AutomaApp/automa/issues/247)

     并且自己实现灵活度更高一些

*   每次启动使用全新的浏览器环境？
    
    全新环境，也就是说从下载插件导入钱包开始做起。
    
    对于一些需要web2授权的网站（twitter\\gmail\\discord），不建议使用selenium操作（很容易封号）。如果有这种需求建议先绑定号后再使用钱包登陆。如果不需要钱包只需要web2账号，那直接使用Automa也能满足需求。
    
    综上，我们使用带缓存的chrome实例。
    

配置selenium
----------

钱包相关操作，推荐使用

[https://github.com/javerianadeem/selenium\_metamask\_automation](https://github.com/javerianadeem/selenium_metamask_automation)

这个实现，但需要做一些修改

---

*Originally published on [plsdm7](https://paragraph.com/@dogsuisui/selenium)*
