百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

playwright-ruby-client

> 测试质量
开源

用于 Ruby 的 Playwright 客户端

502 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

用于 Ruby 的 Playwright 客户端

Playwright client for Ruby

Docs | API

Getting Started

gem 'playwright-ruby-client'

and then 'bundle install'.

Since playwright-ruby-client doesn't include Playwright, we have to install Node.js and a compatible version of playwright-core in advance.

bash
PLAYWRIGHT_CLI_VERSION=$(bundle exec ruby -e 'require "playwright/version"; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION')
npm install "playwright-core@$PLAYWRIGHT_CLI_VERSION"
./node_modules/.bin/playwright-core install

And set playwright_cli_executable_path: './node_modules/.bin/playwright-core'.

Capture a site

ruby
require 'playwright'

Playwright.create(playwright_cli_executable_path: './node_modules/.bin/playwright-core') do |playwright|
  playwright.chromium.launch(headless: false) do |browser|
    page = browser.new_page
    page.goto('https://github.com/YusukeIwaki')
    page.screenshot(path: './YusukeIwaki.png')
  end
end

Simple scraping

…
bash
$ bundle exec ruby main.rb
==> microsoft/playwright
==> microsoft/playwright-python
==> microsoft/playwright-cli
==> checkly/headless-recorder
==> microsoft/playwright-sharp
==> playwright-community/jest-playwright
==> microsoft/playwright-test
==> mxschmitt/playwright-go
==> microsoft/playwright-java
==> MarketSquare/robotframework-browser

Android browser automation

…

Android native automation

We have to download android-driver for Playwright in advance.

bash
wget https://github.com/microsoft/playwright/raw/master/bin/android-driver-target.apk -O ./node_modules/playwright-core/bin/android-driver-target.apk
wget https://github.com/microsoft/playwright/raw/master/bin/android-driver.apk -O ./node_modules/playwright-core/bin/android-driver.apk
…

Communicate with Playwright server

If your environment doesn't accept installing browser or creating browser process, consider separating Ruby client and Playwright server.

For launching Playwright server, just execute:

./node_modules/.bin/playwright-core install && ./node_modules/.bin/playwright-core run-server --port 8080 --path /ws

and we can connect to the server with the code like this:

ruby
require 'playwright'

Playwright.connect_to_browser_server('wss://example.com:8888/ws') do |browser|
  page = browser.new_page
  page.goto('https://github.com/YusukeIwaki')
  page.screenshot(path: './YusukeIwaki.png')
end

When Playwright.connect_to_browser_server is used, playwright_cli_executable_path is not required.

For more detailed instraction, refer this article: https://playwright-ruby-client.vercel.app/docs/article/guides/playwright_on_alpine_linux

Contributing

See CONTRIBUTING.md for development setup and contributing guidelines.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Playwright project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Issues· 9 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubyplaywrightruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类测试质量
定价开源

> 相关工具

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.