1个稳定版本
1.2.0 | 2024年1月2日 |
---|---|
0.1.0 |
|
#430 in 测试
44KB
661 行
Squirrel
░░░░░░░░░██▄▒█▀▄░▄▀▄░█░░▒█░▄▀▀▒██▀▒█▀▄░░▒▄▀▄░█▒█░▀█▀░▄▀▄░█▄▒▄█▒▄▀▄░▀█▀░█░▄▀▄░█▄░█░░░░░░░░
▒░▒░▒░▒░▒█▄█░█▀▄░▀▄▀░▀▄▀▄▀▒▄██░█▄▄░█▀▄▒░░█▀█░▀▄█░▒█▒░▀▄▀░█▒▀▒█░█▀█░▒█▒░█░▀▄▀░█▒▀█▒░▒░▒░▒░
.^!777!^.
^5#@@@@@@@&GJ^ !5^.
?@@&#&&@@@@@@@@G! .J@@&PGJ:
.7^:...:~75B@@@@@@G! ..:^~?P&@@@@B@@@J
~5&@@@@@G~ :~?YPGB#&&@@@@@@@@&GPY7.
:?G@@@@@G7. ^YB&@@@@@@@@@@@@@@@@@G.
^?PB&@@BY~Y@@@@@@@@@@@@@@@@@@@@@@&GY?7~:
.::..P@@@@@@&B5J7~~^^^^^^~!77??7!^.
5@@@@@#7:
Y@@@@B?.
:G@&GJ~
.#G!.
:5
.
░░░░░░░░░░░░░░░░░░░░░█░░▒█░█░▀█▀░█▄█░░░░░▄▀▀░▄▀▄░█▒█░█▒█▀▄▒█▀▄▒██▀░█▒░░░░░░░░░░░░░░░░░░░░░
▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░░▀▄▀▄▀░█░▒█▒▒█▒█▒░▒░▒▄██░▀▄█░▀▄█░█░█▀▄░█▀▄░█▄▄▒█▄▄▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░
Squirrel通过简化基于YAML的工作流程定义(例如此示例工作流程)革命性地改变了浏览器自动化。使用Squirrel,您可以轻松自动化任务,而无需被技术复杂性所困扰,因为该工具会为您处理所有底层复杂性。
以下是上述工作流程的演示
快速入门
步骤1:设置Chrome进行测试
按照以下步骤设置Chrome进行测试
参考Chrome for Testing:可靠的下载用于浏览器自动化和Chrome for Testing的可用性。但,以下是重点
下载最新稳定的Chrome for Testing二进制文件和ChromeDriver
# Download the latest available Chrome for Testing binary corresponding to the Stable channel.
npx @puppeteer/browsers install chrome@stable
# Download the latest available ChromeDriver version corresponding to the Stable channel.
npx @puppeteer/browsers install chromedriver@stable
使它们可执行
# Setup executables
cd ~
mv chrome chromeDIR
mv chromedriver chromedriverDIR
ln -s chromeDIR/.../Google\ Chrome\ for\ Testing.app Google\ Chrome\ for\ Testing.app
# note: for macOS, drag a copy of Google Chrome for Testing app to "Applications" as well
ln -s chromedriverDIR/.../chromedriver chromedriver
调用Chrome Driver
# Run webdriver
cd ~
./chromedriver --verbose --port=9515 --allowed-origins='*' --allowed-ips='0.0.0.0'
一旦webdriver正在运行,您可以通过连接到http://0.0.0.0:9515/进行测试。
步骤2:运行Squirrel
选项1:使用Docker镜像中的Squirrel可执行文件(推荐)
参考安装Docker Engine以安装Docker。
对于docker容器与主机连接问题,请参阅我想从容器连接到主机上的服务。
# Run with sample workflow (with default option of webdriver_url=http://host.docker.internal:9515 and headless_browser=true)
docker run --rm --name squirrel goyalmunish/squirrel
# or, run with your own workflow without headless browser
docker run --rm --name squirrel goyalmunish/squirrel ./src/sample_workflow.yaml http://host.docker.internal:9515 false
选项2:使用本地构建的Squirrel可执行文件
# Clone the repo
git clone [email protected]:goyalmunish/squirrel.git
# cd into projet directory
cd squirrel
# Run with sample workflow (with default option of webdriver_url=https://127.0.0.1:9515 and headless_browser=true)
cargo run --release ./src/sample_workflow.yaml
选项3:使用Docker镜像中的Squirrel可执行文件和WebDriver(实验性)
参考
SeleniumHQ/docker-selenium
(Selenium Docker镜像)seleniumhq-community/docker-seleniarm
(适用于Arm64的Selenium Docker镜像)
# Run Selenium Chromium Driver on MacOS (Arm64)
docker run --rm -it -p 4444:4444 -p 7900:7900 --shm-size="2g" -v /dev/shm:/dev/shm --name chrome seleniarm/standalone-chromium:latest
# Run Squirrel
docker run --rm --name squirrel goyalmunish/squirrel ./src/sample_workflow.yaml http://host.docker.internal:4444 false
开发指南
构建和推送Docker镜像
使用 build_image.sh
构建和推送 Docker 镜像(需要管理员权限)Docker 镜像
# cd into repo
cd squirrel/
# set version, for example
VERSION=v1.0.0
# build images and pushing them
. ./scripts/build_image.sh ${VERSION}
依赖项
约14–29MB
约491K SLoC