Skip to main content

img

seliky — 极简、稳定的 UI 自动化测试库

seliky 致力于做好 UI 自动化及爬虫中与页面交互的逻辑。它在 selenium、自研 Chromium core、Playwright 三大交互引擎之上做了统一封装,三套引擎 API 一致、可互相平滑替换;并在此之上提供自然语言驱动、AI Agent 与单文件 HTML 报告能力。

pip install seliky

核心特性

  1. 极致简约稳定,学习简单🔥🔥🔥🔥🔥
    • 大量复杂、冗余的操作被完美封装,调用语句非常简约干净。
    • 只需记住 get、click、send_keys、is_visible 等少数几个方法即可上手,无需了解 selenium 内在机制,甚至可以用自然语言直接驱动(见下文)。
  2. 三引擎统一 API,平滑替代🔥🔥🔥🔥🔥
    • seliky_sel(selenium 4)、seliky_dri(Chromium core,免驱动)、seliky_pw(Playwright)三套实现 API 相同,相互之间无痛切换。
    • 公用 API 涵盖其它主流封装库的 90%,方便将 helium 等库平滑迁移至 seliky。
  3. 交互稳定🔥🔥🔥🔥🔥
    • 原生 selenium 最大的弊病是"元素明明在页面上却找不到"。seliky 通过最大耗时的精确计算巧妙解决了这一问题。
    • 核心方法如 click、send_keys 均有多重保障机制,所以才稳定好用。
  4. 统一采用 xpath 定位🔥🔥🔥
    • 不同定位符的管理一直是业内通病。为方便管理,seliky 统一采用 xpath 这种万能定位,并支持简化写法(seliky_dri 还支持直接用元素上的文字定位)。
  5. 元素高亮🔥🔥🔥
    • 元素交互时默认高亮闪烁,方便执行时观察页面;无界面模式下自动关闭。
  6. 无侵入式封装🔥🔥
    • 封装不吞掉原生方法,交互中随时可以使用 selenium / seliky.core / Playwright 的原生能力,熟悉原生的用户可无缝切换。
  7. GRID 分布式化繁为简🔥🔥🔥🔥
    • 准备好 jar 包后,一个 remote_location 参数即可控制从机,一大堆配置变成一个参数。
  8. 自动化、爬虫通用🔥🔥🔥
    • 被反爬的认证机制搞怕了?seliky_dri 无需 driver,anti_spy 参数一键开启防侦测;还支持 take_over_port 接管已打开的浏览器、performance 模式一边走 UI 一边抓包。
  9. 兼容 Robot Framework🔥🔥
    • ROBOT_LIBRARY_SCOPE = 'GLOBAL',可直接作为 RF 关键字库使用。
  10. 自动提取注释、自动报告🔥🔥🔥
    • 自动从 xpath 中提取关键词作为报告说明;内置 autoreport 生成开箱即用的单文件 HTML 报告(含饼图、日志、失败自动截图)。

快速开始:一个案例告诉你有多简单

案例:访问百度,依次搜索 3 组关键词并校验结果。你只需记住几个关键方法:请求 get、点击 click、输入 send_keys、是否可见 is_visible:

from seliky.core.seliky_sel import WebDriver

page = WebDriver(executable_path=r'c:\chromedriver.exe')
page.open_browser()
page.get("https://www.baidu.com")

for word in ["小张", "小李", "小刘"]:
    page.send_keys('//input[@id="kw"]', word)   # 输入值
    page.click('//input[@id="su"]')             # 点击搜索
    if page.is_visible('//img[@class="index-logo-src"]'):
        print('百度logo已正确加载')

page.quit()

如果你是做爬虫的,或想要免 driver 的方式与页面交互,试试 seliky_dri(基于 seliky.core,有 Chrome 浏览器即可):

from seliky.core.seliky_dri import WebDriver

page = WebDriver()          # 实例化无需传参
page.open_browser()
page.get('https://sahitest.com/demo')
page.click('Link Test', bac_sleep=3)   # 直接复制按钮上的文字来定位

偏好 Playwright 的用户使用 seliky_pw,API 与上面完全一致:

from seliky.core.seliky_pw import WebDriver

page = WebDriver()
page.open_browser()
page.get('https://www.baidu.com')

自然语言驱动:不写代码也能自动化

NaturalLanguage 通过规则解析把一句中文变成一串浏览器操作,无需 API Key、离线可用:

安装后可以直接在命令行执行:

