Skip to content

Instantly share code, notes, and snippets.

@drnic
Created March 22, 2023 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drnic/284bc36a99ca879136e6e503fe79cc9d to your computer and use it in GitHub Desktop.
Save drnic/284bc36a99ca879136e6e503fe79cc9d to your computer and use it in GitHub Desktop.
require "playwright"
uri = "wss://chrome.browserless.io/playwright?token=#{browserless_api_key}"
Playwright.connect_to_playwright_server(uri) do |playwright|
playwright.chromium.launch do |browser|
page = browser.new_page
page.goto("https://github.com/YusukeIwaki")
page.screenshot(path: "./YusukeIwaki.png")
end
end
@drnic
Copy link
Author

drnic commented Mar 22, 2023

My package.json contains "playwright": "1.27.1", and Gemfile contains gem "playwright-ruby-client", "~> 1.31"

@drnic
Copy link
Author

drnic commented Mar 22, 2023

The error I get looks like:

/Users/drnic/.rvm/gems/ruby-3.2.1/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promises.rb:1258:in `raise': Error: Executable doesn't exist at /usr/src/app/chromium-1028/chrome-linux/chrome (Playwright::Error)
╔═════════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just installed or updated. ║
#export DEFAULT_URL_HOST=http://localhost:3000
║ Please run the following command to download new browsers:              ║
║                                                                         ║
║     npx playwright install                                              ║
║                                                                         ║
║ <3 Playwright Team                                                      ║
╚═════════════════════════════════════════════════════════════════════════╝

@drnic
Copy link
Author

drnic commented Mar 22, 2023

Perhaps there's an issue related to playwright versions. The playwright rubygem seems to want playwright verson 1.31.1

$ bundle exec ruby -e "require 'playwright'; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION.strip"
1.31.1

But looking at the gem I'm unsure where this version number is used; or how it might affect the connection to browserless.

@AlexLoyola
Copy link

The playwright version could be the issue, make sure you install a supported playwright version, since playwright is tightly version coupled -> https://www.browserless.io/docs/versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment