Skip to main content

img

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

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

pip install seliky

核心特性

  1. 极致简约稳定,学习简单🔥🔥🔥🔥🔥
    • 大量复杂、冗余的操作被完美封装,调用语句非常简约干净。
    • 只需记住 getclicksend_keysis_visible 等少数几个方法即可上手,无需了解 selenium 内在机制,甚至可以用自然语言直接驱动(见下文)。
  2. 三引擎统一 API,平滑替代🔥🔥🔥🔥🔥
    • seliky_sel(selenium 4)、seliky_dri(DrissionPage,免驱动)、seliky_pw(Playwright)三套实现 API 相同,相互之间无痛切换。
    • 公用 API 涵盖其它主流封装库的 90%,方便将 helium 等库平滑迁移至 seliky。
  3. 交互稳定🔥🔥🔥🔥🔥
    • 原生 selenium 最大的弊病是"元素明明在页面上却找不到"。seliky 通过最大耗时的精确计算巧妙解决了这一问题。
    • 核心方法如 clicksend_keys 均有多重保障机制,所以才稳定好用。
  4. 统一采用 xpath 定位🔥🔥🔥
    • 不同定位符的管理一直是业内通病。为方便管理,seliky 统一采用 xpath 这种万能定位,并支持简化写法(seliky_dri 还支持直接用元素上的文字定位)。
  5. 元素高亮🔥🔥🔥
    • 元素交互时默认高亮闪烁,方便执行时观察页面;无界面模式下自动关闭。
  6. 无侵入式封装🔥🔥
    • 封装不吞掉原生方法,交互中随时可以使用 selenium / DrissionPage / 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.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(基于 DrissionPage,有 Chrome 浏览器即可):

from seliky.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.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'

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

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

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

from seliky.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 无法被 DrissionPage 事后直接接管。

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

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

自动报告:单文件 HTML

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

from seliky.autoreport import Reporter

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

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

模块一览

模块 说明 额外依赖
seliky.seliky_sel selenium 4 引擎,支持 GRID 分布式、抓包、防爬、浏览器接管
seliky.seliky_dri DrissionPage 引擎,免 driver,爬虫友好
seliky.seliky_pw Playwright 引擎,自带浏览器管理
seliky.natural_langurage 自然语言(规则解析)驱动,支持飞书表格用例
seliky.agent Claude 大模型驱动的 UI Agent pip install seliky[agent]
seliky.autoreport 单文件 HTML 测试报告 pip install seliky[report](截图增强)
seliky.ai_auto FastAPI 路由,供平台级集成(SSE 推送执行结果) pip install seliky[ai]

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

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seliky-26.9.tar.gz (424.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seliky-26.9-py3-none-any.whl (425.9 kB view details)

Uploaded Python 3

File details

Details for the file seliky-26.9.tar.gz.

File metadata

  • Download URL: seliky-26.9.tar.gz
  • Upload date:
  • Size: 424.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for seliky-26.9.tar.gz
Algorithm Hash digest
SHA256 3e26ea90e7606b90720a2f02265e405748100a0d7cba22c40d49f745540633bd
MD5 30e685c08acd35c0b1bab1a9e65d46e2
BLAKE2b-256 5af8250a5b5559e5f3aa623b5a4a829f88ad0a13c68831f44041144cdae386d3

See more details on using hashes here.

File details

Details for the file seliky-26.9-py3-none-any.whl.

File metadata

  • Download URL: seliky-26.9-py3-none-any.whl
  • Upload date:
  • Size: 425.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for seliky-26.9-py3-none-any.whl
Algorithm Hash digest
SHA256 7a99cead12aaf44a210ca09aaa2305dd2cc40ddd36a797edc4779fdffb036659
MD5 03a56a7a056ffba7aefe45e4f9266391
BLAKE2b-256 f27a604044c0c6dc78cf6292436d7e63bf98677eb4c8655291f66af7f219779c

See more details on using hashes here.

Release history Release notifications | RSS feed

26.10

2 files

This release

26.9 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page