seliky -l '打开https://www.baidu.com,在搜索框输入你好,点击百度一下'
seliky -l 'https://example.feishu.cn/sheets/xxxxx'

命令行默认使用 bridge 引擎,通过 recorder 扩展接管当前已打开的浏览器。 扩展随 pip install seliky 一起安装,加载方式:

seliky --recorder-path   # 打印扩展目录
# Chrome → chrome://extensions/ → 开发者模式 → 加载已解压的扩展程序

需要使用传统驱动时,可显式指定 --engine seliky_dri。

接管已通过 9222 端口启动的 Chrome:

seliky -l '点击我的学员' --engine seliky_dri --port 9222

用 seliky --help 查看报告、截图和浏览器引擎等选项。飞书表格模式需要 本机已安装并配置 lark-cli。

from seliky.core.natural_langurage import NaturalLanguage

nl = NaturalLanguage(
    report=True,       # 自动生成 HTML 报告
    auto_clear=True,   # 飞书表格执行完后删除本次的本地截图
)
nl.claw('打开https://www.baidu.com,在搜索框输入你好,点击百度一下,向下滚动200像素,等待3秒')

接管已打开的 Chrome 时,需要先用调试端口启动 Chrome:

# macOS
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
  --remote-debugging-port=9222 \
  --user-data-dir=/tmp/seliky-chrome-profile
nl = NaturalLanguage(engine='seliky_dri', take_over_port=9222)
nl.claw('点击我的学员')

已按普通方式启动、未开放调试端口的 Chrome 无法被 seliky.core 事后直接接管。

支持的指令风格示例:打开百度、搜索 seliky 自动化、在第2个输入框输入你好、点击第1个按钮、刷新页面、截图、退出浏览器……

claw 还可以直接传入一个飞书表格 URL:通过 lark-cli 读取表格中符合优先级筛选的行(默认优先级为 1),取同行"操作步骤"列逐条执行,结果与截图自动写回表格,实现"表格即用例"。可用 -p 2,3-5 或 -p 0 指定筛选范围。

自动报告:单文件 HTML

使用报告前需安装可选依赖:pip install 'seliky[report]'。

autoreport.Reporter 执行用例并生成单文件 HTML 报告——通过/失败/跳过饼图、每步日志、失败自动截图,一个文件即可发出去:

from seliky.core.autoreport import Reporter

class TestDemo:
    def test_search(self):
        ...

Reporter(output="output/report.html", title="冒烟报告", executor="teark").run(TestDemo)

模块一览

模块 说明 额外依赖
seliky.core.seliky_sel selenium 4 引擎,支持 GRID 分布式、抓包、防爬、浏览器接管 —
seliky.core.seliky_dri Chromium core 引擎,免 driver,爬虫友好 —
seliky.core.seliky_pw Playwright 引擎,自带浏览器管理 —
seliky.core.natural_langurage 自然语言(规则解析)驱动,支持飞书表格用例 —
seliky.core.autoreport 单文件 HTML 测试报告 pip install 'seliky[report]'

from seliky import WebDriver 默认导出 Chromium core(seliky_dri)版;WebDriver2 为 selenium 版、WebDriver3 为 Playwright 版。推荐按上表从子模块显式导入。

更多其它好用的特性,尽在 seliky,使用 pip install seliky 来体验吧…

Metadata

Release files for seliky 26.10.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for seliky 26.10.1
File Size Uploaded Provenance Actions
seliky-26.10.1.tar.gz 1.1 MB Without provenance Details for seliky-26.10.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for seliky 26.10.1
File Interpreter ABI Platform Actions
seliky-26.10.1-py3-none-any.whl Python 3 none any Details for seliky-26.10.1-py3-none-any.whl

Total release size: 2.2 MB

Release files / seliky-26.10.1.tar.gz

Download URL seliky-26.10.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
7bbab0585119c136b271189b99f425265de7e4e8810cba5f7cd6fd63e87e276f
BLAKE2b-256 checksum
How to use checksums
aad06d967b7d53e6b3c333cdd55b057394d082a560014aea849d53c14cf8e977
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / seliky-26.10.1-py3-none-any.whl

Download URL seliky-26.10.1-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
581a1c21933a48a778a63ea5c5a8a31b181a6d88c6836dd77fd23b0a7c661bde
BLAKE2b-256 checksum
How to use checksums
a66424dddbb4b29990aa5dac39fbec5d723fe48161cc44693edc2210f008d2b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for seliky 26.10.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

26.10.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page